Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/21720#discussion_r200831755
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -515,13 +515,33 @@ class Analyzer(
s"Aggregate expression required for pivot, found '$e'")
}
}
+ // Check all pivot values are literal and match pivot column data
type.
+ val evalPivotValues = pivotValues.map { value =>
+ if (!Cast.canCast(value.dataType, pivotColumn.dataType)) {
+ throw new AnalysisException(s"Invalid pivot value '$value': " +
+ s"value data type ${value.dataType.simpleString} does not
match " +
+ s"pivot column data type
${pivotColumn.dataType.simpleString}")
+ }
+ try {
+ Cast(value, pivotColumn.dataType).eval(EmptyRow)
+ } catch {
+ case _: UnsupportedOperationException =>
--- End diff --
We should check if the value is foldable before the type is castable
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]