Skip to content

refactor: HivePartitionManager.parsePartition to instance method and remove timeZone argument#27284

Merged
gggrace14 merged 1 commit intoprestodb:masterfrom
gggrace14:export-D95603597
Mar 7, 2026
Merged

refactor: HivePartitionManager.parsePartition to instance method and remove timeZone argument#27284
gggrace14 merged 1 commit intoprestodb:masterfrom
gggrace14:export-D95603597

Conversation

@gggrace14
Copy link
Copy Markdown
Contributor

@gggrace14 gggrace14 commented Mar 6, 2026

Summary:
Convert parsePartition from a static method to an instance method in
HivePartitionManager (presto-facebook-trunk), removing the DateTimeZone
timeZone parameter. Then parsePartition could use the timeZone member
field of the HivePartitionManager instance instead of requiring callers to pass.
Update call sites within HivePartitionManager,
TestMetastoreHiveStatisticsProvider, and VectorSearchOptimizerUtils.

== NO RELEASE NOTE ==

Differential Revision: D95603597

Summary by Sourcery

Refactor Hive partition parsing to use an instance-level HivePartitionManager method without an explicit time zone parameter and update call sites and tests accordingly.

Enhancements:

  • Convert HivePartitionManager.parsePartition from a static method with a time zone argument to an instance method that relies on manager configuration instead.
  • Adjust internal HivePartitionManager callers to use the new instance parsePartition signature when building partitions and applying constraints.

Tests:

  • Update TestMetastoreHiveStatisticsProvider to construct a HivePartitionManager instance and use it for partition parsing in test helpers.

@gggrace14 gggrace14 requested a review from a team as a code owner March 6, 2026 22:02
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Mar 6, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors HivePartitionManager.parsePartition from a static utility-style method into an instance method (removing the DateTimeZone parameter) and updates internal call sites and tests accordingly.

Class diagram for refactored HivePartitionManager.parsePartition instance method

classDiagram
    class HivePartitionManager {
        +HivePartitionResult getPartitions(SemiTransactionalHiveMetastore metastore, ConnectorSession session, HiveTableHandle hiveTableHandle, Constraint~ColumnHandle~ constraint)
        -List~HivePartition~ getPartitionListFromPartitionNames(ConnectorSession session, SchemaTableName tableName, List~PartitionNameWithVersion~ partitionNames, List~HiveColumnHandle~ partitionColumns, List~Type~ partitionTypes, Constraint~ColumnHandle~ constraint)
        -Optional~HivePartition~ parseValuesAndFilterPartition(SchemaTableName tableName, PartitionNameWithVersion partitionNameWithVersion, List~HiveColumnHandle~ partitionColumns, List~Type~ partitionColumnTypes, Constraint~ColumnHandle~ constraint)
        +HivePartition parsePartition(SchemaTableName tableName, PartitionNameWithVersion partitionNameWithVersion, List~HiveColumnHandle~ partitionColumns, List~Type~ partitionColumnTypes)
    }

    class HivePartition {
    }

    class HiveColumnHandle {
        +String getName()
        +TypeSignature getTypeSignature()
    }

    class PartitionNameWithVersion {
    }

    class Type {
    }

    class SchemaTableName {
    }

    class Constraint~ColumnHandle~ {
        +TupleDomain~ColumnHandle~ getSummary()
    }

    class TupleDomain~T~ {
        +Optional~Map~ColumnHandle,Domain~~ getDomains()
    }

    HivePartitionManager --> HivePartition : creates
    HivePartitionManager --> HiveColumnHandle : uses
    HivePartitionManager --> PartitionNameWithVersion : uses
    HivePartitionManager --> Type : uses
    HivePartitionManager --> SchemaTableName : uses
    HivePartitionManager --> Constraint~ColumnHandle~ : uses
    Constraint~ColumnHandle~ --> TupleDomain~ColumnHandle~ : returns
    TupleDomain~ColumnHandle~ --> Domain : contains
Loading

File-Level Changes

Change Details Files
Refactor parsePartition from static utility-style method to an instance method and remove the DateTimeZone argument.
  • Change parsePartition signature to be an instance method on HivePartitionManager instead of static
  • Remove DateTimeZone timeZone parameter from parsePartition and its call sites
  • Update optimized partition parsing stream pipeline to call the new instance method
  • Update parseValuesAndFilterPartition to use the new instance method signature
presto-hive/src/main/java/com/facebook/presto/hive/HivePartitionManager.java
Adjust unit test helper to use a HivePartitionManager instance for partition parsing.
  • Introduce a HivePartitionManager field in TestMetastoreHiveStatisticsProvider initialized with test dependencies
  • Change partition(String name) helper from static to instance method to allow calling the instance parsePartition
  • Update partition(String name) to delegate to hivePartitionManager.parsePartition with the new method signature (no DateTimeZone argument)
presto-hive/src/test/java/com/facebook/presto/hive/statistics/TestMetastoreHiveStatisticsProvider.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

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 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
Copy Markdown
Member

@skyelves skyelves left a comment

Choose a reason for hiding this comment

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

LGTM

…remove timeZone argument (prestodb#27284)

Summary:

Convert parsePartition from a static method to an instance method in
HivePartitionManager (presto-facebook-trunk), removing the DateTimeZone
timeZone parameter. Then parsePartition could use the timeZone member
field of the HivePartitionManager instance instead of requiring callers to pass.
Update call sites within HivePartitionManager,
TestMetastoreHiveStatisticsProvider, and VectorSearchOptimizerUtils.

== NO RELEASE NOTE ==

Reviewed By: skyelves

Differential Revision: D95603597
PartitionNameWithVersion partitionNameWithVersion,
List<HiveColumnHandle> partitionColumns,
List<Type> partitionColumnTypes,
DateTimeZone timeZone)
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 guess this is under the assumption that the timeZone used will always be the timeZone defined in the class?

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.

Yes, exactly. Checked all call sites, and all set this parameter to the timeZone member of the class, except unit tests.

(It's hard for the user to get the timezone configured in prod.)

@gggrace14 gggrace14 merged commit 4073ecb into prestodb:master Mar 7, 2026
154 of 159 checks passed
@gggrace14 gggrace14 deleted the export-D95603597 branch March 7, 2026 07:47
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