Skip to content

feat: [iceberg] support iceberg metadata columns _file, _partition#4752

Draft
parthchandra wants to merge 4 commits into
apache:mainfrom
parthchandra:iceberg-metadata-columns
Draft

feat: [iceberg] support iceberg metadata columns _file, _partition#4752
parthchandra wants to merge 4 commits into
apache:mainfrom
parthchandra:iceberg-metadata-columns

Conversation

@parthchandra

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Adds support for iceberg metadata columns

Closes #.

Rationale for this change

What changes are included in this PR?

How are these changes tested?

@parthchandra parthchandra force-pushed the iceberg-metadata-columns branch 2 times, most recently from d23bf63 to ec21656 Compare June 29, 2026 20:56
@parthchandra parthchandra changed the title feat: support iceberg metadata columns _file, _partition feat: [iceberg] support iceberg metadata columns _file, _partition Jun 29, 2026
@parthchandra parthchandra force-pushed the iceberg-metadata-columns branch 2 times, most recently from 50fb6b3 to 0e34cf1 Compare July 6, 2026 18:23
@parthchandra parthchandra force-pushed the iceberg-metadata-columns branch from cf7b59f to 82d7c43 Compare July 9, 2026 16:54
// Data under spec 0
spark.sql(s"INSERT INTO $table VALUES (1, 'US', 'A'), (2, 'EU', 'B')")

// Evolve partition spec: add category field -> spec 1

@hsiang-c hsiang-c Jul 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(nit) We might be able to use SparkSQL as well but it is not a must.

ALTER TABLE $table ADD PARTITION FIELD category; 

ref: https://iceberg.apache.org/docs/nightly/spark-ddl/#alter-table-add-partition-field

withFallbackReason(scan, "Comet Scan is not enabled")

case scan if metadataCols(scan).nonEmpty =>
case scan: FileSourceScanExec if metadataCols(scan).nonEmpty =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can move it under the data source V1 branch?


// _pos should be 0-indexed per file
val result = spark.sql(s"SELECT id, _pos FROM $table ORDER BY id").collect()
assert(result(0).getLong(1) == 0L)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be all zero according to my local test.

val positions = result.map(_.getLong(0))
// First file has 0,1,2; second file has 0,1 (or vice versa)
assert(positions.contains(0L))
assert(positions.count(_ == 0L) == 2, "Each file should start _pos at 0")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I got this from Iceberg Java:

+----+
|_pos|
+----+
|0   |
|0   |
|0   |
|0   |
|0   |
+----+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants