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

    https://github.com/apache/spark/pull/15332#discussion_r81932694
  
    --- Diff: 
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedColumnReader.java
 ---
    @@ -362,7 +363,15 @@ private void readLongBatch(int rowId, int num, 
ColumnVector column) throws IOExc
         if (column.dataType() == DataTypes.LongType ||
             DecimalType.is64BitDecimalType(column.dataType())) {
           defColumn.readLongs(
    -          num, column, rowId, maxDefLevel, (VectorizedValuesReader) 
dataColumn);
    +              num, column, rowId, maxDefLevel, (VectorizedValuesReader) 
dataColumn);
    --- End diff --
    
    I've tested the following test case:
    
        test("SPARK-10634 timestamp written and read as INT64 - 
TIMESTAMP_MILLIS") {
          val data = (1 to 1000).map { i =>
            if (i < 500) {
              Row(new java.sql.Timestamp(10))
            } else {
              Row(new java.sql.Timestamp(i))
            }
          }
          val schema = StructType(List(StructField("time", TimestampType, 
false)).toArray)
          withSQLConf(ParquetOutputFormat.DICTIONARY_PAGE_SIZE -> "64",
              ParquetOutputFormat.PAGE_SIZE -> "128") {
            withSQLConf(SQLConf.PARQUET_INT64_AS_TIMESTAMP_MILLIS.key -> 
"true") {
              withTempPath { file =>
                val df = spark.createDataFrame(sparkContext.parallelize(data), 
schema)
                df.coalesce(1).write.parquet(file.getCanonicalPath)
                ("true" :: Nil).foreach { vectorized =>
                  withSQLConf(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> 
vectorized) {
                    val df2 = spark.read.parquet(file.getCanonicalPath)
                    checkAnswer(df2, df.collect().toSeq)
                  }
                }
              }
            }
          }
        }
    
    It will cause an exception:
    
        [info]  org.apache.spark.SparkException: Job aborted due to stage 
failure: Task 0 in stage 3.0 failed 1 times, most recent failure: Lost task 0.0 
in stage 3.0 (TID 4, localhost): java.lang.UnsupportedOperationException: 
Unimplemented type: TimestampType
        [info]  at 
org.apache.spark.sql.execution.datasources.parquet.VectorizedColumnReader.decodeDictionaryIds(VectorizedColumnReader.java:256)
        [info]  at 
org.apache.spark.sql.execution.datasources.parquet.VectorizedColumnReader.readBatch(VectorizedColumnReader.java:177)
        [info]  at 
org.apache.spark.sql.execution.datasources.parquet.VectorizedParquetRecordReader.nextBatch(VectorizedParquetRecordReader.java:230)
    
    
    



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to