Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15332#discussion_r81890950
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
 ---
    @@ -164,6 +165,63 @@ class ParquetQuerySuite extends QueryTest with 
ParquetTest with SharedSQLContext
         }
       }
     
    +  test("SPARK-10634 timestamp written and read as INT64 - 
TIMESTAMP_MILLIS") {
    +    val data = (1 to 10).map(i => Row(i, new java.sql.Timestamp(i)))
    +    val schema = StructType(List(StructField("d", IntegerType, false),
    +      StructField("time", TimestampType, false)).toArray)
    +    withSQLConf(SQLConf.PARQUET_INT64_AS_TIMESTAMP_MILLIS.key -> "true") {
    +      withTempPath { file =>
    +        val df = spark.createDataFrame(sparkContext.parallelize(data), 
schema)
    +        df.write.parquet(file.getCanonicalPath)
    +        ("true" :: "false" :: Nil).foreach { vectorized =>
    +          withSQLConf(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> 
vectorized) {
    +            val df2 = spark.read.parquet(file.getCanonicalPath)
    +            checkAnswer(df2, df.collect().toSeq)
    +          }
    +        }
    +      }
    +    }
    +  }
    +
    +  test("SPARK-10634 timestamp written and read as INT64 - truncation") {
    +    withTable("ts") {
    +      sql("create table ts (c1 int, c2 timestamp) using parquet")
    +      sql("insert into ts values (1, '2016-01-01 10:11:12.123456')")
    +      sql("insert into ts values (2, null)")
    +      sql("insert into ts values (3, '1965-01-01 10:11:12.123456')")
    +      checkAnswer(
    +        sql("select * from ts"),
    +        Seq(
    +          Row(1, Timestamp.valueOf("2016-01-01 10:11:12.123456")),
    +          Row(2, null),
    +          Row(3, Timestamp.valueOf("1965-01-01 10:11:12.123456"))))
    +    }
    +
    +    // When written as TIMESTAMP_MILLIS, the microseconds are truncated.
    +    withTable("ts") {
    +      withSQLConf(SQLConf.PARQUET_INT64_AS_TIMESTAMP_MILLIS.key -> "true") 
{
    --- End diff --
    
    Can you add a test that can we read a timestamp field written with 
`SQLConf.PARQUET_INT64_AS_TIMESTAMP_MILLIS` as `true`, but reading it with 
`SQLConf.PARQUET_INT64_AS_TIMESTAMP_MILLIS` as `false`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to