Skip to content

feat(wren-ui): Support Redshift connector#1761

Merged
fredalai merged 1 commit into
mainfrom
feature/redshift-connector
Jun 20, 2025
Merged

feat(wren-ui): Support Redshift connector#1761
fredalai merged 1 commit into
mainfrom
feature/redshift-connector

Conversation

@fredalai
Copy link
Copy Markdown
Contributor

@fredalai fredalai commented Jun 19, 2025

This pull request introduces support for the Redshift data source.

Description

Support Redshift connector

  • Guide link: https://docs.getwren.ai/oss/guide/connect/redshift
  • When updating the connection settings:
    • if the project was onboarded using the corresponding authentication method:
      • Username and password authentication method
        • The Host and Database fields cannot be edited.
      • AWS credentials authentication method
        • The Cluster identifier and Database and AWS region fields cannot be edited.
    • Allow update authentication method

Redshift Data Source:

Logo:

redshift

Engine API information

Development version: 0.16.4

1.
connection_info = {
  "redshift_type": "redshift",
  "host": <host>,
  "port": <port>,
  "database": <database name>,
  "user": <user name>,
  "password": <password>,
}
 
2.
connection_info = {
  "redshift_type":"redshift_iam" ,
  "cluster_identifier": <cluste identifier>,
  "database": <database name>,
  "user": <user name>,
  "region": <AWS region>,
  "access_key_id": <AWS access key ID>,
  "access_key_secret": <AWS secret access key>,
}

Ref UI

截圖 2025-06-19 上午9 57 26

Username and password authentication method

截圖 2025-06-19 下午3 08 08
截圖 2025-06-19 下午3 54 39

AWS credentials authentication method

截圖 2025-06-19 下午3 13 16

截圖 2025-06-19 下午5 21 04

Summary by CodeRabbit

  • New Features

    • Added support for Amazon Redshift as a new data source, including configuration via username/password or AWS IAM authentication.
    • Introduced a dedicated form for Redshift connection setup with dynamic fields based on authentication method.
    • Redshift is now available in the data source selection options with a direct link to setup documentation.
  • Bug Fixes

    • Added validation and error messaging for the Redshift cluster identifier field.
  • Style

    • Updated UI components and utilities to display Redshift-specific icons, names, and form fields where applicable.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 19, 2025

Walkthrough

This change introduces comprehensive support for Amazon Redshift as a new data source throughout the codebase. It adds new enums, types, interfaces, and validation logic for Redshift connection methods (password and IAM), updates GraphQL schema and server logic, extends utility functions, and implements a new React component for Redshift configuration in the UI.

Changes

File(s) Change Summary
.../graphql/types.ts
.../schema.ts
.../types/dataSource.ts
Added REDSHIFT to DataSourceName enum; introduced RedshiftConnectionType enum for Redshift auth methods.
.../server/adaptors/ibisAdaptor.ts Added Redshift support: enums, interfaces for password/IAM auth, union types, and updated data source mappings.
.../server/dataSource.ts Added Redshift entry to dataSource with sensitive props and connection info transformation logic.
.../server/mdl/mdlBuilder.ts
.../server/mdl/type.ts
Added Redshift to engine data source types and builder logic.
.../server/repositories/projectRepository.ts Introduced Redshift connection info interfaces, union types, and extended supported connection info.
.../components/pages/setup/dataSources/RedshiftProperties.tsx New React component for configuring Redshift data source with password/IAM authentication forms and validation.
.../components/pages/setup/utils.tsx Added Redshift entry to DATA_SOURCE_OPTIONS with guide URL and enabled status.
.../hooks/useSetupConnectionDataSource.tsx Added Redshift-specific logic to transform properties for form handling.
.../utils/dataSourceType.ts Added Redshift support to image, name, and properties utility functions.
.../utils/enum/dataSources.ts Added REDSHIFT to DATA_SOURCES enum and re-exported Redshift auth method enum.
.../utils/error/dictionary.ts Added error message for Redshift cluster identifier validation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI (RedshiftProperties)
    participant Server
    participant IbisAdaptor
    participant Redshift

    User->>UI (RedshiftProperties): Selects Redshift & fills form (Password/IAM)
    UI (RedshiftProperties)->>Server: Submits Redshift connection info
    Server->>IbisAdaptor: Converts to IbisRedshiftConnectionInfo
    IbisAdaptor->>Redshift: Attempts connection using provided credentials
    Redshift-->>IbisAdaptor: Returns connection result
    IbisAdaptor-->>Server: Passes result
    Server-->>UI (RedshiftProperties): Returns status to user
