Skip to content

Conversation

@sh-shamsan
Copy link
Contributor

@sh-shamsan sh-shamsan commented Jul 16, 2025

Description

An internal cherry-pick to make MAX_PREFIXES_COUNT configurable via session properties and config.properties. This helps improve performance of SHOW QUERY

Motivation and Context

Impact

Test Plan

UTs

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.

Release Notes

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

== RELEASE NOTES ==

General Changes
* Add configuration property ``max-prefixes-count``

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Jul 16, 2025
@sh-shamsan sh-shamsan marked this pull request as ready for review July 21, 2025 13:52
@sh-shamsan sh-shamsan requested a review from a team as a code owner July 21, 2025 13:52
@prestodb-ci prestodb-ci requested review from a team, pramodsatya and xin-zhang2 and removed request for a team July 21, 2025 13:52
@sh-shamsan sh-shamsan requested a review from ScrapCodes July 21, 2025 13:57
@sh-shamsan sh-shamsan requested a review from aaneja July 31, 2025 07:50
@sh-shamsan sh-shamsan force-pushed the max-prefix-count branch 2 times, most recently from 5e0f8e6 to 2227c73 Compare August 5, 2025 13:11
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

@sh-shamsan sh-shamsan marked this pull request as draft September 21, 2025 18:36
@sh-shamsan sh-shamsan marked this pull request as ready for review October 30, 2025 08:46
@prestodb-ci prestodb-ci requested a review from a team October 30, 2025 08:46
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 30, 2025

Reviewer's Guide

This PR refactors the hard-coded max prefixes limit into a configurable session and server property, wiring it through FeaturesConfig and SystemSessionProperties, and updating InformationSchemaMetadata to respect the dynamic limit when calculating table prefixes. Tests have been adapted and extended to validate the new configuration end-to-end.

Entity relationship diagram for session and config properties

erDiagram
    FEATURES_CONFIG {
        int maxPrefixesCount
    }
    SYSTEM_SESSION_PROPERTIES {
        string MAX_PREFIXES_COUNT
    }
    SESSION {
        int maxPrefixesCount
    }
    FEATURES_CONFIG ||--o| SYSTEM_SESSION_PROPERTIES : exposes
    SYSTEM_SESSION_PROPERTIES ||--o| SESSION : sets
Loading

Class diagram for configurable max prefixes count

classDiagram
    class FeaturesConfig {
        - int maxPrefixesCount
        + setMaxPrefixesCount(Integer): FeaturesConfig
        + getMaxPrefixesCount(): int
    }
    class SystemSessionProperties {
        + MAX_PREFIXES_COUNT: String
        + getMaxPrefixesCount(Session): int
    }
    class InformationSchemaMetadata {
        + getTableLayoutForConstraint(...): ConnectorTableLayoutResult
    }
    FeaturesConfig <.. SystemSessionProperties : uses
    SystemSessionProperties <.. InformationSchemaMetadata : uses
Loading

File-Level Changes

Change Details Files
Expose max-prefixes-count in the feature configuration
  • Introduce maxPrefixesCount field with default 100
  • Add @config setter and getter for max-prefixes-count
  • Include validation with @min(1) annotation
presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java
Register and expose the session property
  • Define MAX_PREFIXES_COUNT constant
  • Register integerProperty in SystemSessionProperties constructor
  • Add getMaxPrefixesCount(session) helper method
presto-main-base/src/main/java/com/facebook/presto/SystemSessionProperties.java
Apply dynamic prefix limit in InformationSchemaMetadata
  • Remove hard-coded MAX_PREFIXES_COUNT constant
  • Fetch maxPrefixesCount from session via SystemSessionProperties
  • Replace static checks with dynamic comparisons in getTableLayoutForConstraint
presto-main-base/src/main/java/com/facebook/presto/connector/informationSchema/InformationSchemaMetadata.java
Adapt and extend tests for the new property
  • Introduce TEST_CATALOG constant
  • Update createNewSession to accept and set maxPrefixesCount
  • Modify tests to use dynamic session property and constants
  • Add default and explicit mapping assertions in TestFeaturesConfig
