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

Getting Original Schema of a DataFile in a FileScanTask? #401

Closed
srilman opened this issue Feb 9, 2024 · 4 comments
Closed

Getting Original Schema of a DataFile in a FileScanTask? #401

srilman opened this issue Feb 9, 2024 · 4 comments
Labels

Comments

@srilman
Copy link
Contributor

srilman commented Feb 9, 2024

Question

Is there a recommended way to getting the base / original schema or schema-id of a data file in a FileScanTask returned during FileTableScan.plan_files? This is useful to determine what kind of schema evolution occurred with the subset of files we are reading, and group files together with the same schemas for reads.

I had a hard time accomplishing this in the Java library, but found it much easier to do in Python. In plan_files, we can get the snapshot id a data file was created by looking at the snapshot_id of the associated manifest entry (or added_snapshot_id of the manifest list if the previous is null). From there, we can get the associated schema per snapshot.

Is this a logical approach, or is there a better way to get the original schema? Happy to open a PR to integrate this into FileTableScan if it would be useful!

@srilman
Copy link
Contributor Author

srilman commented Feb 14, 2024

@Fokko any thoughts?

@Fokko
Copy link
Contributor

Fokko commented Feb 14, 2024

Hey @srilman sorry for not replying earlier. It slipped somewhere through the cracks, thanks for pinging me!

Is there a recommended way to getting the base / original schema or schema-id of a data file in a FileScanTask returned during FileTableScan.plan_files? This is useful to determine what kind of schema evolution occurred with the subset of files we are reading, and group files together with the same schemas for reads.

Unfortunately, no :(

From there, we can get the associated schema per snapshot.

A snapshot can have files with multiple schemas. See the example in duckdb/duckdb-iceberg#40

Is this a logical approach, or is there a better way to get the original schema? Happy to open a PR to integrate this into FileTableScan if it would be useful!

The only source of truth is in the Parquet file. The crux is that you don't want to do lookups based on names, but only on field field-IDs. Names can change over time, but field-id won't. So if you filter on a specific field-id, that will always work correctly. The same goes when reading parquet files, it can be that the names change over time, and you don't want to rewrite petabytes of data, so you can leave them as is. When reading, you want to make the field-ids to the current schema.

Copy link

This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.

@github-actions github-actions bot added the stale label Aug 13, 2024
Copy link

This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants