Skip to content

feat(plugin-delta): Add support to show the external table location of Delta tables when running the SHOW CREATE TABLE command#26986

Merged
acarpente-denodo merged 1 commit intoprestodb:masterfrom
acarpente-denodo:feature/include_external_location_of_delta_tables_in_show_create_table_command
Jan 22, 2026
Merged

feat(plugin-delta): Add support to show the external table location of Delta tables when running the SHOW CREATE TABLE command#26986
acarpente-denodo merged 1 commit intoprestodb:masterfrom
acarpente-denodo:feature/include_external_location_of_delta_tables_in_show_create_table_command

Conversation

@acarpente-denodo
Copy link
Copy Markdown
Contributor

Description

Add support to show the external table location of Delta tables when running the SHOW CREATE TABLE command.

Motivation and Context

  • Some tools need to know the data and metadata location of Delta tables.
  • After this change, users will be able to recreate a Delta table at the same location where it was previously created.

Test Plan

Integration test added

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

== RELEASE NOTES ==

Delta Connector Changes
* Add support to show the external table location of Delta tables when running the SHOW CREATE TABLE command.

@acarpente-denodo acarpente-denodo requested a review from a team as a code owner January 19, 2026 11:01
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Jan 19, 2026

Reviewer's Guide

Adds support in the Delta connector to surface the external table location in SHOW CREATE TABLE by propagating the Delta table location into ConnectorTableMetadata properties, and adds an integration test to verify the generated CREATE TABLE statement includes external_location.

Sequence diagram for SHOW CREATE TABLE with external_location in Delta connector

sequenceDiagram
    actor User
    participant PrestoCoordinator
    participant DeltaMetadata
    participant DeltaTableHandle
    participant DeltaTable
    participant DeltaTableProperties
    participant ConnectorTableMetadata

    User->>PrestoCoordinator: SHOW CREATE TABLE delta_schema.table
    PrestoCoordinator->>DeltaMetadata: getTableMetadata(session, schemaTableName, tableHandle)
    DeltaMetadata->>DeltaTableHandle: getDeltaTable()
    DeltaTableHandle-->>DeltaMetadata: deltaTable

    DeltaMetadata->>DeltaTable: getColumns()
    DeltaTable-->>DeltaMetadata: List columns

    DeltaMetadata->>DeltaTable: getTableLocation()
    DeltaTable-->>DeltaMetadata: tableLocation

    DeltaMetadata->>DeltaTableProperties: EXTERNAL_LOCATION_PROPERTY
    DeltaTableProperties-->>DeltaMetadata: external_location_key

    DeltaMetadata->>ConnectorTableMetadata: new ConnectorTableMetadata(tableName, columnMetadata, properties)
    ConnectorTableMetadata-->>DeltaMetadata: connectorTableMetadata

    DeltaMetadata-->>PrestoCoordinator: connectorTableMetadata
    PrestoCoordinator-->>User: CREATE TABLE statement with external_location property
Loading

Updated class diagram for DeltaMetadata and related Delta table metadata classes

classDiagram
    class DeltaMetadata {
        +ConnectorTableMetadata getTableMetadata(ConnectorSession session, SchemaTableName tableName, DeltaTableHandle tableHandle)
    }

    class DeltaTableHandle {
        +DeltaTable getDeltaTable()
    }

    class DeltaTable {
        +List columns
        +String tableLocation
        +List getColumns()
        +String getTableLocation()
    }

    class ConnectorTableMetadata {
        +SchemaTableName table
        +List columns
        +Map properties
        +ConnectorTableMetadata(SchemaTableName tableName, List columns, Map properties)
    }

    class DeltaTableProperties {
        <<static>> String EXTERNAL_LOCATION_PROPERTY
    }

    DeltaMetadata --> DeltaTableHandle : uses
    DeltaTableHandle --> DeltaTable : returns
    DeltaMetadata --> DeltaTable : reads columns and tableLocation
    DeltaMetadata --> ConnectorTableMetadata : constructs
    DeltaMetadata --> DeltaTableProperties : uses constant
    DeltaTable --> ConnectorTableMetadata : columns data
    DeltaTableProperties --> ConnectorTableMetadata : property key
Loading

File-Level Changes

Change Details Files
Propagate Delta table external location into table metadata so it appears in SHOW CREATE TABLE output.
  • Refactor getTableMetadata to first obtain the DeltaTable instance from the table handle.
  • Create and populate a properties map with the external_location property when the Delta table has a non-null table location.
  • Construct ConnectorTableMetadata with columns and the new properties map instead of only columns.
presto-delta/src/main/java/com/facebook/presto/delta/DeltaMetadata.java
Add integration coverage to ensure SHOW CREATE TABLE for Delta tables includes external_location.
  • Add testShowCreateTable parameterized by deltaReaderVersions to create a Delta table using external_location.
  • Define a CREATE TABLE SQL template including the external_location table property and format it with the table name and golden table location.
  • Assert that the SHOW CREATE TABLE output for the Delta table exactly matches the expected CREATE TABLE command.
presto-delta/src/test/java/com/facebook/presto/delta/TestDeltaIntegration.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

@acarpente-denodo acarpente-denodo changed the title feat(connector-delta): Add support to show the external table location of Delta tables when running the SHOW CREATE TABLE command feat(plugin-delta): Add support to show the external table location of Delta tables when running the SHOW CREATE TABLE command Jan 19, 2026
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:

  • The new getTableMetadata(ConnectorSession, SchemaTableName, DeltaTable) API feels a bit awkward: callers now have to optionally pass a DeltaTable just to populate properties while the method still looks up tableHandle.getDeltaTable() for columns; consider either always deriving the DeltaTable inside this method (no DeltaTable parameter) or consistently using the passed DeltaTable for both properties and columns to avoid divergence and null plumbing.
  • In the testShowCreateTable assertion, the expected SQL string is tightly coupled to the exact formatting (whitespace, property ordering); if the SHOW CREATE TABLE printer evolves slightly this test may become fragile, so it might be worth normalizing or comparing in a more structure-aware way rather than strict string equality.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `getTableMetadata(ConnectorSession, SchemaTableName, DeltaTable)` API feels a bit awkward: callers now have to optionally pass a `DeltaTable` just to populate properties while the method still looks up `tableHandle.getDeltaTable()` for columns; consider either always deriving the `DeltaTable` inside this method (no `DeltaTable` parameter) or consistently using the passed `DeltaTable` for both properties and columns to avoid divergence and null plumbing.
- In the `testShowCreateTable` assertion, the expected SQL string is tightly coupled to the exact formatting (whitespace, property ordering); if the SHOW CREATE TABLE printer evolves slightly this test may become fragile, so it might be worth normalizing or comparing in a more structure-aware way rather than strict string equality.

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.

@acarpente-denodo acarpente-denodo force-pushed the feature/include_external_location_of_delta_tables_in_show_create_table_command branch from 1dfc506 to af37040 Compare January 19, 2026 12:24
Copy link
Copy Markdown
Contributor

@PingLiuPing PingLiuPing 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 feature.

@acarpente-denodo acarpente-denodo force-pushed the feature/include_external_location_of_delta_tables_in_show_create_table_command branch from af37040 to 27e6d67 Compare January 21, 2026 09:04
@acarpente-denodo
Copy link
Copy Markdown
Contributor Author

@sourcery-ai review

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 found 1 issue, and left some high level feedback:

  • In DeltaMetadata.getTableMetadata, consider returning an immutable empty map when there are no properties and an immutable singleton map when tableLocation is non-null instead of constructing a mutable HashMap<>(1), which avoids exposing a mutable properties map and removes the magic initial capacity.
  • The testShowCreateTable assertion does a strict string equality comparison on the entire generated SQL; you might want to normalize or compare structurally (e.g., ignoring whitespace or property ordering) to make the test less brittle to harmless formatting changes in the SHOW CREATE TABLE output.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `DeltaMetadata.getTableMetadata`, consider returning an immutable empty map when there are no properties and an immutable singleton map when `tableLocation` is non-null instead of constructing a mutable `HashMap<>(1)`, which avoids exposing a mutable properties map and removes the magic initial capacity.
- The `testShowCreateTable` assertion does a strict string equality comparison on the entire generated SQL; you might want to normalize or compare structurally (e.g., ignoring whitespace or property ordering) to make the test less brittle to harmless formatting changes in the SHOW CREATE TABLE output.

## Individual Comments

### Comment 1
<location> `presto-delta/src/test/java/com/facebook/presto/delta/TestDeltaIntegration.java:364-366` </location>
<code_context>
+                "   external_location = '%s'\n" +
+                ")";
+
+        String expectedSqlCommand = format(createTableQueryTemplate, fullTableName, goldenTablePath(tableName));
+
+        String showCreateTableCommandResult = (String) computeActual("SHOW CREATE TABLE " + fullTableName).getOnlyValue();
+
+        assertEquals(showCreateTableCommandResult, expectedSqlCommand);
</code_context>

<issue_to_address>
**suggestion (testing):** Add a test case covering a Delta table with no `tableLocation` to exercise the null/absent-location path

Since `external_location` is now only added when `deltaTable.getTableLocation()` is non-null, please add a test where `tableLocation` is null/absent. For instance, create a Delta table via the connector without specifying `external_location` and assert that `SHOW CREATE TABLE` omits the `WITH ( external_location = ...)` clause. This will exercise the empty-property-map branch and guard against regressions in metadata population.
</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.

Comment on lines +364 to +366
String expectedSqlCommand = format(createTableQueryTemplate, fullTableName, goldenTablePath(tableName));

String showCreateTableCommandResult = (String) computeActual("SHOW CREATE TABLE " + fullTableName).getOnlyValue();
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.

suggestion (testing): Add a test case covering a Delta table with no tableLocation to exercise the null/absent-location path

Since external_location is now only added when deltaTable.getTableLocation() is non-null, please add a test where tableLocation is null/absent. For instance, create a Delta table via the connector without specifying external_location and assert that SHOW CREATE TABLE omits the WITH ( external_location = ...) clause. This will exercise the empty-property-map branch and guard against regressions in metadata population.

…f Delta tables when running the SHOW CREATE TABLE command.
@acarpente-denodo acarpente-denodo force-pushed the feature/include_external_location_of_delta_tables_in_show_create_table_command branch from 27e6d67 to d96d4e9 Compare January 21, 2026 11:08
Copy link
Copy Markdown
Contributor

@PingLiuPing PingLiuPing left a comment

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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.

@acarpente-denodo acarpente-denodo merged commit 6ac60ce into prestodb:master Jan 22, 2026
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants