c21 commented on code in PR #37264:
URL: https://github.com/apache/spark/pull/37264#discussion_r928226213


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala:
##########
@@ -172,39 +172,55 @@ object Project {
     expected.map { f =>
       val matched = fields.filter(field => conf.resolver(field._1, f.name))
       if (matched.isEmpty) {
-        if (columnPath.isEmpty) {
-          throw QueryCompilationErrors.unresolvedColumnError(f.name, 
fields.map(_._1))
+        if (f.nullable) {
+          val columnExpr = Literal.create(null, f.dataType)
+          // Fill nullable missing new column with null value.
+          createNewColumn(columnExpr, f.name, f.metadata, Metadata.empty)

Review Comment:
   Let me know if we want to a SQL config to control the default behavior or 
not. Thanks. I think it's ok to allow null value for missing columns by default.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to