实木复合地板数据的时间戳列

时间:2020-06-10 21:48:37

标签: scala apache-spark spark-structured-streaming

我正在尝试通过Spark流将实木复合地板数据流传输到Kafka。在数据上运行parquet-tools会将列之一显示为
optional int96 start_timestamp

当我尝试登录Spark Shell并描述数据框架构时,我看到了
StructField(start_timestamp,TimestampType,true)

要流传输数据,首先我要为模式创建一个结构

val dataSchema = new StructType()
      .add("ColA", "string")
      .add("start_timestamp", TimestampType)
      .add("ingested_timestamp", TimestampType)
      .add("product_type", "string")

然后我要读写卡夫卡

spark.readStream
      .option("header", "false")
      .schema(dataSchema)
      .parquet("<location>")
      .withColumn("values", <struct>)
      .select("values" )
      .select(
        AvroFunction.encode_avro(col("values"),jsonFormatSchema1) as 'value
      )
      .writeStream
      .format("kafka")

由于时间戳列,我收到以下错误。如果我删除了时间戳列,它们可以正常工作

Caused by: org.apache.spark.sql.catalyst.parser.ParseException: 
DataType timestamptype is not supported.(line 1, pos 0)
== SQL ==
TimestampType
^^^
    at org.apache.spark.sql.catalyst.parser.AstBuilder$$anonfun$visitPrimitiveDataType$1.apply(AstBuilder.scala:1769)
    at org.apache.spark.sql.catalyst.parser.AstBuilder$$anonfun$visitPrimitiveDataType$1.apply(AstBuilder.scala:1747)

如果我做错了事,请告诉我。感谢帮助

0 个答案:

没有答案