Skip to content

misc: Remove dead code in Iceberg connector#27336

Merged
amitkdutta merged 1 commit intoprestodb:masterfrom
amitkdutta:export-D96532833
Mar 16, 2026
Merged

misc: Remove dead code in Iceberg connector#27336
amitkdutta merged 1 commit intoprestodb:masterfrom
amitkdutta:export-D96532833

Conversation

@amitkdutta
Copy link
Copy Markdown
Contributor

@amitkdutta amitkdutta commented Mar 14, 2026

Summary: Remove unused columnParseParameters in IcebergPrestoToVeloxConnector::toVeloxColumnHandle. The variable was computed for date types but never passed to the IcebergColumnHandle constructor, which doesn't accept it — it already hardcodes kDaysSinceEpoch internally.

== NO RELEASE NOTE ==

@amitkdutta amitkdutta requested review from a team as code owners March 14, 2026 00:40
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Mar 14, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Makes TypeParser’s cached type map thread-safe using folly::Synchronized and removes unused date parsing parameter code in the IcebergPrestoToVeloxConnector.

Sequence diagram for TypeParser::parse with thread-safe cache access

sequenceDiagram
  actor Thread
  participant TypeParser
  participant Cache as SynchronizedCache
  participant VeloxParser as PrestoSqlTypeParser

  Thread->>TypeParser: parse(text)
  TypeParser->>Cache: rlock()
  Cache-->>TypeParser: lockedCache
  TypeParser->>Cache: find(text)
  alt type_in_cache
    Cache-->>TypeParser: cached TypePtr
    TypeParser-->>Thread: TypePtr
  else type_not_in_cache
    TypeParser->>VeloxParser: parseType(text)
    VeloxParser-->>TypeParser: TypePtr result
    TypeParser->>Cache: wlock()
    Cache-->>TypeParser: lockedCache
    TypeParser->>Cache: insert(text, result)
    TypeParser-->>Thread: TypePtr result
  end
Loading

Class diagram for updated TypeParser thread-safe cache

classDiagram
  class TypeParser {
    +velox::TypePtr parse(std::string text) const
    -mutable folly::Synchronized<std::unordered_map<std::string, velox::TypePtr>> cache_
  }

  class SynchronizedCache {
    <<folly::Synchronized>>
    +std::unordered_map<std::string, velox::TypePtr> data
    +rlock() const
    +wlock()
  }

  class VeloxType {
    <<velox::TypePtr>>
  }

  TypeParser --> SynchronizedCache : uses cache_
  SynchronizedCache --> VeloxType : stores
Loading

File-Level Changes

Change Details Files
Make TypeParser cache thread-safe while preserving existing caching behavior.
  • Wrap the mutable unordered_map cache in folly::Synchronized to allow safe concurrent access from const parse()
  • Use rlock() to look up existing cached entries without mutation and return early on hit
  • Use wlock() to insert newly parsed types into the cache after calling prestosql::parseType
  • Include folly/Synchronized.h and add brief documentation comments describing the TypeParser and its cache
presto-native-execution/presto_cpp/main/types/TypeParser.cpp
presto-native-execution/presto_cpp/main/types/TypeParser.h
Remove unused date partition parsing parameter setup from IcebergPrestoToVeloxConnector.
  • Delete construction of HiveColumnHandle::ColumnParseParameters and the conditional date-specific partitionDateValueFormat assignment
  • Leave type resolution via stringToType and IcebergColumnHandle construction unchanged
presto-native-execution/presto_cpp/main/connectors/IcebergPrestoToVeloxConnector.cpp

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

Copy link
Copy Markdown
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 - I've left some high level feedback:

  • In TypeParser::parse, you now take a read lock, release it, then take a write lock and unconditionally insert; consider a double-checked pattern under the write lock (re-check if the key was inserted while computing or use try_emplace) to avoid duplicate parsing and to keep the cache semantics consistent under contention.
  • Holding the write lock while calling velox::functions::prestosql::parseType could serialize all parses; you might want to compute the type outside the write lock and then insert with a short critical section, accepting the possibility of benign duplicate parses.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `TypeParser::parse`, you now take a read lock, release it, then take a write lock and unconditionally insert; consider a double-checked pattern under the write lock (re-check if the key was inserted while computing or use `try_emplace`) to avoid duplicate parsing and to keep the cache semantics consistent under contention.
- Holding the write lock while calling `velox::functions::prestosql::parseType` could serialize all parses; you might want to compute the type outside the write lock and then insert with a short critical section, accepting the possibility of benign duplicate parses.

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.

@amitkdutta amitkdutta marked this pull request as draft March 14, 2026 00:41
@amitkdutta amitkdutta marked this pull request as ready for review March 14, 2026 00:59
Comment on lines +32 to +34
// Cache of previously parsed types keyed by type signature string.
mutable folly::Synchronized<std::unordered_map<std::string, velox::TypePtr>>
cache_;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is the performance implication for this new synchronization?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this change.

Summary: Remove unused `columnParseParameters` in `IcebergPrestoToVeloxConnector::toVeloxColumnHandle`. The variable was computed for date types but never passed to the `IcebergColumnHandle` constructor, which doesn't accept it — it already hardcodes `kDaysSinceEpoch` internally.

Differential Revision: D96532833
@meta-codesync meta-codesync bot changed the title fix: Remove dead code and fix thread-unsafe TypeParser cache fix(connector): Remove dead code in Iceberg connector Mar 14, 2026
@amitkdutta amitkdutta changed the title fix(connector): Remove dead code in Iceberg connector misc: Remove dead code in Iceberg connector Mar 14, 2026
Copy link
Copy Markdown
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.

Thanks @amitkdutta

@amitkdutta amitkdutta merged commit d01dd46 into prestodb:master Mar 16, 2026
145 of 151 checks passed
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.

4 participants