Skip to content

Conversation

@jbewing
Copy link
Contributor

@jbewing jbewing commented Nov 25, 2025

This PR updates all writes from Spark 4.0 & 3.5 to set the sort_order_id of data files when applicable per the Iceberg Table Spec. I've opened this PR to:

  1. Gauge interest in this and validate my approach
  2. If the approach is good, make a decision on whether to backport these changes to Spark 3.4. This patch doesn't apply super cleanly to 3.4 as it stands right now, so I don't want to invest effort into it unless others would find value from it.
  3. As a follow up to those PRs, implement the ability to then report this ordering information when applicable to Spark to better inform the query planner of potential optimizations. This is rather useful when used in conjunction with SPJ and I have this running on an Iceberg fork with success

This is a successor to my initial PR #13636 which has since been closed for being stale (but I've revived it here and ported the changes forwards to spark 4.0). I've re-opened this PR as of late there has been some increased interest in this:

So it appears that there is value to these changes being upstreamed instead of confined to a fork.

Testing

I've added tests for newer added utility functions and updated existing tests that write data files and compact data files in a sorted manner to verify that we're setting the sort_order_id entry in the manifests to the correct value. Additionally, I've used this patch on an internal fork and verified that it correctly sets this field during compaction and normal writes.

Issue: #13634


public org.apache.iceberg.SortOrder icebergOrdering() {
return icebergOrdering;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not in love with this approach, but I went through a couple of iterations of this and plumbing the intended Iceberg SortOrder along through with the Spark SortOrder ended up being the cleanest in my opinion (open to any suggestions of course). I initially had an approach which would attempt to re-guess the Iceberg SortOrder from a Spark SortOrder. It worked pretty well, but was pretty naive in my opinion—the algorithm was to essentially reverse the Iceberg -> Spark SortOrder transformation as best as possible and then see if things matched up. It gets complicated when you start to consider Spark Orderings for stuff like say a positionDeltaUpdateMergeOrdering.

ebyhr and others added 25 commits November 25, 2025 10:26
---------

Co-authored-by: nk1506 <nk1506@gmail.com>
Co-authored-by: Kevin Liu <kevinjqliu@users.noreply.github.com>
Bumps [actions/labeler](https://github.com/actions/labeler) from 5 to 6.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](actions/labeler@v5...v6)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/stale](https://github.com/actions/stale) from 9.1.0 to 10.1.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](actions/stale@v9.1.0...v10.1.0)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: 10.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…14693)

Bumps software.amazon.awssdk:bom from 2.39.2 to 2.39.4.

---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
  dependency-version: 2.39.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Notify ci-jobs@iceberg.apache.org when Github Workflow fails
…14718)

Bumps software.amazon.awssdk:bom from 2.39.4 to 2.39.5.

---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
  dependency-version: 2.39.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator) from 0.35.0 to 0.36.0.
- [Release notes](https://github.com/koxudaxi/datamodel-code-generator/releases)
- [Commits](koxudaxi/datamodel-code-generator@0.35.0...0.36.0)

---
updated-dependencies:
- dependency-name: datamodel-code-generator
  dependency-version: 0.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [com.google.errorprone:error_prone_annotations](https://github.com/google/error-prone) from 2.44.0 to 2.45.0.
- [Release notes](https://github.com/google/error-prone/releases)
- [Commits](google/error-prone@v2.44.0...v2.45.0)

---
updated-dependencies:
- dependency-name: com.google.errorprone:error_prone_annotations
  dependency-version: 2.45.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…uetMetricsRowGroupFilter` (apache#14013)

Co-authored-by: Sreesh Maheshwar <smaheshwar@palantir.com>
Bumps [com.azure:azure-sdk-bom](https://github.com/azure/azure-sdk-for-java) from 1.3.2 to 1.3.3.
- [Release notes](https://github.com/azure/azure-sdk-for-java/releases)
- [Commits](Azure/azure-sdk-for-java@azure-sdk-bom_1.3.2...azure-sdk-bom_1.3.3)

---
updated-dependencies:
- dependency-name: com.azure:azure-sdk-bom
  dependency-version: 1.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@RussellSpitzer
Copy link
Member

I am willing to help as well :) I just introduced a new child to my family so I have been gone for a few of those months but I will do my best to stay on top of any new developments. Feel free to ping me on slack as well

…etection (apache#14940)

* BigQuery: Reuse table from doRefresh() in updateTable() to reduce API calls
@jbewing
Copy link
Contributor Author

jbewing commented Jan 16, 2026

I can understand the frustration, but I also understand that the OSS community is volunteering time to review the changes (most of the time outside of their work; I'm sure it is the same for you). Also, some of us just came back from the holiday season. I've also found it useful to reach out on the dev list for reviews. We could also join the community sync meetings to seek reviews if you have time.

Yeah I totally get it. I've just had a slew of interesting experiences in this project, so I want to be certain that if I'm putting in the work that someone else is in it with me 😄 .

I'll discuss this PR and my #14948 that reports this ordering to Spark to the Iceberg Spark community sync next week to gather feedback. I'm happy to help with reviews, but I'm not a committer. We will need a committer to take a look as well.

Sweet yeah as I allude to in the PR description, I also have a patch that does this on a private fork. It works quite well in a narrower set of circumstances—you need to ensure that partitions don't get too skewed or large. But in the set of circumstances that things are roughly even, the performance improvement is drastic. I'd be happy to take a look at your implementation and give feedback/lessons learned from ours.

I am willing to help as well :) I just introduced a new child to my family so I have been gone for a few of those months but I will do my best to stay on top of any new developments. Feel free to ping me on slack as well

Sounds good! Totally understand—life happens. I just wanted to make sure before putting a bunch of effort in that it would be matched this time. I look forwards to working together!

@jbewing
Copy link
Contributor Author

jbewing commented Jan 16, 2026

Alright I've rebased to the latest master. I can split out the changes if you'd like @RussellSpitzer. It seems like 4.1 is state of the art now, so would you like a PR that:

  • Is opened against 4.1
  • Backport all clean branches in a follow up (I plan on taking it back to 4.0 & 3.5 as I recall the 3.4 backport being ugly)

Or would you like it if we kept the current PR and ported forward to 4.1 as it seems like there hasn't been an official iceberg release for Spark 4.1. I'm assuming both are fine as I think the 4.1 setup must be more recent so stuff will probably forward/backport super cleanly.

@anuragmantri
Copy link
Contributor

Hi @jbewing - We discussed this PR in the community, and I would like to help move these forward with the help of other reviewers.

It seems like something went wrong with the rebase. Could you please rebase your change and make a single PR with just 4.1? I will do the same with my PR.

Community prefers that way as it's easier to review. We can have a subsequent PR that back ports to all older branches (in one PR). Usually that will not take much time in reviews.

@RussellSpitzer
Copy link
Member

One single PR against 4.1 would be ideal IMHO. Unless you have multiple independent bits you want to get in one at a time.

@jbewing
Copy link
Contributor Author

jbewing commented Jan 26, 2026

Hey @anuragmantri & @RussellSpitzer , will do. I thought I was going to be able to get to it this weekend but wasn't able to find the time, but should have some time in the next couple days. Just wanted to give an update to let you know that I had seen this and am getting to it (just not as quickly as I would've liked to)

@jbewing
Copy link
Contributor Author

jbewing commented Jan 27, 2026

@RussellSpitzer & @anuragmantri, I've opened up #15150. We can move conversation there as I'm closing this PR in favor of that one.

@jbewing jbewing closed this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.