KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745691647



##########
File path: 
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -319,48 +313,54 @@ public void deleteWhere(Filter[] filters) {
 
   @Override
   public StructType partitionSchema() {
-    List<Types.NestedField> fields = 
icebergTable.spec().partitionType().fields();
-    StructField[] structFields = new StructField[fields.size()];
-    int index = 0;
-    for (Types.NestedField field : fields) {
-      StructField structField = new StructField(field.name(), 
SparkSchemaUtil.convert(field.type()), true,
-          Metadata.empty());
-      structFields[index] = structField;
-      ++index;
+    if (lazyPartitionSchema == null) {
+      Table table = table();
+      PartitionsTable partitionsTable =
+          (PartitionsTable) 
MetadataTableUtils.createMetadataTableInstance(table, 
MetadataTableType.PARTITIONS);
+      Types.NestedField partition = 
partitionsTable.schema().findField("partition");
+      if (partition != null) {
+        this.lazyPartitionSchema = (StructType) 
SparkSchemaUtil.convert(partition.type());
+      } else {
+        lazyPartitionSchema = new StructType();
+      }
     }
-    return new StructType(structFields);
+
+    return lazyPartitionSchema;
   }
 
   @Override
   public void createPartition(InternalRow ident, Map<String, String> 
properties)
-      throws PartitionAlreadyExistsException, UnsupportedOperationException {
-    throw new UnsupportedOperationException("not support create partition, use 
addFile procedure to refresh");
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException("Cannot create partition: 
partitions exist only when there are rows");
   }
 
   @Override
   public boolean dropPartition(InternalRow ident) {
-    throw new UnsupportedOperationException("not support drop partition, use 
delete sql instead of it");
+    throw new UnsupportedOperationException("Cannot drop partition: not 
implemented");
   }
 
   @Override
   public void replacePartitionMetadata(InternalRow ident, Map<String, String> 
properties)
-      throws NoSuchPartitionException, UnsupportedOperationException {
-    throw new UnsupportedOperationException("not support replace partition 
metadata");
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException("Cannot replace partition 
metadata: partition metadata is only related to" +
+        " data files");
   }

Review comment:
       I think partition metadata is the data file col's statistics.




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