You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/11/03 15:24:38 UTC
[GitHub] [iceberg] KnightChess opened a new pull request #3459: Spark: add show partition sql to spark-3.2 moudle
KnightChess opened a new pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459
support show partitions in spark-3.2 with iceberg table
#3406
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r749870042
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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());
Review comment:
I think you are ok here since you are getting the type from the partitions metadata table. I would just make sure we have a test for it.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r746218179
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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());
Review comment:
Oh, I got it, when a partition field remove, it only mark spec transform void, so it may be return incorrectly. I am not sure if I understand is correct
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-960363663
> Hi, thanks for this, but first of all I'm just wondering first of all, whether its possible to re-use the partitions metadata table? Then we can get some benefits like predicate pushdown and future work to make it parallel, instead of re-implementing in two places? @RussellSpitzer any thoughts ? Thanks
@szehon-ho thanks for advice, I'll view the relevant code and do some modifications
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-959826574
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744334696
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
+ Table table = this.table();
+
+ // get possition by partition name
Review comment:
Typo in "position"
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r750369455
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
> You should be displaying them like the metadata partitions table would, which is to produce a "global spec" and then return values in that.
for "global spec", I think it will contain all history partitiions with table.spec()
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] jackye1995 commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
jackye1995 commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-960373555
+1 for reusing the metadata table, it will also help #3269 as we are changing the definition from table to table + snapshotId.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744335207
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
+ Table table = this.table();
+
+ // get possition by partition name
+ StructType partitionSchema = this.partitionSchema();
+ StructField[] partitionFileds = partitionSchema.fields();
+ Map<String, Integer> fieldToPosition = new HashMap<>(8);
Review comment:
Maps should be created using `Maps.newHashMap` and similar factory methods from Guava. Also, I don't think it is a good idea to use a constant, 8. If you want to initialize the size of the map, then I recommend calculating the target size using something like `partitionSchema().size()`.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744334492
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
Review comment:
Iceberg has a style for error messages. Use sentence case, be direct, add context, and try to make it useful. In this case, I think a good error message is "Cannot create partition: partitions exist only when there are rows"
That is direct because it states what the user was attempting, but failed to do: "Cannot create partition". We use `:` before giving the relevant context or reason, "partitions exist only when there are rows". Iceberg does not track partition existence independent of data. Partitions exist if and only if there are rows stored in the partition.
Could you similarly update the others? Some we could implement later, so you can use "not implemented" as the context. For `dropPartition`, I would use "Cannot drop partition: not implemented".
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745811355
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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 {
+ this.lazyPartitionSchema = new StructType();
+ }
+ }
+
+ return lazyPartitionSchema;
+ }
+
+ @Override
+ public void createPartition(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot create partition: partitions exist only when there are rows");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("Cannot drop partition: not implemented");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot replace partition metadata: partition metadata is only related to" +
Review comment:
Here I would just say "Iceberg partitions do not support metadata"
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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 {
+ this.lazyPartitionSchema = new StructType();
+ }
+ }
+
+ return lazyPartitionSchema;
+ }
+
+ @Override
+ public void createPartition(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot create partition: partitions exist only when there are rows");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("Cannot drop partition: not implemented");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot replace partition metadata: partition metadata is only related to" +
+ " data files");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot load partition metadata: not implemented");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
+ StructType partitionSchema = partitionSchema();
+ if (partitionSchema.isEmpty()) {
Review comment:
V1 Void Transforms strike again here, Let's make sure we are correctly returning "empty" from partitionSchema when we get those void's.
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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 {
+ this.lazyPartitionSchema = new StructType();
+ }
+ }
+
+ return lazyPartitionSchema;
+ }
+
+ @Override
+ public void createPartition(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot create partition: partitions exist only when there are rows");
Review comment:
I find this a little confusing. Perhaps "partitions are created implicitly when inserting new rows into iceberg tables"?
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
let's add in a few tests for showing partitions of a table which has had it's partitioning altered.
Specifically we should hit
1. A table which was partitioned but is now no longer partitioned (voidTransforms)
2. Adding a partition column
3. Changing a partition column type with a compatible transform, going from hours -> days
Any thing else you can think of here
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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 {
+ this.lazyPartitionSchema = new StructType();
+ }
+ }
+
+ return lazyPartitionSchema;
+ }
+
+ @Override
+ public void createPartition(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot create partition: partitions exist only when there are rows");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("Cannot drop partition: not implemented");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot replace partition metadata: partition metadata is only related to" +
+ " data files");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot load partition metadata: not implemented");
Review comment:
Same as above
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744334604
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
Review comment:
Can you remove any `throws` exceptions that are not actually thrown or that are not checked exceptions?
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-971084426
@RussellSpitzer yes, I konw, `listPartitionIdentifiers` can return all partitions of the "maximal" spec.
1. But in `ShowPartitionsExe`, spark use `partitionSchema` method to get dataType in following code.
So that's mean I need return "maximal" spec when use `partitionSchema` although the table was partitioned before but unpartitioned now.
```scala
val partitionIdentifiers = table.listPartitionIdentifiers(names.toArray, ident)
// Converting partition identifiers as `InternalRow` of partition values,
// for instance InternalRow(value0, value1, ..., valueN), to `InternalRow`s
// with a string in the format: "col0=value0/col1=value1/.../colN=valueN".
val schema = table.partitionSchema()
val len = schema.length
val partitions = new Array[String](len)
val timeZoneId = conf.sessionLocalTimeZone
val output = partitionIdentifiers.map { row =>
var i = 0
while (i < len) {
val dataType = schema(i).dataType
val partValueUTF8String =
Cast(Literal(row.get(i, dataType), dataType), StringType, Some(timeZoneId)).eval()
val partValueStr = if (partValueUTF8String == null) "null" else partValueUTF8String.toString
partitions(i) = escapePathName(schema(i).name) + "=" + escapePathName(partValueStr)
i += 1
}
partitions.mkString("/")
}
output.sorted.map(p => InternalRow(UTF8String.fromString(p)))
```
2. But if `partitionSchema` method return "maximal" spec. Some scenes may lead to errors. like: `CheckAnalysis.checkAnalysis` in following code, although the table is unpartitioned, but will pass the check if the table was partitioned before.
```scala
case command: V2PartitionCommand =>
command.table match {
case r @ ResolvedTable(_, _, table, _) => table match {
case t: SupportsPartitionManagement =>
if (t.partitionSchema.isEmpty) {
failAnalysis(s"Table ${r.name} is not partitioned.")
}
case _ =>
failAnalysis(s"Table ${r.name} does not support partition management.")
}
case _ =>
}
```
3. And My fault, I didn't notice the following description before.
> `partitionSchema` must be consistent with `Table.partitioning`
The `Table.partitioning` will only return the physical partitioning of the table (voiedTransform will be remove).
```scala
/**
* Get the partition schema of table,
* this must be consistent with ${@link Table#partitioning()}.
* @return the partition schema of table
*/
StructType partitionSchema();
```
I have a little confusion. So that's mean it can't achieve the same effect by use `show partitions` and `select * form xxxx.partitions` when follow the rules in points 2 and 3?
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745819059
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
Review comment:
I think it is still a good idea to be defensive here. It's very low cost.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r755101455
##########
File path: spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestPartitionSQL.java
##########
@@ -147,4 +152,113 @@ public void testUnSupportPartitionsOps() {
() -> sql("ALTER TABLE %s drop partition (age = 10, dt = '20210101')", tableName));
}
+
+ @Test
+ public void testShowPartitonWithDateEvolution() {
+
+ sql("CREATE TABLE %s (id bigint, age bigint, ts timestamp) USING iceberg PARTITIONED BY (days(ts))",
+ tableName);
+
+ assertEquals("result should have expected rows",
Review comment:
add partition evolution test. When #3598 fix, I can supplement year and months.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] jackye1995 edited a comment on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
jackye1995 edited a comment on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-960373555
+1 for reusing the metadata table, it will also help #3269 as we are changing the definition of `SparkTable` from table to table + snapshotId.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744334568
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
Review comment:
One more thing: no need to suggest using `addFile`. The person that gets this error will not be familiar with the Iceberg or Spark internal APIs, so it isn't very useful to add.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745563037
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
Review comment:
spark will check whether the table is partitioned when use show partitions in CheckAnalysis, so I am not sure it's necessary to check here
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745807634
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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());
Review comment:
Just checking do we handle void transforms here correctly?
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744334810
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
+ Table table = this.table();
Review comment:
No need to prefix method or instance field references with `this.`
We only use the prefix when setting an instance field, so that it is obvious that the instance state is being modified.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r746224078
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
According to the suggestions, I thought of a question.
What do users want when use show partitions,
1. if the table is unpartitioned now but partitioned before. Is there need to return he historical partition info
2. the partition has been updated, is there need to return the historical partition info
Considering the way updated, the result is different:
> now have a table, partitioned by (year, month), has `/year=2021/month=01/xxxx.parquet` data file
- add partitions day, then add data, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- drop partitions year, then add data, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- /year=null/month=01/day=02/xxxx.parqut
- /year=null/month=01/day=03/xxxx.parqut
- then drop partitions month, day, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- /year=null/month=01/day=02/xxxx.parqut
- /year=null/month=01/day=03/xxxx.parqut
- /year=null/month=null/day=null/xxxx.parqut
now the table is unpartitioned, when use show partitions, need throw `the table is unpartitioned` or return the partitions the table has( and is there need to remove xxx=null fields)
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
According to the suggestions, I thought of a question.
What do users want when use show partitions,
1. if the table is unpartitioned now but partitioned before. Is there need to return the historical partition info
2. the partition has been updated, is there need to return the historical partition info
Considering the way updated, the result is different:
> now have a table, partitioned by (year, month), has `/year=2021/month=01/xxxx.parquet` data file
- add partitions day, then add data, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- drop partitions year, then add data, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- /year=null/month=01/day=02/xxxx.parqut
- /year=null/month=01/day=03/xxxx.parqut
- then drop partitions month, day, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- /year=null/month=01/day=02/xxxx.parqut
- /year=null/month=01/day=03/xxxx.parqut
- /year=null/month=null/day=null/xxxx.parqut
now the table is unpartitioned, when use show partitions, need throw `the table is unpartitioned` or return the partitions the table has( and is there need to remove xxx=null fields)
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-972125255
Since you are using
``` (PartitionsTable) MetadataTableUtils.createMetadataTableInstance(table, MetadataTableType.PARTITIONS);
```
Right now for determining the partition spec I believe you are already using the maximal spec.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-970426229
@knightchess here is an example of what happens with the partitions metadata table
```
scala> spark.sql("CREATE TABLE example (a int, b int, c int, d int) using Iceberg location 'file:///Users/russellspitzer/Temp/example'")
scala> spark.sql("ALTER TABLE example ADD PARTITION FIELD identity(a)")
scala> spark.sql("INSERT INTO example VALUES (1,1,1,1)")
// Partition (a = 1)
scala> spark.sql("ALTER TABLE example ADD PARTITION FIELD identity(b)")
scala> spark.sql("INSERT INTO example VALUES (2,2,2,2)")
// Partition (a = 2, b =2)
scala> spark.sql("ALTER TABLE example ADD PARTITION FIELD identity(c)")
scala> spark.sql("INSERT INTO example VALUES (3,3,3,3)")
// Partition (a = 3, b = 3, c = 3)
scala> spark.sql("ALTER TABLE example DROP PARTITION FIELD identity(c)")
scala> spark.sql("INSERT INTO example VALUES (4,4,4,4)")
// Partition (a = 4, b = 4, null(c) = null)
scala> spark.sql("ALTER TABLE example DROP PARTITION FIELD identity(b)")
scala> spark.sql("INSERT INTO example VALUES (5,5,5,5)")
// Partition (a= 5, null(b) = null, null(c) = null)
scala> spark.sql("ALTER TABLE example DROP PARTITION FIELD identity(a)")
scala> spark.sql("INSERT INTO example VALUES (6,6,6,6)")
// Partition (null(a) = null, null(b) = null, null(c) = null
```
This creates a metadata table
```
scala> spark.sql("SELECT * from default.example.partitions SORT BY partition").show
+------------------+------------+----------+
| partition|record_count|file_count|
+------------------+------------+----------+
|{null, null, null}| 1| 1|
| {1, null, null}| 1| 1|
| {2, 2, null}| 1| 1|
| {3, 3, 3}| 1| 1|
| {4, 4, null}| 1| 1|
| {5, null, null}| 1| 1|
+------------------+------------+----------+
```
This metadata table has a partition spec which covers the entire range of possible specs the table has had even though the underlying table is currently unpartitioned. Now even though some partitions where written in a different spec (in this case every partition was written with a different spec) you see them all in the context of the "maximal" spec which covers all fields.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r755099231
##########
File path: core/src/main/java/org/apache/iceberg/PartitionData.java
##########
@@ -96,6 +96,7 @@ public Schema getSchema() {
return schema;
}
+ @Override
public Type getType(int pos) {
return partitionType.fields().get(pos).type();
}
Review comment:
I want to get PartitionData field type, I don't know how to get it in other way.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r750369455
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
> You should be displaying them like the metadata partitions table would, which is to produce a "global spec" and then return values in that.
for "global spec", I think it will contain all history partitiions with table.spec()
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r750407570
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
> You should be displaying them like the metadata partitions table would, which is to produce a "global spec" and then return values in that.
I will work for it.
so I think:
- if a table is partitioned, will show all partitions contain the other historical version of partition
- if a table was partitioned before, but now it unpartitioned. will throw error although it had partitions before
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
> You should be displaying them like the metadata partitions table would, which is to produce a "global spec" and then return values in that.
I will work for it.
so I think:
- if a table is partitioned, will show all partitions contain the other historical version of partition
- if a table was partitioned before, but now it unpartitioned. will throw error although it had partitions before
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-962701637
I think there's also a larger question here: do we want to support some of the other methods, like `dropPartition`? It's easy enough to turn that into a delete filter. The problem is that we don't encourage people to interact with tables through partitions because partitioning can change.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744334661
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
Review comment:
It may be worth a discussion about what we may return for this if we choose to implement it.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-959826574
I agree with @szehon-ho , we should use the metadata table here, especially because it already has the code for dealing with multiple partition specs in it which is currently missing from this PR. I can do a more through review later
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745563037
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
Review comment:
spark will check whether the table is partitioned when use show partitions in CheckAnalysis, so I am not sure it's necessary to check here
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r746218392
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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 {
+ this.lazyPartitionSchema = new StructType();
+ }
+ }
+
+ return lazyPartitionSchema;
+ }
+
+ @Override
+ public void createPartition(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot create partition: partitions exist only when there are rows");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("Cannot drop partition: not implemented");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot replace partition metadata: partition metadata is only related to" +
+ " data files");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot load partition metadata: not implemented");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
+ StructType partitionSchema = partitionSchema();
+ if (partitionSchema.isEmpty()) {
Review comment:
> V1 Void Transforms strike again here, Let's make sure we are correctly returning "empty" from partitionSchema when we get those void's.
I will test it
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r750339012
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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());
Review comment:
> I think you are ok here since you are getting the type from the partitions metadata table. I would just make sure we have a test for it.
ok, and I have a question. for the `partitionSchema` method.
```java
public StructType partitionSchema()
```
If I have a table, partitioned by dt, ht. then I drop ht. So I think the method should only return partition dt. Is it right?
And in https://github.com/apache/iceberg/pull/3459#discussion_r749869700, the data from metadata partitions table will contain ht. So I think `listPartitionIdentifiers` doesn't conflict with `partitionSchema`?
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744335163
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ List<Types.NestedField> fields = icebergTable.spec().partitionType().fields();
Review comment:
This should use the partition metadata table's Iceberg schema and convert it to Spark using `SparkSchemaUtil.convert`. Also, it would be great to reuse the value using a lazily initialized instance variable.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-959826574
I agree with @szehon-ho , we should use the metadata table here, especially because it already has the code for dealing with multiple partition specs in it which is currently missing from this PR. I can do a more through review later
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745807634
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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());
Review comment:
Just checking do we handle void transforms here correctly? V1 Tables which have had a partition field removed leave this as a field in their spec and I just want to make sure we don't expose these in a confusing way since it's just an internal detail.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r745687157
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
Review comment:
spark will use partitionSchema to check the table is partitiioned, so I am not sure is it necessary to check here
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r746224078
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
According to the suggestions, I thought of a question.
What do users want when use show partitions,
1. if the table is unpartitioned now but partitioned before. Is there need to return to the historical partition info
2. the partition has been updated, is there need to return the historical partition info
Considering the way updated, the result is different:
> now have a table, partitioned by (year, month), has `/year=2021/month=01/xxxx.parquet` data file
- add partitions day, then add data, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- drop partitions year, then add data, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- /year=null/month=01/day=02/xxxx.parqut
- /year=null/month=01/day=03/xxxx.parqut
- then drop partitions month, day, data path:
- /year=2021/month=01/xxxx.parqut
- /year=2021/month=01/day=01/xxxx.parqut
- /year=null/month=01/day=02/xxxx.parqut
- /year=null/month=01/day=03/xxxx.parqut
- /year=null/month=null/day=null/xxxx.parqut
now the table is unpartitioned, when use show partitions, need throw `the table is unpartitioned` or return the partitions the table has( and is there need to remove xxx=null fields)
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r746225033
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
this will affect the specific implementation to partitionSchema and listPartitionIdentifiers
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r746201352
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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());
Review comment:
> V1 Tables which have had a partition field removed leave this as a field in their spec
that is mean this is not suitable for use Types.NestedField. I am not sure if Igot it. Is there a related detailed doc?
I don't know if there are other ways to get partitions when use partition metadata table. I can use sparkTable.spec to instead it.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-979833271
When solve #3609 , I think maybe ShowPartitionExec need use "maximal" spec like https://github.com/apache/iceberg/pull/3609#discussion_r757336415 to format partitionData instead of use `partitionSchema()`when using iceberg table
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r755105296
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -315,23 +320,38 @@ public void deleteWhere(Filter[] filters) {
public StructType partitionSchema() {
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());
+ PartitionSpec spec = table.spec();
+ if (spec != null) {
+ // type always String when transform is void
+ List<PartitionField> fields = spec.fields();
+ Types.StructType structType = spec.partitionType();
+ List<Types.NestedField> fieldsType = structType.fields();
+ StructField[] structFields = new StructField[fields.size()];
+
+ for (int i = 0; i < fields.size(); ++i) {
+ PartitionField partitionField = fields.get(i);
+ Types.NestedField nestedField = fieldsType.get(i);
+ if ("void".equals(partitionField.transform().toString())) {
+ structFields[i] = StructField.apply(nestedField.name(), DataTypes.StringType, nestedField.isOptional(),
+ Metadata.empty());
+ } else {
+ structFields[i] = StructField.apply(nestedField.name(), SparkSchemaUtil.convert(nestedField.type()),
+ nestedField.isOptional(), Metadata.empty());
+ }
Review comment:
for compatible history, the field type always String when transform is void.( It seems to only timestamp that's going to be a problem when evolution
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#issuecomment-972801775
> Since you are using
>
> Right now for determining the partition spec I believe you are already using the maximal spec.
Yes, I am using the maximal spec now. And a table is unpartitioned but has history partitions will also return partition result. This may mislead user: a unpartitioned table can show partitons.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] KnightChess commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
KnightChess commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r746201352
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +311,103 @@ public void deleteWhere(Filter[] filters) {
}
}
+ @Override
+ public StructType partitionSchema() {
+ 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());
Review comment:
> V1 Tables which have had a partition field removed leave this as a field in their spec
that is mean this is not suitable for use Types.NestedField. I am not sure if Igot it. Is there a related detailed doc?
I don't know if there are other ways to get partitions when use partition metadata table. I can use sparkTable.spec to instead it.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] rdblue commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r744335351
##########
File path: spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -298,6 +317,97 @@ 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;
+ }
+ return new StructType(structFields);
+ }
+
+ @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");
+ }
+
+ @Override
+ public boolean dropPartition(InternalRow ident) {
+ throw new UnsupportedOperationException("not support drop partition, use delete sql instead of it");
+ }
+
+ @Override
+ public void replacePartitionMetadata(InternalRow ident, Map<String, String> properties)
+ throws NoSuchPartitionException, UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support replace partition metadata");
+ }
+
+ @Override
+ public Map<String, String> loadPartitionMetadata(InternalRow ident) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("not support load partition metadata");
+ }
+
+ @Override
+ public InternalRow[] listPartitionIdentifiers(String[] names, InternalRow ident) {
Review comment:
I think this and the other methods should check whether the table is partitioned.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
[GitHub] [iceberg] RussellSpitzer commented on a change in pull request #3459: Spark: add show partition sql to spark-3.2 moudle
Posted by GitBox <gi...@apache.org>.
RussellSpitzer commented on a change in pull request #3459:
URL: https://github.com/apache/iceberg/pull/3459#discussion_r749869700
##########
File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionSQL.java
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.spark.sql;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestPartitionSQL extends SparkCatalogTestBase {
+
+ public TestPartitionSQL(String catalogName, String implementation, Map<String, String> config) {
+ super(catalogName, implementation, config);
+ }
+
+ @After
+ public void removeTables() {
+ sql("DROP TABLE IF EXISTS %s", tableName);
+ }
+
Review comment:
You should be displaying them like the metadata partitions table would, which is to produce a "global spec" and then return values in that.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org