Skip to content

Conversation

@PingLiuPing
Copy link
Contributor

@PingLiuPing PingLiuPing commented Nov 4, 2025

Description

Resolve issue #26214

Motivation and Context

Impact

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.

== RELEASE NOTES ==

Iceberg Connector Changes
* Update iceberg time column catalog type from string to long.

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Nov 4, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 4, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Introduces a dedicated mapping for Iceberg TIME types by adding an icebergTypeToHiveType helper and refactoring toHiveColumns to use this helper, ensuring TIME columns are mapped to Hive LONG instead of STRING.

Class diagram for updated IcebergUtil type mapping

classDiagram
    class IcebergUtil {
        +List<Column> toHiveColumns(List<NestedField> columns)
        +FileFormat getFileFormat(Table table)
        -HiveType icebergTypeToHiveType(org.apache.iceberg.types.Type icebergType)
    }
    IcebergUtil --> Column
    IcebergUtil --> HiveType
    IcebergUtil --> HiveSchemaUtil
    IcebergUtil --> org.apache.iceberg.types.Type
    IcebergUtil --> FileFormat
    IcebergUtil --> Table
    class Column {
        +String name
        +HiveType type
        +Optional comment
        +Optional extra
    }
    class HiveType {
        +static HiveType toHiveType(Type type)
        +static HiveType HIVE_LONG
    }
    class HiveSchemaUtil {
        +static Type convert(Type type)
    }
    class org.apache.iceberg.types.Type {
        +TypeID typeId()
    }
    class TypeID {
        TIME
        // ...
    }
Loading

File-Level Changes

Change Details Files
Add icebergTypeToHiveType helper for TIME type mapping
  • Implement icebergTypeToHiveType that checks for TypeID.TIME and returns HIVE_LONG
  • Fallback to HiveType.toHiveType(HiveSchemaUtil.convert()) for other types
presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java
Refactor toHiveColumns to use the new helper
  • Replace direct HiveType.toHiveType(HiveSchemaUtil.convert()) call with icebergTypeToHiveType
  • Remove outdated conversion logic in the map operation
presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java

Possibly linked issues


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

@PingLiuPing PingLiuPing changed the title Fix(plugin-iceberg): Iceberg time column type fix(plugin-iceberg): Iceberg time column type Nov 5, 2025
@PingLiuPing PingLiuPing marked this pull request as ready for review November 5, 2025 14:35
@prestodb-ci prestodb-ci requested review from a team, Joe-Abraham and namya28 and removed request for a team November 5, 2025 14:36
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - 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.

Copy link
Member

@hantangwangd hantangwangd left a comment

Choose a reason for hiding this comment

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

@PingLiuPing Thanks for this fix. Just to confirm, have you tested it manually? Curious but I still got an error when querying a table including a column of Time type in prestissimo. I'm sure my prestissimo is the latest version, and the type is already parsed as bigint instead of varchar.

Besides, is it possible to add a test case for this fix?

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

@PingLiuPing : Thanks for this code.

Prestissimo also has TIME logical type now. Since that is backed by the BIGINT physical type this code would be fine mostly, but why not use the logical type like TIMESTAMP here ?

Also, please can you add some tests.

@PingLiuPing
Copy link
Contributor Author

@hantangwangd

Thanks for the comment.

Yes, the error is expected (I guess the error should be reported from ParquetReader "!requestedType || isCompatible(requestedType, isRepeated"). This PR only address the time column data type issue. There should be few PR required in Velox to adapt to the new time data type which is been added few weeks ago. I have submitted few PRs in Velox for this but not all of them get merged, only one relate to writing time data type been merged.

Yes, I will try to find a place to add a test case.

@PingLiuPing
Copy link
Contributor Author

@aditi-pandit thank you for comment.

Prestissimo also has TIME logical type now.

Can you point me to the PR or code in Prestissimo? Thank you.

but why not use the logical type like TIMESTAMP here?

I think TIME data type is a different logical type than TIMESTAMP but their physical type can be same such as bigint (int64). And if we convert the type to TIMESTAMP here, when this type passed to Velox, it will be treated as TIMESTAMP. And the semantics is different with TIME.

@aditi-pandit
Copy link
Contributor

@aditi-pandit thank you for comment.

Prestissimo also has TIME logical type now.

Can you point me to the PR or code in Prestissimo? Thank you.

My bad... I meant Velox. https://github.com/facebookincubator/velox/blob/main/velox/type/Type.h#L1546

but why not use the logical type like TIMESTAMP here?

I think TIME data type is a different logical type than TIMESTAMP but their physical type can be same such as bigint (int64). And if we convert the type to TIMESTAMP here, when this type passed to Velox, it will be treated as TIMESTAMP. And the semantics is different with TIME.

There is some confusion here... I meant TIMESTAMP in Iceberg uses logical type TIMESTAMP in Velox. So similarly TIME in Iceberg should use Velox TIME type.

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.

4 participants