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), ("1019-01-03", 7)).toDF("date", "id")
   df2: org.apache.spark.sql.DataFrame = [date: string, id: int]
   
   scala> df2.show
   +----------+---+
   |      date| id|
   +----------+---+
   |0119-01-03|  6|
   |1019-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)|
   +----------+---+-------+
   |1019-01-03|  7|      3|
   +----------+---+-------+
   ```
   ```scala
   joined.write.partitionBy("date").csv("date2")
   ```
   ```shell
   $ tree date2
   .
   ├── _SUCCESS
   └── date=1019-01-03
       ├── _SUCCESS
       ├── _committed_2042414757166556120
       ├── _started_2042414757166556120
       └── 
part-00001-tid-2042414757166556120-5729e821-9cf3-41f1-94af-c909bd0f9972-1621.c000.csv
   
   1 directory, 5 files
   ```
   The same result 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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to