beliefer commented on code in PR #42763:
URL: https://github.com/apache/spark/pull/42763#discussion_r1351135259


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TableOutputResolver.scala:
##########
@@ -455,6 +457,19 @@ object TableOutputResolver {
     }
   }
 
+  def suitableForByNameCheck(
+      byName: Boolean,
+      expected: Seq[Attribute],
+      queryOutput: Seq[Attribute]): Unit = {
+    if (!byName && expected.size == queryOutput.size &&
+      expected.forall(e => queryOutput.exists(p => conf.resolver(p.name, 
e.name))) &&
+      expected.zip(queryOutput).exists(e => !conf.resolver(e._1.name, 
e._2.name))) {
+      logWarning("The query columns and the table columns have same names but 
different " +
+        "orders. You can use INSERT [INTO | OVERWRITE] BY NAME to reorder the 
query columns to " +
+        "align with the table columns.")

Review Comment:
   Users always insert table columns doesn't match the query columns. For 
example, table `student(name: STRING, address: STRING)` and table 
`location(code: STRING, name: STRING)`. The `student.address` references 
`location.name`.
   I am neutral on this warning message.



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