Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(plugin-iceberg): Fix Iceberg ANALYZE failure when column names in metadata are not lowercase for Native catalogs#28209

Open
agrawalreetika wants to merge 1 commit into
prestodb:masterprestodb/presto:masterfrom
agrawalreetika:iceberg-analyze-nativeagrawalreetika/prestodb:iceberg-analyze-nativeCopy head branch name to clipboard
Open

fix(plugin-iceberg): Fix Iceberg ANALYZE failure when column names in metadata are not lowercase for Native catalogs#28209
agrawalreetika wants to merge 1 commit into
prestodb:masterprestodb/presto:masterfrom
agrawalreetika:iceberg-analyze-nativeagrawalreetika/prestodb:iceberg-analyze-nativeCopy head branch name to clipboard

Conversation

@agrawalreetika

@agrawalreetika agrawalreetika commented Jul 23, 2026

Copy link
Copy Markdown
Member

ANALYZE on Iceberg tables using Native catalogs (REST, Nessie, Hadoop) failed with:

failed to find column name id in schema of table iceberg.default.table2_hadoop
com.facebook.presto.spi.PrestoException: failed to find column name id in schema of table iceberg4.default.table2_hadoop
    at com.facebook.presto.iceberg.TableStatisticsMaker.getField(TableStatisticsMaker.java:508)
    at com.facebook.presto.iceberg.TableStatisticsMaker.generateNDVBlob(TableStatisticsMaker.java:421)
    at com.facebook.presto.iceberg.TableStatisticsMaker.writeTableStatistics(...)

This occurred when Iceberg table metadata was written by an external engine (e.g., Spark, Flink, or other systems) that stored column names in non-lowercase form in the Iceberg schema. During ANALYZE, Presto resolves column names via schema.findField(columnName), which performs a case-sensitive lookup. If the schema stored a column as ID or Name but the stat collection referenced it as id or name, the lookup returned null, and the error was thrown.

Description

Fix Iceberg ANALYZE failure when column names in metadata are not lowercase for Native catalogs

Motivation and Context

Fix Iceberg ANALYZE failure when column names in metadata are not lowercase for Native catalogs

Impact

  • Only affects ANALYZE on Iceberg Native catalog tables (REST, Nessie, Hadoop).
  • No impact on read/write paths, which already handle case insensitivity separately.
  • No behavior change for schemas written entirely in lowercase (the common case).

Test Plan

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

Summary by Sourcery

Bug Fixes:

  • Fix ANALYZE failures on Iceberg Native catalog tables when column names in table metadata differ in case from the requested column names.

@agrawalreetika agrawalreetika self-assigned this Jul 23, 2026
Copilot AI review requested due to automatic review settings July 23, 2026 16:44
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Jul 23, 2026
@prestodb-ci
prestodb-ci requested review from a team and NivinCS and removed request for a team July 23, 2026 16:44
@sourcery-ai

sourcery-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR fixes Iceberg ANALYZE failures for Native catalogs by making column lookup in table statistics generation case-insensitive, so ANALYZE works with schemas whose column names are not stored in lowercase.

Sequence diagram for Iceberg ANALYZE case-insensitive column lookup

sequenceDiagram
    participant PrestoAnalyzer
    participant TableStatisticsMaker
    participant IcebergTable
    participant IcebergSchema

    PrestoAnalyzer->>TableStatisticsMaker: writeTableStatistics
    TableStatisticsMaker->>TableStatisticsMaker: generateNDVBlob
    TableStatisticsMaker->>TableStatisticsMaker: getField(metadata, icebergTable, snapshot)
    TableStatisticsMaker->>IcebergTable: schemas()
    IcebergTable-->>TableStatisticsMaker: SchemaMap
    TableStatisticsMaker->>IcebergSchema: caseInsensitiveFindField(metadata.getColumnName)
    alt field found
        IcebergSchema-->>TableStatisticsMaker: NestedField
        TableStatisticsMaker-->>PrestoAnalyzer: statistics written
    else field not found
        TableStatisticsMaker->>TableStatisticsMaker: log.warn
        TableStatisticsMaker-->>PrestoAnalyzer: PrestoException ICEBERG_INVALID_METADATA
    end
Loading

File-Level Changes

Change Details Files
Make column field lookup during Iceberg ANALYZE case-insensitive to handle non-lowercase column names in table metadata.
  • Change the schema field resolution from a case-sensitive findField call to caseInsensitiveFindField when resolving ColumnStatisticMetadata column names against the Iceberg table schema.
  • Preserve the existing error handling and logging path when a column still cannot be found, keeping the PrestoException type and message intact.
presto-iceberg/src/main/java/com/facebook/presto/iceberg/TableStatisticsMaker.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes ANALYZE failures for Iceberg tables (specifically when using Native catalogs like REST/Nessie/Hadoop) where the Iceberg schema stores column names with non-lowercase casing, but Presto’s stats collection references the columns using a different case.

Changes:

  • Switch Iceberg schema field resolution in stats collection from case-sensitive findField to caseInsensitiveFindField to tolerate mixed/upper-case column names in Iceberg metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 508 to 512
return Optional.ofNullable(icebergTable.schemas().get(snapshot.schemaId()))
.map(schema -> schema.findField(metadata.getColumnName()))
.map(schema -> schema.caseInsensitiveFindField(metadata.getColumnName()))
.orElseThrow(() -> {
log.warn("failed to find column name %s in schema of table %s", metadata.getColumnName(), icebergTable.name());
return new PrestoException(ICEBERG_INVALID_METADATA, format("failed to find column name %s in schema of table %s", metadata.getColumnName(), icebergTable.name()));
Copilot AI review requested due to automatic review settings July 24, 2026 05:00
@agrawalreetika
agrawalreetika force-pushed the iceberg-analyze-native branch from 7e42d7a to 59018e5 Compare July 24, 2026 05:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.