-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: Add Databend connector #27187
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
base: master
Are you sure you want to change the base?
feat: Add Databend connector #27187
Conversation
Reviewer's GuideThis PR introduces a new Databend connector by adding a dedicated plugin module, wiring it into the build and CI pipelines, implementing the JDBC-based client with Databend-specific dialect support, and providing comprehensive documentation and test coverage. Class diagram for new Databend connector typesclassDiagram
class DatabendPlugin {
+DatabendPlugin()
}
class DatabendClientModule {
+setup(Binder)
+connectionFactory(BaseJdbcConfig, CredentialProvider, OpenTelemetry)
}
class DatabendClient {
+DatabendClient(...)
+topNFunction()
+isTopNGuaranteed(ConnectorSession)
+implementJoin(...)
+getTables(...)
+quoted(...)
+copyTableSchema(...)
+listSchemas(Connection)
+getTableComment(ResultSet)
+createTableSqls(...)
+getTableProperties(...)
+setTableProperties(...)
+getColumnDefinitionSql(...)
+createSchema(...)
+dropSchema(...)
+renameSchema(...)
+addColumn(...)
+setTableComment(...)
+setColumnType(...)
+dropNotNullConstraint(...)
+getTableTypes()
+renameTable(...)
+limitFunction()
+isLimitGuaranteed(ConnectorSession)
+toColumnMapping(...)
+toWriteMapping(...)
}
class DatabendTableProperties {
+DatabendTableProperties()
+getTableProperties()
+static getEngine(Map)
+static getOrderBy(Map)
}
class DatabendConfig {
+getConnectionTimeout()
+setConnectionTimeout(Duration)
}
class DatabendEngineType {
+getEngineType()
<<enum>>
}
class DatabendUtil {
+convertToQuotedString(Object)
+escape(String, char)
<<static>>
}
DatabendPlugin --|> JdbcPlugin
DatabendClientModule --|> AbstractConfigurationAwareModule
DatabendClient --|> BaseJdbcClient
DatabendTableProperties --|> TablePropertiesProvider
DatabendClientModule --> DatabendClient
DatabendClient --> DatabendConfig
DatabendClient --> DatabendTableProperties
DatabendTableProperties --> DatabendEngineType
DatabendClient --> DatabendUtil
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- The override of setTableProperties currently emits an empty ALTER TABLE MODIFY (no-op)—either implement engine/order_by modifications or remove it to fail fast on unsupported operations.
- getTableProperties only reads the engine field but ignores the configured order_by property; update it to return all declared tableProperties to keep metadata in sync.
- DatabendClient duplicates a lot of JDBC pushdown/join/limit logic seen in other connectors—consider refactoring shared behavior into BaseJdbcClient utilities to reduce boilerplate.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The override of setTableProperties currently emits an empty ALTER TABLE MODIFY (no-op)—either implement engine/order_by modifications or remove it to fail fast on unsupported operations.
- getTableProperties only reads the engine field but ignores the configured order_by property; update it to return all declared tableProperties to keep metadata in sync.
- DatabendClient duplicates a lot of JDBC pushdown/join/limit logic seen in other connectors—consider refactoring shared behavior into BaseJdbcClient utilities to reduce boilerplate.
## Individual Comments
### Comment 1
<location> `plugin/trino-databend/src/main/java/io/trino/plugin/databend/DatabendClient.java:142-151` </location>
<code_context>
+ }
+ }
+
+ @Override
+ public void setTableProperties(ConnectorSession session, JdbcTableHandle handle, Map<String, Optional<Object>> nullableProperties)
+ {
+ checkArgument(nullableProperties.values().stream().noneMatch(Optional::isEmpty), "Setting a property to null is not supported");
</code_context>
<issue_to_address>
**issue (bug_risk):** setTableProperties does not actually set any properties.
Currently, setTableProperties does not modify any table properties, which could mislead users. Please implement property modification logic or throw an exception to indicate this operation is unsupported.
</issue_to_address>
### Comment 2
<location> `plugin/trino-databend/src/main/java/io/trino/plugin/databend/DatabendTableProperties.java:65-71` </location>
<code_context>
+ return (DatabendEngineType) tableProperties.get(ENGINE_PROPERTY);
+ }
+
+ public static List<String> getOrderBy(Map<String, Object> tableProperties)
+ {
+ requireNonNull(tableProperties, "tableProperties is null");
+ @SuppressWarnings("unchecked")
+ List<String> orderBy = (List<String>) tableProperties.get("order_by");
+ return orderBy;
</code_context>
<issue_to_address>
**suggestion:** getOrderBy does not handle missing or null property gracefully.
Returning null can cause runtime errors if not handled. Returning an empty list would be safer and prevent NullPointerExceptions.
```suggestion
public static List<String> getOrderBy(Map<String, Object> tableProperties)
{
requireNonNull(tableProperties, "tableProperties is null");
@SuppressWarnings("unchecked")
List<String> orderBy = (List<String>) tableProperties.get("order_by");
if (orderBy == null) {
return Collections.emptyList();
}
return orderBy;
}
```
</issue_to_address>
### Comment 3
<location> `plugin/trino-databend/src/test/java/io/trino/plugin/databend/TestDatabendTypeMapping.java:45-46` </location>
<code_context>
+ };
+ }
+
+ @Test
+ @Override
+ public void testShowColumns()
</code_context>
<issue_to_address>
**suggestion (testing):** Add tests for boolean type edge cases (nulls, invalid values).
Please include test cases for null and invalid boolean values to verify correct handling by the connector.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
plugin/trino-databend/src/main/java/io/trino/plugin/databend/DatabendClient.java
Show resolved
Hide resolved
plugin/trino-databend/src/main/java/io/trino/plugin/databend/DatabendTableProperties.java
Show resolved
Hide resolved
plugin/trino-databend/src/main/java/io/trino/plugin/databend/DatabendClient.java
Show resolved
Hide resolved
12d1732 to
e0ec291
Compare
|
Hi @ebyhr , sorry to bother you, I want to ask a question that I run |

Add Databend connector.
Summary by Sourcery
Introduce a new Databend connector plugin for Trino, enabling JDBC-based connectivity, query pushdown, type mapping, and metadata operations against Databend databases.
New Features:
Enhancements:
Build:
CI:
Documentation:
Tests: