Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark: fix rewrite_position_delete_files reports an error when the partition column contains "." #8111

Merged

Conversation

lintingbin
Copy link
Contributor

Solve the "AnalysisException: No such struct field" mentioned in #8109.

@github-actions github-actions bot added the spark label Jul 20, 2023
@lintingbin lintingbin changed the title fix: rewrite_position_delete_files reports an error when the partition column contains "." Spark: fix rewrite_position_delete_files reports an error when the partition column contains "." Jul 20, 2023
@szehon-ho
Copy link
Collaborator

Thanks very much for the pr and the fix, can you add a test ? I have some test in https://github.com/apache/iceberg/blob/master/spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRewritePositionDeleteFiles.java to catch the removeDanglingDelete scenarios , I think it would fit here well. Thanks in advance

…", change partition_col to `partition_col.type`.
@lintingbin
Copy link
Contributor Author

@szehon-ho In order to test the case where the partition column contains ".", I changed the partition_col in the https://github.com/apache/iceberg/blob/master/spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRewritePositionDeleteFiles.java to partition_col.type.

@@ -122,8 +123,8 @@ public void testDatePartition() throws Exception {
@Test
public void testBooleanPartition() throws Exception {
createTable("boolean");
insertData(i -> i % 2 == 0, 2);
testDanglingDelete(2);
insertData(PARTITION_COL, i -> i % 2 == 0, 2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, can also you make these methods have a default version that delegates with PARTITION_COL?:

  private void insertData(Function<Integer, ?> partitionValueFunction) throws Exception {
    insertData(partitionValueFunction, PARTITION_COL, NUM_DATA_FILES);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. testDanglingDelete also made the same optimization.

@szehon-ho szehon-ho merged commit a83e885 into apache:master Jul 26, 2023
31 checks passed
@szehon-ho
Copy link
Collaborator

Merged, thanks @lintingbin2009 !

@lintingbin lintingbin deleted the fix_rewrite_position_delete_files_error branch July 31, 2023 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants