|
56 | 56 | "trino", |
57 | 57 | # Nullable types are problematic |
58 | 58 | "clickhouse", |
| 59 | + # Do not support table name starts with "_" |
| 60 | + "doris", |
59 | 61 | } |
60 | 62 | MOTHERDUCK_TOKEN_REGEX = re.compile(r"(\?|\&)(motherduck_token=)(\S*)") |
61 | 63 |
|
@@ -2274,6 +2276,80 @@ def init(cursor: t.Any) -> None: |
2274 | 2276 | return init |
2275 | 2277 |
|
2276 | 2278 |
|
| 2279 | +class DorisConnectionConfig(ConnectionConfig): |
| 2280 | + """Configuration for the Apache Doris connection. |
| 2281 | +
|
| 2282 | + Apache Doris uses MySQL network protocol and is compatible with MySQL ecosystem tools, |
| 2283 | + JDBC/ODBC drivers, and various visualization tools. |
| 2284 | +
|
| 2285 | + Args: |
| 2286 | + host: The hostname of the Doris FE (Frontend) node. |
| 2287 | + user: The Doris username. |
| 2288 | + password: The Doris password. |
| 2289 | + port: The port number of the Doris FE node. Default is 9030. |
| 2290 | + database: The optional database name. |
| 2291 | + charset: The optional character set. |
| 2292 | + collation: The optional collation. |
| 2293 | + ssl_disabled: Whether to disable SSL connection. |
| 2294 | + concurrent_tasks: The maximum number of tasks that can use this connection concurrently. |
| 2295 | + register_comments: Whether or not to register model comments with the SQL engine. |
| 2296 | + local_infile: Whether or not to allow local file access. |
| 2297 | + pre_ping: Whether or not to pre-ping the connection before starting a new transaction to ensure it is still alive. |
| 2298 | + """ |
| 2299 | + |
| 2300 | + host: str |
| 2301 | + user: str |
| 2302 | + password: str |
| 2303 | + port: t.Optional[int] = 9030 # Default Doris FE port |
| 2304 | + database: t.Optional[str] = None |
| 2305 | + charset: t.Optional[str] = None |
| 2306 | + collation: t.Optional[str] = None |
| 2307 | + ssl_disabled: t.Optional[bool] = None |
| 2308 | + |
| 2309 | + concurrent_tasks: int = 4 |
| 2310 | + register_comments: bool = True |
| 2311 | + local_infile: bool = False |
| 2312 | + pre_ping: bool = True |
| 2313 | + |
| 2314 | + type_: t.Literal["doris"] = Field(alias="type", default="doris") |
| 2315 | + DIALECT: t.ClassVar[t.Literal["doris"]] = "doris" |
| 2316 | + DISPLAY_NAME: t.ClassVar[t.Literal["Apache Doris"]] = "Apache Doris" |
| 2317 | + DISPLAY_ORDER: t.ClassVar[t.Literal[17]] = 17 |
| 2318 | + |
| 2319 | + _engine_import_validator = _get_engine_import_validator("pymysql", "doris") |
| 2320 | + |
| 2321 | + @property |
| 2322 | + def _connection_kwargs_keys(self) -> t.Set[str]: |
| 2323 | + connection_keys = { |
| 2324 | + "host", |
| 2325 | + "user", |
| 2326 | + "password", |
| 2327 | + } |
| 2328 | + if self.port is not None: |
| 2329 | + connection_keys.add("port") |
| 2330 | + if self.database is not None: |
| 2331 | + connection_keys.add("database") |
| 2332 | + if self.charset is not None: |
| 2333 | + connection_keys.add("charset") |
| 2334 | + if self.collation is not None: |
| 2335 | + connection_keys.add("collation") |
| 2336 | + if self.ssl_disabled is not None: |
| 2337 | + connection_keys.add("ssl_disabled") |
| 2338 | + if self.local_infile is not None: |
| 2339 | + connection_keys.add("local_infile") |
| 2340 | + return connection_keys |
| 2341 | + |
| 2342 | + @property |
| 2343 | + def _engine_adapter(self) -> t.Type[EngineAdapter]: |
| 2344 | + return engine_adapter.DorisEngineAdapter |
| 2345 | + |
| 2346 | + @property |
| 2347 | + def _connection_factory(self) -> t.Callable: |
| 2348 | + from pymysql import connect |
| 2349 | + |
| 2350 | + return connect |
| 2351 | + |
| 2352 | + |
2277 | 2353 | CONNECTION_CONFIG_TO_TYPE = { |
2278 | 2354 | # Map all subclasses of ConnectionConfig to the value of their `type_` field. |
2279 | 2355 | tpe.all_field_infos()["type_"].default: tpe |
|
0 commit comments