Loading

Suggested reviewers

  • andreashimin

Poem

A new path opens, Redshift in the mix,
With forms and enums, we’ve added new tricks.
IAM or password, connect with delight,
Validation and options, everything’s right!
The rabbit hops onward, with code shining bright—
Redshift now joins us, in data’s great flight!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feature/redshift-connector

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fredalai fredalai marked this pull request as ready for review June 19, 2025 09:25
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🧹 Nitpick comments (1)
wren-ui/src/components/pages/setup/dataSources/RedshiftProperties.tsx (1)

11-84: Consider extracting validation rules to improve maintainability

The password fields component is well-structured, but the validation rules are inline. Consider extracting them to a constants file for better reusability and maintenance.

+// Extract to a validation constants file
+const REDSHIFT_VALIDATION_RULES = {
+  HOST: [{ required: true, validator: hostValidator }],
+  PORT: [{ required: true, message: ERROR_TEXTS.CONNECTION.PORT.REQUIRED }],
+  // ... other rules
+};

 <Form.Item
   label="Host"
   name="host"
   required
-  rules={[
-    {
-      required: true,
-      validator: hostValidator,
-    },
-  ]}
+  rules={REDSHIFT_VALIDATION_RULES.HOST}
 >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b1a5b9 and d7bf55a.

