-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Enhance trino connector #1207
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes introduce enhanced support for multiple schemas in Trino data source connections across the Wren UI project. The modifications span several files, updating the connection information handling to allow multiple schemas instead of a single schema. This involves changes to the data source adaptor, connection info interfaces, form components, and error text dictionary to support a more flexible schema configuration approach. Changes
Sequence DiagramsequenceDiagram
participant UI as Trino Properties UI
participant Repo as Project Repository
participant Adaptor as Ibis Adaptor
participant DataSource as Data Source Handler
UI->>Repo: Submit connection info with multiple schemas
Repo->>DataSource: Process connection info
DataSource->>DataSource: Convert to multiple connection infos
DataSource-->>Adaptor: Provide connection details
Adaptor->>Adaptor: Fetch tables for each connection
Adaptor-->>UI: Return consolidated table list
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
wren-ui/src/components/pages/setup/dataSources/TrinoProperties.tsx (1)
Line range hint
85-90
: Fix inconsistency inrequired
validation forPassword
fieldThe
Password
field hasrequired
set totrue
in theForm.Item
, butrequired
is set tofalse
in the validationrules
. This inconsistency may lead to incorrect form validation. If thePassword
field is intended to be required, setrequired: true
in the validation rules.Apply this diff to fix the validation rule:
<Form.Item label="Password" name="password" required rules={[ { - required: false, + required: true, message: ERROR_TEXTS.CONNECTION.PASSWORD.REQUIRED, }, ]} >
🧹 Nitpick comments (4)
wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts (2)
276-286
: Add type annotations togetTablesByConnectionInfo
for type safetyAdding explicit type annotations to the
getTablesByConnectionInfo
function's parameters and return type improves type safety and code readability.Apply this diff to add type annotations:
- const getTablesByConnectionInfo = async (ibisConnectionInfo) => { + const getTablesByConnectionInfo = async ( + ibisConnectionInfo: IbisConnectionInfo, + ): Promise<CompactTable[]> => {
296-301
: Consider handling individual connection failures when fetching tablesCurrently, if fetching tables from one of the multiple connections fails, the entire operation will fail due to the use of
Promise.all
. Consider usingPromise.allSettled
to handle individual failures, allowing the successful retrieval of tables from other connections while appropriately handling or logging the errors from failed connections.wren-ui/src/utils/error/dictionary.ts (1)
47-47
: Improve error message wording forSCHEMAS.REQUIRED
Consider rephrasing the error message for better clarity and grammar:
Apply this diff to update the error message:
SCHEMAS: { - REQUIRED: 'Please input list of catalog.schema separated by comma.', + REQUIRED: 'Please input a list of catalog.schema entries separated by commas.', },wren-ui/src/apollo/server/dataSource.ts (1)
181-198
: Enhance error handling for schema parsing.The schema parsing logic could be more robust. Consider these improvements:
- Trim whitespace from schema parts
- Validate schema format before splitting
- const [catalog, schema] = schemas.split(',')?.[0]?.split('.') ?? []; + const firstSchema = schemas.split(',')[0]?.trim(); + if (!firstSchema) { + throw new Error('No valid schema provided'); + } + const [catalog, schema] = firstSchema.split('.');
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts
(2 hunks)wren-ui/src/apollo/server/dataSource.ts
(3 hunks)wren-ui/src/apollo/server/repositories/projectRepository.ts
(1 hunks)wren-ui/src/components/pages/setup/dataSources/TrinoProperties.tsx
(2 hunks)wren-ui/src/utils/error/dictionary.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (7)
wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts (1)
17-20
: ImportingtoMultipleIbisConnectionInfos
to handle multiple connectionsThe addition of
toMultipleIbisConnectionInfos
enhances the ability to process multiple Ibis connection information objects, aligning with the new requirement to support multiplecatalog.schema
configurations.wren-ui/src/components/pages/setup/dataSources/TrinoProperties.tsx (2)
54-64
: UpdateSchemas
field to support multiplecatalog.schema
configurationsThe changes to the
Schemas
field appropriately reflect the support for multiplecatalog.schema
configurations, enhancing the flexibility of the Trino connector as per the PR objectives.
90-90
: Use ofInput.Password
for password fieldChanging the password input to
Input.Password
enhances security by masking user input, providing a better user experience.wren-ui/src/apollo/server/repositories/projectRepository.ts (1)
56-56
: Verify backward compatibility of the schema property rename.The change from
schema
toschemas
in theTRINO_CONNECTION_INFO
interface might break existing code that relies on the old property name.Let's check for any existing usage of the old property name:
✅ Verification successful
The schema property rename is safe to proceed with
The rename from
schema
toschemas
inTRINO_CONNECTION_INFO
interface is actually a bug fix that better reflects the expected format of multiple catalog.schema entries. No usage of the old property name was found in the codebase.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for direct usage of the old schema property rg -l "schema.*:.*string.*TRINO_CONNECTION_INFO" || rg -l "TRINO_CONNECTION_INFO.*schema.*:.*string" # Search for destructuring of the old schema property from TRINO_CONNECTION_INFO rg "const.*{.*schema.*}.*as.*TRINO_CONNECTION_INFO"Length of output: 292
Script:
#!/bin/bash # Find the interface definition and any related types rg -l "interface.*TRINO_CONNECTION_INFO" # Search for any usage of .schema property rg "\.schema\b" --type typescript # Search for schema in type definitions rg "schema.*:.*string" --type typescript # Search for any destructuring patterns with schema rg "{[^}]*schema[^}]*}" --type typescriptLength of output: 389
Script:
#!/bin/bash # View the content of the file containing the interface cat wren-ui/src/apollo/server/repositories/projectRepository.ts # Search for any schema-related patterns rg "\.schema\b" # Search for schema in type definitions with fixed regex rg "schema: string" # Search for TRINO_CONNECTION_INFO usage rg "TRINO_CONNECTION_INFO"Length of output: 15160
wren-ui/src/apollo/server/dataSource.ts (3)
50-57
: LGTM! Well-structured null-safe implementation.The new
toMultipleIbisConnectionInfos
function safely handles data sources that don't support multiple connection infos by returning null.
62-62
: LGTM! Good use of optional method.Making
toMultipleIbisConnectionInfos
optional in the interface allows for gradual adoption by different data sources.
192-192
: LGTM! Proper SSL handling.The SSL implementation correctly prefixes the host with
https://
when SSL is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts (1)
296-301
: Handle Partial Failures When Fetching TablesCurrently, if one of the connections fails in
Promise.all
, the entire operation will fail. Consider handling partial failures so that tables from successful connections are returned, and errors are logged or communicated appropriately.You might modify the implementation to use
Promise.allSettled
and process the results accordingly:- const results = await Promise.all( - multipleIbisConnectionInfos.map(getTablesByConnectionInfo), - ); + const results = await Promise.allSettled( + multipleIbisConnectionInfos.map(getTablesByConnectionInfo), + ); + const tables = results + .filter(result => result.status === 'fulfilled') + .flatMap(result => result.value); + if (tables.length === 0) { + throw new Error('Failed to retrieve tables from all connections'); + } + return tables;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts
(2 hunks)wren-ui/src/apollo/server/adaptors/tests/ibisAdaptor.test.ts
(2 hunks)wren-ui/src/apollo/server/dataSource.ts
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (5)
wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts (1)
276-287
: Correct Implementation of Multiple Connection InfosThe addition of the
getTablesByConnectionInfo
function and handling multiple Ibis connection infos enhances thegetTables
method to support multiple schemas effectively. The asynchronous implementation usingasync/await
is well-structured.wren-ui/src/apollo/server/adaptors/tests/ibisAdaptor.test.ts (1)
77-77
: Update Mock Trino Connection Info StructureThe change from
catalog
toschemas
inmockTrinoConnectionInfo
correctly reflects the new structure supporting multiple schemas. This aligns the test data with the updated function expectations.wren-ui/src/apollo/server/dataSource.ts (3)
50-57
: Well-DesignedtoMultipleIbisConnectionInfos
FunctionThe introduction of the
toMultipleIbisConnectionInfos
function is thoughtfully implemented, enhancing the ability to handle multiple schemas within the data source configuration.
181-199
: Consider Reusing Schema Parsing Logic to Avoid DuplicationIn the
toIbisConnectionInfo
method for Trino, you're performing schema parsing similar totoMultipleIbisConnectionInfos
. To maintain DRY (Don't Repeat Yourself) principles, consider reusing theparseSchema
helper function to avoid code duplication and ensure consistent validation.Since a similar suggestion was made in a previous review, applying this change will improve maintainability and consistency in your codebase.
200-243
: Effective Handling of Multiple Schemas for TrinoThe
toMultipleIbisConnectionInfos
method effectively parses and validates multiple schemas, and constructs the corresponding connection information objects. This implementation enhances the flexibility and scalability of the Trino connector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
besides a nitpick, others lgtm
Fix SSL issue
ref: #1106
Support using multiple catalog.schema
Users could now specify more than one catalog.schema
![Screenshot 2025-01-23 at 5 07 33 AM](/https://private-user-images.githubusercontent.com/1208829/405791810-4415b11c-ff35-46d1-bf2c-264300ccbc6a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMDA0MTIsIm5iZiI6MTczOTMwMDExMiwicGF0aCI6Ii8xMjA4ODI5LzQwNTc5MTgxMC00NDE1YjExYy1mZjM1LTQ2ZDEtYmYyYy0yNjQzMDBjY2JjNmEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMTg1NTEyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NWZlYjM3OWQyYWExNzY2NmViZGQyNTRmMmQ3NWQxZDkxY2RjYTE2ODNkYTRiZWFiZDk0Mzk5YTY0MzI2ZjAwZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Hh41IbcupXCl-wfns9WuYc9y5N1p1i2qFdPQICGtFuc)
ref: #546
Summary by CodeRabbit
New Features
Bug Fixes
Documentation