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: Allow importing empty tables #7980

Merged
merged 1 commit into from
Jul 12, 2023
Merged

Conversation

lirui-apache
Copy link
Contributor

To address #7929.

When a partitioned table is empty, create an empty append commit instead of throwing an exception.

@github-actions github-actions bot added the spark label Jul 4, 2023
importSparkPartitions(
spark, sourceTablePartitions, targetTable, spec, stagingDir, checkDuplicateFiles);
if (sourceTablePartitions.isEmpty()) {
targetTable.newAppend().commit();
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason of empty commit, instead of say, returning ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what we do for un-partitioned table. And we expect the migration produces a snapshot so that we know the number of migrated files: https://github.com/apache/iceberg/blob/master/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/actions/MigrateTableSparkAction.java#L159

@szehon-ho
Copy link
Collaborator

Makes sense, Ill wait to see if any comments, will commit if not.

@lirui-apache
Copy link
Contributor Author

@szehon-ho Thanks for reviewing. Do I need to port the change to other spark versions?

@szehon-ho szehon-ho merged commit 7a44ee2 into apache:master Jul 12, 2023
31 checks passed
@szehon-ho
Copy link
Collaborator

Merged, thanks @lirui-apache , yea I think that would be great , maybe at least 3.3? I think It's voluntary and depends who needs what in each branch.

@lirui-apache lirui-apache deleted the 7929 branch July 13, 2023 06:18
@puchengy
Copy link
Contributor

Would love to see this ported to 3.2 as well, thanks! Otherwise I can do it.

@lirui-apache
Copy link
Contributor Author

Sure I'll open a PR for other spark versions.

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.

3 participants