⛔ Files ignored due to path filters (1)
  • wren-ui/public/images/dataSource/redshift.svg is excluded by !**/*.svg
📒 Files selected for processing (14)
  • wren-ui/src/apollo/client/graphql/__types__.ts (2 hunks)
  • wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts (3 hunks)
  • wren-ui/src/apollo/server/dataSource.ts (3 hunks)
  • wren-ui/src/apollo/server/mdl/mdlBuilder.ts (1 hunks)
  • wren-ui/src/apollo/server/mdl/type.ts (1 hunks)
  • wren-ui/src/apollo/server/repositories/projectRepository.ts (3 hunks)
  • wren-ui/src/apollo/server/schema.ts (1 hunks)
  • wren-ui/src/apollo/server/types/dataSource.ts (1 hunks)
  • wren-ui/src/components/pages/setup/dataSources/RedshiftProperties.tsx (1 hunks)
  • wren-ui/src/components/pages/setup/utils.tsx (1 hunks)
  • wren-ui/src/hooks/useSetupConnectionDataSource.tsx (2 hunks)
  • wren-ui/src/utils/dataSourceType.ts (4 hunks)
  • wren-ui/src/utils/enum/dataSources.ts (2 hunks)
  • wren-ui/src/utils/error/dictionary.ts (1 hunks)
🔇 Additional comments (33)
wren-ui/src/apollo/server/types/dataSource.ts (1)

12-12: LGTM! Enum addition follows established pattern.

The addition of REDSHIFT = 'REDSHIFT' to the DataSourceName enum is consistent with the existing naming convention and maintains alphabetical ordering.

wren-ui/src/apollo/server/mdl/type.ts (1)

98-98: LGTM! Engine data source type addition is consistent.

The addition of REDSHIFT = 'REDSHIFT' to the WrenEngineDataSourceType enum follows the established pattern and maintains proper alphabetical ordering.

wren-ui/src/apollo/server/mdl/mdlBuilder.ts (1)

515-516: LGTM! Required mapping for Redshift data source.

The addition of the DataSourceName.REDSHIFT case that returns WrenEngineDataSourceType.REDSHIFT follows the established pattern and completes the necessary mapping for Redshift support in the MDL builder.

wren-ui/src/components/pages/setup/utils.tsx (1)

110-114: LGTM! Data source configuration follows established pattern.

The Redshift configuration entry properly follows the same pattern as other data sources, including the spread of getDataSourceConfig() results, appropriate guide URL, and enabling the data source with disabled: false.

Please verify that the documentation URL is accessible:

#!/bin/bash
# Description: Verify the Redshift documentation URL is accessible
# Expected: HTTP 200 response

curl -I -s "https://docs.getwren.ai/oss/guide/connect/redshift" | head -1
wren-ui/src/apollo/server/schema.ts (2)

58-58: LGTM! DataSourceName enum extension is consistent.

The addition of REDSHIFT to the DataSourceName enum follows the established GraphQL schema pattern and maintains consistency with other data source entries.


61-64: LGTM! New connection type enum supports authentication methods.

The RedshiftConnectionType enum properly defines the two authentication methods (redshift for username/password and redshift_iam for AWS credentials) as outlined in the PR objectives. The naming convention follows GraphQL best practices with lowercase values.

wren-ui/src/utils/error/dictionary.ts (1)

64-66: LGTM! Validation message follows established pattern.

The new error message for cluster identifier validation is consistent with other connection validation messages and will properly support the Redshift IAM authentication method.

wren-ui/src/utils/enum/dataSources.ts (2)

1-1: LGTM! Semantic alias improves code clarity.

Re-exporting RedshiftConnectionType as REDSHIFT_AUTH_METHOD provides better semantic meaning in the UI context.


14-14: LGTM! Enum addition follows established pattern.

Adding REDSHIFT = 'REDSHIFT' to the DATA_SOURCES enum is consistent with other data source entries.

wren-ui/src/apollo/client/graphql/__types__.ts (2)

324-324: LGTM! Generated enum addition is correct.

Adding REDSHIFT = 'REDSHIFT' to the DataSourceName enum properly extends GraphQL type support for Redshift.


1226-1229: LGTM! Authentication method enum is well-defined.

The RedshiftConnectionType enum correctly defines the two authentication methods for Redshift: password-based (redshift) and IAM-based (redshift_iam).

wren-ui/src/utils/dataSourceType.ts (4)

12-12: LGTM! Import follows established pattern.

Importing RedshiftProperties component is consistent with other data source property imports.


36-37: LGTM! Image path follows naming convention.

The Redshift image path /images/dataSource/redshift.svg is consistent with other data source image paths.


65-66: LGTM! Display name is clear and consistent.

Returning 'Redshift' as the display name follows the simple naming pattern used by other data sources.


94-95: LGTM! Properties component integration is correct.

Returning the RedshiftProperties component follows the established pattern for data source configuration components.

wren-ui/src/hooks/useSetupConnectionDataSource.tsx (2)

3-3: LGTM! Import supports Redshift authentication handling.

Adding REDSHIFT_AUTH_METHOD import enables proper authentication method detection in the form transformation logic.


105-113: LGTM! Redshift form transformation logic is well-implemented.

The conditional logic correctly handles password placeholder only for the password authentication method (REDSHIFT_AUTH_METHOD.redshift), while leaving IAM authentication properties unchanged. This aligns with the different field requirements of each authentication method.

wren-ui/src/apollo/server/dataSource.ts (3)

9-11: LGTM: Clean import structure

The imports for Redshift types are properly organized and follow the existing pattern in the file.


24-27: LGTM: Consistent import pattern

The repository type imports follow the established naming convention and are appropriately grouped.


342-397: Verify the field mapping consistency for IAM authentication

The implementation correctly handles both authentication types, but there's a potential inconsistency in field naming between the repository types and Ibis types.

#!/bin/bash
# Description: Verify field name consistency between repository and adaptor types
# Expected: Field names should be consistent or properly mapped

echo "Checking REDSHIFT_IAM_AUTH fields in repository types..."
ast-grep --pattern 'interface REDSHIFT_IAM_AUTH {
  $$$
}'

echo -e "\nChecking IbisRedshiftIAMAuth fields in adaptor types..."
ast-grep --pattern 'interface IbisRedshiftIAMAuth {
  $$$
}'

echo -e "\nChecking field mapping in toIbisConnectionInfo method..."
rg -A 20 "redshiftType === IbisRedshiftConnectionType.REDSHIFT_IAM"
wren-ui/src/components/pages/setup/dataSources/RedshiftProperties.tsx (3)

1-6: LGTM: Appropriate imports and dependencies

The component imports the necessary dependencies for form handling, validation, and Redshift-specific constants.


86-170: LGTM: Well-structured IAM fields component

The IAM authentication fields are properly organized with appropriate validation rules and helpful extras like the username description. The field disabling logic in edit mode is correctly implemented.


196-201: LGTM: Smart edit mode logic

The getIsEditModeForComponent function correctly handles the edge case where the authentication method might change and ensures proper field disabling behavior.

wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts (5)

77-80: LGTM: Well-defined enum for Redshift connection types

The enum values are descriptive and follow a consistent naming pattern that clearly distinguishes between password and IAM authentication methods.


82-89: LGTM: Complete password authentication interface

The interface includes all necessary fields for password-based Redshift connections with appropriate types.


91-99: LGTM: Comprehensive IAM authentication interface

The IAM interface correctly includes AWS-specific fields like cluster_identifier, region, and access keys, which are essential for IAM-based Redshift connections.


101-104: LGTM: Proper union type definition

The union type correctly represents either authentication method, providing type safety while maintaining flexibility.


115-115: LGTM: Consistent integration with existing patterns

The addition to the SupportedDataSource enum and dataSourceUrlMap follows the established pattern and maintains consistency with other data sources.

Also applies to: 128-128

wren-ui/src/apollo/server/repositories/projectRepository.ts (5)

12-12: LGTM: Proper import of shared types

The import of IbisRedshiftConnectionType ensures type consistency between the repository and adaptor layers.


96-103: LGTM: Complete password authentication interface

The interface includes all required fields for password-based authentication with proper typing.


105-113: LGTM: Comprehensive IAM authentication interface

The IAM interface correctly includes all AWS-specific fields needed for IAM-based Redshift connections.


115-117: LGTM: Clean union type definition

The union type properly represents both authentication methods with clear naming.


129-130: LGTM: Proper integration with existing types

The addition of REDSHIFT_CONNECTION_INFO to the union type maintains backward compatibility while extending support for the new data source.

Comment on lines +184 to +194
useEffect(() => {
if (isEditMode) {
if (redshiftType && initialRedshiftTypeRef.current === null) {
initialRedshiftTypeRef.current = redshiftType;
}
} else {
form.setFieldsValue({
redshiftType: REDSHIFT_AUTH_METHOD.redshift,
});
}
}, [isEditMode, form, redshiftType]);
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.

🛠️ Refactor suggestion

Potential issue with useEffect dependency and side effects

The useEffect has a potential issue where the form.setFieldsValue call could trigger unnecessary re-renders or conflicts with user input.

 useEffect(() => {
   if (isEditMode) {
     if (redshiftType && initialRedshiftTypeRef.current === null) {
       initialRedshiftTypeRef.current = redshiftType;
     }
   } else {
-    form.setFieldsValue({
-      redshiftType: REDSHIFT_AUTH_METHOD.redshift,
-    });
+    if (!redshiftType) {
+      form.setFieldsValue({
+        redshiftType: REDSHIFT_AUTH_METHOD.redshift,
+      });
+    }
   }
 }, [isEditMode, form, redshiftType]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
if (isEditMode) {
if (redshiftType && initialRedshiftTypeRef.current === null) {
initialRedshiftTypeRef.current = redshiftType;
}
} else {
form.setFieldsValue({
redshiftType: REDSHIFT_AUTH_METHOD.redshift,
});
}
}, [isEditMode, form, redshiftType]);
useEffect(() => {
if (isEditMode) {
if (redshiftType && initialRedshiftTypeRef.current === null) {
initialRedshiftTypeRef.current = redshiftType;
}
} else {
if (!redshiftType) {
form.setFieldsValue({
redshiftType: REDSHIFT_AUTH_METHOD.redshift,
});
}
}
}, [isEditMode, form, redshiftType]);
🤖 Prompt for AI Agents
In wren-ui/src/components/pages/setup/dataSources/RedshiftProperties.tsx around
lines 184 to 194, the useEffect hook calls form.setFieldsValue unconditionally
when not in edit mode, which may cause unnecessary re-renders or interfere with
user input. To fix this, add a condition to only call form.setFieldsValue if the
current form value for redshiftType is different from
REDSHIFT_AUTH_METHOD.redshift, preventing redundant updates and side effects.

Copy link
Copy Markdown
Contributor

@andreashimin andreashimin left a comment

Choose a reason for hiding this comment

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

lgtm

@fredalai fredalai merged commit 62446f1 into main Jun 20, 2025
7 checks passed
@fredalai fredalai deleted the feature/redshift-connector branch June 20, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants