spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shubham Chaurasia <>
Subject DataSourceV2 producing wrong date value in Custom Data Writer
Date Tue, 05 Feb 2019 12:46:11 GMT
Hi All,

I am using custom DataSourceV2 implementation (*Spark version 2.3.2*)

Here is how I am trying to pass in *date type *from spark shell.

scala> val df =
> sc.parallelize(Seq("2019-02-05")).toDF("datetype").withColumn("datetype",
> col("datetype").cast("date"))
> scala> df.write.format("com.shubham.MyDataSource").save

Below is the minimal write() method of my DataWriter implementation.

public void write(InternalRow record) throws IOException {
  ByteArrayOutputStream format = streamingRecordFormatter.format(record);
  System.out.println("MyDataWriter.write: " + record.get(0,


It prints an integer as output:

MyDataWriter.write: 17039

Is this a bug?  or I am doing something wrong?


View raw message