Skip to content

Add presto-managed-view config property to BaseJdbcConfig to control remote view SQL analysis#27815

Draft
KNagaVivek wants to merge 1 commit into
prestodb:masterfrom
KNagaVivek:view_analyze_controller
Draft

Add presto-managed-view config property to BaseJdbcConfig to control remote view SQL analysis#27815
KNagaVivek wants to merge 1 commit into
prestodb:masterfrom
KNagaVivek:view_analyze_controller

Conversation

@KNagaVivek
Copy link
Copy Markdown
Contributor

@KNagaVivek KNagaVivek commented May 15, 2026

Description

Adds a new configuration property presto-managed-view to BaseJdbcConfig and a gatekeeper in JdbcMetadata.getViews() that controls whether Presto fetches and re-analyzes view SQL from the remote database in JDBC connectors.

When a JDBC connector implements JdbcClient.getViews() to expose remote database views, Presto currently re-analyzes the raw view SQL through StatementAnalyzer.analyzeView() as if it were native Presto SQL. This fails for any view containing database-native constructs such as SESSION_USER, database UDFs, or SQL dialect keywords not recognized by Presto's analyzer, even though the same views work correctly from native database clients.

This change introduces presto-managed-view as a single gatekeeper in JdbcMetadata.getViews() that applies uniformly to all JDBC connectors. When set to false, views are surfaced as regular tables via getTableHandle() and all view resolution is delegated to the remote database. When set to true, the existing Presto-managed view analysis behavior is preserved.

Changes:

  • BaseJdbcConfig: add presto-managed-view property (default: true)
  • JdbcClient: add getViews(ConnectorSession, SchemaTablePrefix) to interface
  • JdbcMetadata: gatekeeper in getViews() delegates to client or returns
    empty based on flag value
  • JdbcMetadataFactory: to create MetadataFactory

Motivation and Context

#27814

Impact

New configuration property for all JDBC connectors in catalog.properties:

Property Default Description
presto-managed-view true When true (default), Presto fetches view SQL from the remote database and analyzes it as Presto SQL. When false, views surface as tables and view resolution is delegated to the remote database.

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 ==

General Changes
* Add configuration property presto-managed-view (default: true) to JDBC connectors to control whether Presto fetches and re-analyzes view SQL from the remote database. When false, remote views are surfaced as tables
and all view resolution is delegated to the remote database, allowing database-native functions such as `SESSION_USER` and `UDFs` to execute correctly. When true, existing Presto-managed view analysis behavior is preserved.

Summary by Sourcery

Add a configurable gate to control whether JDBC connectors expose Presto-managed views or delegate view handling entirely to the remote database.

New Features:

  • Introduce the presto-managed-view configuration property in BaseJdbcConfig to toggle Presto-managed analysis of remote JDBC views.
  • Allow JdbcClient implementations to expose view definitions via a new getViews API used by JdbcMetadata when Presto view analysis is enabled.

Enhancements:

  • Wire the presto-managed-view configuration into JdbcMetadataFactory and JdbcMetadata so metadata behavior respects the connector-level setting.
  • Update JDBC metadata tests to construct JdbcMetadata with the new view analysis configuration flag.

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label May 15, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 15, 2026

Reviewer's Guide

Introduces a new presto-managed-view configuration property for JDBC connectors and threads it into JdbcMetadata so that view discovery and analysis can be centrally gated, delegating view resolution to the remote database when disabled while preserving existing behavior when enabled.

Sequence diagram for JdbcMetadata.getViews gated by presto-managed-view

sequenceDiagram
    participant Caller
    participant JdbcMetadata
    participant JdbcClient

    Caller->>JdbcMetadata: getViews(session, prefix)
    alt [prestoAnalyzeViews is false]
        JdbcMetadata-->>Caller: ImmutableMap.of()
    else [prestoAnalyzeViews is true]
        JdbcMetadata->>JdbcMetadata: listViews(session, Optional schema)
        JdbcMetadata->>JdbcClient: getViews(session, tableNames)
        JdbcClient-->>JdbcMetadata: Map<SchemaTableName, ConnectorViewDefinition>
        JdbcMetadata-->>Caller: Map<SchemaTableName, ConnectorViewDefinition>
    end
Loading

File-Level Changes

Change Details Files
Gate Presto-managed view analysis in JdbcMetadata behind a configurable flag and delegate to JdbcClient for view definitions.
  • Extend JdbcMetadata constructor with a boolean flag controlling whether Presto analyzes views
  • Store the new flag and use it in an overridden getViews() implementation to either return no views (delegating to remote DB resolution) or fetch view definitions
  • Compute the list of view table names based on the provided SchemaTablePrefix and call JdbcClient.getViews()
  • Update all JdbcMetadata instantiations in tests to pass the new flag explicitly
presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/JdbcMetadata.java
presto-base-jdbc/src/test/java/com/facebook/presto/plugin/jdbc/TestJdbcMetadata.java
presto-base-jdbc/src/test/java/com/facebook/presto/plugin/jdbc/TestSimpleJdbcConnectorCompatibility.java
Add a new BaseJdbcConfig property presto-managed-view (default true) and thread it into JdbcMetadataFactory.
  • Introduce a new boolean field in BaseJdbcConfig with default true to represent whether Presto manages/analyzes views
  • Add getter and @Config-annotated setter bound to the presto-managed-view configuration key
  • Inject BaseJdbcConfig into JdbcMetadataFactory and capture the config value in a new field
  • Pass the config-derived flag into the JdbcMetadata constructor from JdbcMetadataFactory
presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/BaseJdbcConfig.java
presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/JdbcMetadataFactory.java
Extend JdbcClient interface to support fetching view definitions for specific tables with a default no-op implementation.
  • Add a new default method getViews(ConnectorSession, List) to JdbcClient returning an empty map by default, allowing connectors to opt in to providing view definitions
  • Use this new method from JdbcMetadata.getViews() when Presto-managed views are enabled
presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/JdbcClient.java
presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/JdbcMetadata.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

@steveburnett
Copy link
Copy Markdown
Contributor

Please include documentation for the new configuration property presto-managed-view. See Designing Your Code in CONTRIBUTING.md:

"All new language features, new functions, session and config properties, and major features have documentation added"

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