cloud-fan commented on a change in pull request #27499: [SPARK-30590][SQL]
Untyped select API cannot take typed column expression
URL: https://github.com/apache/spark/pull/27499#discussion_r383136365
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
##########
@@ -1430,7 +1430,23 @@ class Dataset[T] private[sql](
*/
@scala.annotation.varargs
def select(cols: Column*): DataFrame = withPlan {
- Project(cols.map(_.named), logicalPlan)
+ val untypedCols = cols.map {
+ case typedCol: TypedColumn[_, _] =>
+ val isSimpleEncoder = typedCol.encoder.namedExpressions.head match {
+ case Alias(_: BoundReference, _) if
!typedCol.encoder.isSerializedAsStruct => true
+ case _ => false
+ }
+ if (isSimpleEncoder) {
+ // This typed column produces simple type output that can be fit
into untyped `DataFrame`.
+ typedCol.withInputType(exprEnc, logicalPlan.output)
Review comment:
So here we are supporting more cases than before?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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]