MaxGekk commented on a change in pull request #23391: [SPARK-26456][SQL] Cast 
date/timestamp to string by Date/TimestampFormatter
URL: https://github.com/apache/spark/pull/23391#discussion_r244957053
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningUtils.scala
 ##########
 @@ -230,7 +235,7 @@ object PartitioningUtils {
         // Once we get the string, we try to parse it and find the partition 
column and value.
         val maybeColumn =
           parsePartitionColumn(currentPath.getName, typeInference, 
userSpecifiedDataTypes,
-            validatePartitionColumns, timeZone)
+            validatePartitionColumns, timeZone, dateFormatter, 
timestampFormatter)
 
 Review comment:
   I would guess the result would be the same till only textual representation 
of dates is involved into a query. Let's say if you read dates from a 
datasource:
   ```
   date,id
   2019-01-03,1
   1019-01-03,2
   1019-01-03,3
   0019-01-03,4
   ```
   ```scala
   scala> val df1 = spark
     .read.option("header", true).option("inferSchema", true).csv("dates")
     .where('date < "1582-10-01")
     .groupBy('date)
     .agg(max('id))
   df1: org.apache.spark.sql.DataFrame = [date: string, max(id): int]
   
   scala> df1.show
   +----------+-------+
   |      date|max(id)|
   +----------+-------+
   |0019-01-03|      4|
   |1019-01-03|      3|
   +----------+-------+
   ```
   ```scala
   scala> val df2 = Seq(("0119-01-03", 6), ("0019-01-03", 7)).toDF("date", 
"id"); df2.show
   +----------+---+
   |      date| id|
   +----------+---+
   |0119-01-03|  6|
   |0019-01-03|  7|
   +----------+---+
   ```
   ```scala
   scala> val joined = df1.join(df2, df1("date") === 
df2("date")).select(df1("date"), 'id, $"max(id)"); joined.show
   +----------+---+-------+
   |      date| id|max(id)|
   +----------+---+-------+
   |0019-01-03|  7|      4|
   +----------+---+-------+
   ```
   ```scala
   joined.write.partitionBy("date").csv("date4")
   ```
   ```shell
   ➜  date4 tree
   .
   ├── _SUCCESS
   └── date=0019-01-03
       └── part-00001-8c7875f8-5157-4942-a240-2ef6a8cf291f.c000.csv
   
   1 directory, 2 files
   ```
   The same results are on Spark 2.4 and this branch.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to