presto-main-base/src/test/java/com/facebook/presto/metadata/TestInformationSchemaMetadata.java
presto-main-base/src/test/java/com/facebook/presto/sql/analyzer/TestFeaturesConfig.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
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!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `presto-main-base/src/test/java/com/facebook/presto/metadata/TestInformationSchemaMetadata.java:163` </location>
<code_context>
+                .setCatalog(TEST_CATALOG)
                 .setSchema("information_schema")
                 .setTransactionId(transactionId)
+                .setSystemProperty(MAX_PREFIXES_COUNT, String.valueOf(maxPrefixesCount))
                 .build()
                 .toConnectorSession();
</code_context>

<issue_to_address>
**suggestion (testing):** Missing test for boundary and invalid values of maxPrefixesCount session property.

Add tests for maxPrefixesCount at its minimum (1), a large value, and invalid values (0, negative) to verify correct handling and enforcement of the @Min(1) constraint.

Suggested implementation:

```java
    private ConnectorSession createNewSession(TransactionId transactionId, int maxPrefixesCount)
    {
        return testSessionBuilder()
                .setCatalog(TEST_CATALOG)
                .setSchema("information_schema")
                .setTransactionId(transactionId)
                .setSystemProperty(MAX_PREFIXES_COUNT, String.valueOf(maxPrefixesCount))
                .build()
                .toConnectorSession();
    }

    @Test
    public void testMaxPrefixesCountSessionPropertyBoundaries()
    {
        TransactionId transactionId = TransactionId.create();
        // Minimum valid value
        ConnectorSession sessionMin = createNewSession(transactionId, 1);
        assertEquals(Integer.parseInt(sessionMin.getSystemProperty(MAX_PREFIXES_COUNT)), 1);

        // Large valid value
        int largeValue = 1000000;
        ConnectorSession sessionLarge = createNewSession(transactionId, largeValue);
        assertEquals(Integer.parseInt(sessionLarge.getSystemProperty(MAX_PREFIXES_COUNT)), largeValue);

        // Invalid value: zero
        try {
            createNewSession(transactionId, 0);
            fail("Expected exception for maxPrefixesCount = 0");
        }
        catch (IllegalArgumentException | RuntimeException e) {
            // Expected
        }

        // Invalid value: negative
        try {
            createNewSession(transactionId, -5);
            fail("Expected exception for maxPrefixesCount = -5");
        }
        catch (IllegalArgumentException | RuntimeException e) {
            // Expected
        }
    }

```

If the session property validation does not currently throw an exception for invalid values, you may need to add or adjust validation logic elsewhere in the codebase to enforce the @Min(1) constraint.
</issue_to_address>

### Comment 2
<location> `presto-main-base/src/test/java/com/facebook/presto/sql/analyzer/TestFeaturesConfig.java:62` </location>
<code_context>
     public void testDefaults()
     {
         assertRecordedDefaults(ConfigAssertions.recordDefaults(FeaturesConfig.class)
+                .setMaxPrefixesCount(100)
                 .setCpuCostWeight(75)
                 .setMemoryCostWeight(10)
</code_context>

<issue_to_address>
**suggestion (testing):** Missing test for invalid max-prefixes-count property in FeaturesConfig.

Add a test to ensure that invalid max-prefixes-count values (such as 0 or negative) are properly rejected according to the @Min(1) constraint.
</issue_to_address>

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.

ScrapCodes
ScrapCodes previously approved these changes Oct 30, 2025
@sh-shamsan sh-shamsan changed the title max prefixes count feat: add max-prefixes-count session property Oct 30, 2025
@sh-shamsan sh-shamsan changed the title feat: add max-prefixes-count session property feat: Add max-prefixes-count session property Oct 30, 2025
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

Thanks for the documentation! A few requests.

steveburnett
steveburnett previously approved these changes Nov 3, 2025
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull updated branch, new local doc build. Looks good, thanks for the updates!

        Introduce a new session property `max-prefixes-count` to tune prefixes.

        Co-authored-by: Prashant Sharma <[email protected]>
Copy link
Member

@agrawalreetika agrawalreetika left a comment

Choose a reason for hiding this comment

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

LGTM

@tdcmeehan tdcmeehan merged commit 9374cd8 into prestodb:master Nov 20, 2025
114 of 116 checks passed
@prestodb-ci
Copy link
Contributor

@czentgr imported this issue as lakehouse/presto #25550

@prestodb-ci
Copy link
Contributor

@mohsaka imported this issue as lakehouse/presto #25550

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.

7 participants