Spark:java.lang.IllegalArgumentException:非法模式组件架构不匹配

时间:2018-07-31 08:40:44

标签: apache-spark spark-structured-streaming

我有此代码,想插入到蜂巢中,但现在要打印到控制台。 如果我使用简单的String而不是模式,则会打印出来,但是如果使用模式,则会给我例外情况

java.lang.IllegalArgumentException: Illegal pattern component: XXX
    at org.apache.commons.lang3.time.FastDateFormat.parsePattern(FastDateFormat.java:577)
 val schema_simple: StructType = StructType(
          Array
        (
         StructField("type", StringType, false),
         StructField("id", StringType, false),
         StructField("happened", StringType, false),
         StructField("processed", StringType, false),
         StructField("tracking_id", StringType, false),
          StructField("source_attributes", StringType, false),
          StructField("event_data", StringType, false)
        )
        )
    //
    val query = event_stream
      .selectExpr("CAST(key AS STRING)", "CAST(value AS STRING)")
      .select(from_json($"value", schema_simple).as("data"))
      .select("data.*")
      .writeStream
      .outputMode("append")
      .queryName("WriteToSource")  
      .format("console")

我正在测试的示例JSON如下,它是从Kafka获得的。我知道有一些不匹配,但我找不到它吗?

{
    "type": "identification.carrier",
    "id": "uui#abb0ef56-8562-4056-aa62-afb758a150ad",
    "happened": "2018-03-28T10:52:44.35+02:00",
    "processed": "2018-03-28T10:52:44.35+02:00",
    "tracking_id": "tid#ad2ebdb1-5d5b-4dcb-a058-494b6af89127",
    "source_attributes": {
        "id": "idsadm@app44A0",
        "data": {
            "info": "resumeIdentify: result: carrier has operator and mobile network",
            "callId": "ad2ebdb1-5d5b-4dcb-a058-494b6af89127",
            "contextId": "0aeb6745-a43c-4257-a535-6905d21a5297",
            "ids_state": "SUCCESS",
            "ids_strategy_type": "REDIRECT_MULTI_WITH_MSISDN_IN_HEADER",
            "ids_identity_type": "MSISDN",
            "country": "DE",
            "ids_result_type": "IDENTITY",
            "ids_result_network": "MobileNetwork[MOBILE=Vodafone D2 GmbH,operator=Operator[ref=10013,MNO=VODAFONE,countryIsoName=DE],countryIsoName=DE,ref=64,mnc=2,mcc=262,mvnos=[Operator[ref=30,MVNO=MOBILCOM-DEBITEL,countryIsoName=DE]]",
            "idsServiceLine": "599 387 240"
        }
    },
    "event_data": {
        "service": {
            "name": "IdsService",
            "version": "4.1"
        },
        "result": {
            "country": "DE",
            "mno": "VODAFONE",
            "mvno": "MOBILCOM-DEBITEL",
            "mcc": "262",
            "mnc": "2"
        }
    }
}

1 个答案:

答案 0 :(得分:0)

尝试添加commons-lang3的最新版本。

ScheduledLesson(timeslotIndex == $timeslot.getIndex() + 1, ...