maropu commented on a change in pull request #24179: [SPARK-27241][SQL] Support 
map_keys in SelectedField
URL: https://github.com/apache/spark/pull/24179#discussion_r268142767
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SelectedField.scala
 ##########
 @@ -97,6 +97,19 @@ object SelectedField {
         val MapType(keyType, _, valueContainsNull) = child.dataType
         val opt = dataTypeOpt.map(dt => MapType(keyType, dt, 
valueContainsNull))
         selectField(child, opt)
+      case MapKeys(child) =>
+        val MapType(_, valueType, valueContainsNull) = child.dataType
+        // MapKeys does not select a field from a struct (i.e. prune the 
struct) so it can't be
+        // the top-level extractor. However it can be part of an extractor 
chain.
+        val newKeyType = dataTypeOpt match {
+          case None => None
+          case Some(ArrayType(dataType, _)) => Some(dataType)
+          case Some(x) =>
+            // This should not happen.
+            throw new AnalysisException(s"DataType '$x' is not supported by 
MapKeys.")
 
 Review comment:
   Ah, I see. It seems we have no consistent rule for this...

----------------------------------------------------------------
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]

Reply via email to