cloud-fan commented on a change in pull request #23202: [SPARK-26248][SQL]
Infer date type from CSV
URL: https://github.com/apache/spark/pull/23202#discussion_r242017110
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/CSVInferSchema.scala
##########
@@ -104,6 +108,7 @@ class CSVInferSchema(val options: CSVOptions) extends
Serializable {
compatibleType(typeSoFar,
tryParseDecimal(field)).getOrElse(StringType)
case DoubleType => tryParseDouble(field)
case TimestampType => tryParseTimestamp(field)
+ case DateType => tryParseDate(field)
Review comment:
ah i see your point. So the order here is not only for how we infer the type
for a single token, but also how we merge types.
This is super weird, as the order has different meaning according to the
context:
1. for single token, the case appears first has higher priority. Here
timestamp is prefered over date
2. for type merge, the case appears last has higher priority. Once a type is
inferred as date, we can't go back to timestamp anymore.
If the specified format of data and timestamp is not compatible, timestamp
and date type should be incompatible and we should fallback to string.
----------------------------------------------------------------
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]