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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark: Schema evolution is not reflected on branches #10274

Open
javrasya opened this issue May 6, 2024 · 1 comment
Open

Spark: Schema evolution is not reflected on branches #10274

javrasya opened this issue May 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@javrasya
Copy link
Contributor

javrasya commented May 6, 2024

Apache Iceberg version

1.4.3

Query engine

Spark

Please describe the bug 馃悶

We have added to columns in a nested struct field by using Iceberg Java API. I can query and see the new columns when no version is passed down to the query;

select * 
from spark_catalog.my_db.my_table 
where myStructField.newlyAddedField='123' ;

The query above works. But not the one below

ALTER TABLE spark_catalog.my_db.my_table CREATE BRANCH `my_test_branch`;

select * 
from spark_catalog.my_db.my_table.branch_my_test_branch
where myStructField.newlyAddedField='123' ;

I get Error: org.apache.spark.sql.AnalysisException: No such struct field newlyAddedField

@javrasya javrasya added the bug Something isn't working label May 6, 2024
@javrasya
Copy link
Contributor Author

javrasya commented May 6, 2024

An interesting finding, once there is any update on the main branch after the schema is evolved, this no longer becomes a problem.

I ran the following to trigger a dummy update to test it and the problem went away;

MERGE INTO spark_catalog.spark_catalog.my_db.my_table AS target
USING (SELECT * FROM spark_catalog.my_db.my_table LIMIT 1) AS source
ON target.id = source.id
WHEN MATCHED THEN
    UPDATE SET *;

ALTER TABLE spark_catalog.my_db.my_table CREATE BRANCH `my_test_branch`;

SELECT * 
FROM spark_catalog.my_db.my_table.branch_my_test_branch
WHERE myStructField.newlyAddedField='123' ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant