Skip to content

Conversation

@yadneshpm
Copy link

@yadneshpm yadneshpm commented Oct 30, 2025

Description

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

Summary by Sourcery

Implement Delta Sharing protocol support in the Delta Lake plugin by adding a REST client and profile loader to list shares, schemas, tables, query table versions, and fetch table metadata.

New Features:

  • Introduce DeltaSharingRestClient to interact with Delta Sharing server (list shares, schemas, tables, all-tables, query table version, fetch metadata)
  • Add DeltaSharingProfile for parsing and validating Delta Sharing profile files

Build:

  • Add io.airlift:http-client dependency for HTTP communication

@cla-bot
Copy link

cla-bot bot commented Oct 30, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 30, 2025

Reviewer's Guide

This PR adds Delta Sharing support to the Trino Delta Lake plugin by introducing a new REST client to implement the Delta Sharing protocol, a profile class to load and manage sharing credentials, and updating the plugin’s POM to include the required HTTP client dependency.

Sequence diagram for listing tables via Delta Sharing REST client

sequenceDiagram
participant Client
participant DeltaSharingRestClient
participant HttpClient
Client->>DeltaSharingRestClient: listTables(shareName, schemaName, ...)
DeltaSharingRestClient->>HttpClient: HTTP GET /shares/{share}/schemas/{schema}/tables
HttpClient-->>DeltaSharingRestClient: JSON response
DeltaSharingRestClient-->>Client: TablesResponse
Loading

Sequence diagram for retrieving table metadata via Delta Sharing REST client

sequenceDiagram
participant Client
participant DeltaSharingRestClient
participant HttpClient
Client->>DeltaSharingRestClient: getTableMetadata(shareName, schemaName, tableName)
DeltaSharingRestClient->>HttpClient: HTTP POST /shares/{share}/schemas/{schema}/tables/{table}/metadata
HttpClient-->>DeltaSharingRestClient: NDJSON response
DeltaSharingRestClient-->>Client: TableMetadata
Loading

Class diagram for DeltaSharingRestClient and related types

classDiagram
class DeltaSharingRestClient {
  -HttpClient httpClient
  -DeltaSharingProfile profile
  +listShares(maxResults, pageToken) SharesResponse
  +listSchemas(shareName, maxResults, pageToken) SchemasResponse
  +listTables(shareName, schemaName, maxResults, pageToken) TablesResponse
  +listAllTables(shareName, maxResults, pageToken) TablesResponse
  +queryTableVersion(shareName, schemaName, tableName, startingTimestamp) long
  +getTableMetadata(shareName, schemaName, tableName) TableMetadata
}
class DeltaSharingProfile {
  -int shareCredentialsVersion
  -String endpoint
  -Optional<String> bearerToken
  -Optional<String> expirationTime
  +isExpired() boolean
  +fromFile(profilePath) DeltaSharingProfile
}
class SharesResponse {
  -List<Share> items
  -Optional<String> nextPageToken
  +getItems() List<Share>
  +getNextPageToken() Optional<String>
}
class SchemasResponse {
  -List<Schema> items
  -Optional<String> nextPageToken
  +getItems() List<Schema>
  +getNextPageToken() Optional<String>
}
class TablesResponse {
  -List<Table> items
  -Optional<String> nextPageToken
  +getItems() List<Table>
  +getNextPageToken() Optional<String>
}
class Share {
  -String name
  -String id
  +getName() String
  +getId() Optional<String>
}
class Schema {
  -String name
  -String share
  +getName() String
  +getShare() String
}
class Table {
  -String name
  -String share
  -String schema
  +getName() String
  +getShare() String
  +getSchema() String
}
class TableMetadata {
  -String deltaPath
  -Protocol protocol
  -Metadata metadata
  +getDeltaPath() String
  +getProtocol() Protocol
  +getMetadata() Metadata
}
class Protocol {
  -int minReaderVersion
  -int minWriterVersion
  +getMinReaderVersion() int
  +getMinWriterVersion() int
}
class Metadata {
  -String id
  -String name
  -String description
  -String schemaString
  +getId() String
  +getName() Optional<String>
  +getDescription() Optional<String>
  +getSchemaString() String
}
DeltaSharingRestClient --> DeltaSharingProfile
DeltaSharingRestClient --> SharesResponse
DeltaSharingRestClient --> SchemasResponse
DeltaSharingRestClient --> TablesResponse
DeltaSharingRestClient --> TableMetadata
SharesResponse --> Share
SchemasResponse --> Schema
TablesResponse --> Table
TableMetadata --> Protocol
TableMetadata --> Metadata
Loading

File-Level Changes

Change Details Files
Add HTTP client dependency in plugin POM
  • Include io.airlift http-client artifact as a dependency
plugin/trino-delta-lake/pom.xml
Implement DeltaSharingRestClient with full Delta Sharing API support
  • Build base URI from profile endpoint and append path parameters
  • Implement listShares, listSchemas, listTables, listAllTables methods with pagination
  • Implement queryTableVersion by extracting custom response header
  • Implement getTableMetadata with NDJSON parsing logic
  • Define DTO classes for requests and responses (SharesResponse, SchemasResponse, TablesResponse, Share, Schema, Table, TableMetadata, Protocol, Metadata)
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/metastore/deltasharing/DeltaSharingRestClient.java
Add DeltaSharingProfile for loading and validating share credentials
  • Parse profile JSON file into Java object using Jackson
  • Expose getters for version, endpoint, bearerToken, expirationTime
  • Implement isExpired() to check credential expiry timestamp
  • Provide static fromFile() helper to read profile from filesystem
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/metastore/deltasharing/DeltaSharingProfile.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

@github-actions github-actions bot added the delta-lake Delta Lake connector label Oct 30, 2025
Copy link

@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 - here's some feedback:

  • In parseTableMetadata you’re constructing deltaPath with the literal strings “share”, “schema”, and “table” instead of using the actual shareName, schemaName, and tableName—consider passing those values into the parser or building the path before calling it.
  • Remove the System.out.println debug statements in parseTableMetadata and replace them with proper logging or include debugging context in the thrown exception.
  • Avoid manual concatenation of path segments (e.g. "/shares/" + shareName + "/schemas/" + schemaName) and instead use the URI builder’s path‐segment methods to ensure correct encoding and avoid double slashes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In parseTableMetadata you’re constructing deltaPath with the literal strings “share”, “schema”, and “table” instead of using the actual shareName, schemaName, and tableName—consider passing those values into the parser or building the path before calling it.
- Remove the System.out.println debug statements in parseTableMetadata and replace them with proper logging or include debugging context in the thrown exception.
- Avoid manual concatenation of path segments (e.g. "/shares/" + shareName + "/schemas/" + schemaName) and instead use the URI builder’s path‐segment methods to ensure correct encoding and avoid double slashes.

## Individual Comments

### Comment 1
<location> `plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/metastore/deltasharing/DeltaSharingRestClient.java:335` </location>
<code_context>
+        }
+
+        // Delta path is constructed from share/schema/table
+        String deltaPath = String.format("%s#%s.%s.%s", profile.getEndpoint(), "share", "schema", "table");
+
+        return new TableMetadata(deltaPath, protocol, metadata);
</code_context>

<issue_to_address>
**issue (bug_risk):** Hardcoded share, schema, and table names in deltaPath construction.

Use shareName, schemaName, and tableName variables in deltaPath instead of hardcoded strings to ensure correct path construction.
</issue_to_address>

### Comment 2
<location> `plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/metastore/deltasharing/DeltaSharingRestClient.java:328-330` </location>
<code_context>
+
+        if (protocol == null || metadata == null) {
+            // Add debugging information
+            System.out.println("Debug: Response JSON: " + json);
+            System.out.println("Debug: Protocol found: " + (protocol != null));
+            System.out.println("Debug: Metadata found: " + (metadata != null));
+            throw new IOException("Invalid table metadata response: missing protocol or metadata");
+        }
</code_context>

<issue_to_address>
**issue:** Debugging output left in production code.

Please remove these System.out.println statements or replace them with proper logging to avoid cluttering production logs and exposing sensitive data.
</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.

}

// Delta path is constructed from share/schema/table
String deltaPath = String.format("%s#%s.%s.%s", profile.getEndpoint(), "share", "schema", "table");
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Hardcoded share, schema, and table names in deltaPath construction.

Use shareName, schemaName, and tableName variables in deltaPath instead of hardcoded strings to ensure correct path construction.

Comment on lines +328 to +326
System.out.println("Debug: Response JSON: " + json);
System.out.println("Debug: Protocol found: " + (protocol != null));
System.out.println("Debug: Metadata found: " + (metadata != null));
Copy link

Choose a reason for hiding this comment

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

issue: Debugging output left in production code.

Please remove these System.out.println statements or replace them with proper logging to avoid cluttering production logs and exposing sensitive data.

@ebyhr ebyhr added the needs-docs This pull request requires changes to the documentation label Oct 30, 2025
Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

I recommend starting a discussion in Trino Slack first. https://trino.io/slack.html
A separate connector might be a better approach than modifying the Delta Lake connector.

@yadneshpm yadneshpm force-pushed the add_delta_sharing_support_in_delta_lake branch from 06e9ee7 to cec650b Compare October 30, 2025 05:29
@cla-bot
Copy link

cla-bot bot commented Oct 30, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@yadneshpm yadneshpm changed the title Add delta sharing support in delta lake [WIP] Add delta sharing support in delta lake Oct 30, 2025
@yadneshpm
Copy link
Author

I recommend starting a discussion in Trino Slack first. A separate connector might be a better approach than modifying the Delta Lake connector.

I had started a thread two months ago:
https://trinodb.slack.com/archives/CP1MUNEUX/p1756732277724319
There was no response on that. Would be helpful if you could tag the relevant folks to start a discussion.
I had started working in response to this issue: #19179
We also have a similar use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delta-lake Delta Lake connector needs-docs This pull request requires changes to the documentation

Development

Successfully merging this pull request may close these issues.

2 participants