RussellSpitzer commented on code in PR #4902:
URL: https://github.com/apache/iceberg/pull/4902#discussion_r916343815


##########
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/actions/SparkZOrderStrategy.java:
##########
@@ -133,9 +133,23 @@ public SparkZOrderStrategy(Table table, SparkSession 
spark, List<String> zOrderC
           "Cannot perform ZOrdering, all columns provided were identity 
partition columns and cannot be used.");
     }
 
+    validateColumnsExistence(table, spark, zOrderColNames);
+
     this.zOrderColNames = zOrderColNames;
   }
 
+  private void validateColumnsExistence(Table table, SparkSession spark, 
List<String> colNames) {
+    boolean caseSensitive = 
Boolean.parseBoolean(spark.conf().get("spark.sql.caseSensitive"));
+    Schema schema = table.schema();
+    colNames.forEach(col -> {
+      NestedField nestedField = caseSensitive ? schema.findField(col) : 
schema.caseInsensitiveFindField(col);
+      if (nestedField == null) {
+        throw new IllegalArgumentException(
+            String.format("Cannot find field '%s' in struct: %s", col, 
schema.asStruct()));

Review Comment:
   I still think "struct" is ambiguous even if we don't want to add the other 
parts I suggested. I would probably just say "in table schema"



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