From 6056a34a04ff84f8bfbf76165803061aae302c1a Mon Sep 17 00:00:00 2001 From: ISADBA Date: Thu, 1 Feb 2024 20:03:08 +0800 Subject: [PATCH 1/3] feat(datasource): Support new datasource of Doris --- src/common/datasource/doris/index.tsx | 106 ++++++++++++++++++ src/common/datasource/index.tsx | 13 +++ src/component/AddDataSourceDropdown/index.tsx | 13 ++- src/constant/label.ts | 1 + src/d.ts/datasource.ts | 1 + src/d.ts/index.ts | 3 + .../NewDatasourceDrawer/NewButton.tsx | 23 ++++ src/svgr/database_doris.svg | 5 + src/svgr/doris.svg | 5 + 9 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 src/common/datasource/doris/index.tsx create mode 100644 src/svgr/database_doris.svg create mode 100644 src/svgr/doris.svg diff --git a/src/common/datasource/doris/index.tsx b/src/common/datasource/doris/index.tsx new file mode 100644 index 000000000..7c2f694e2 --- /dev/null +++ b/src/common/datasource/doris/index.tsx @@ -0,0 +1,106 @@ +/* + * Copyright 2023 OceanBase + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ConnectType, TaskType } from '@/d.ts'; +import { IDataSourceModeConfig } from '../interface'; +import MySQLColumnExtra from '../oceanbase/MySQLColumnExtra'; +import { haveOCP } from '@/util/env'; + +const tableConfig = { + enableTableCharsetsAndCollations: true, + enableConstraintOnUpdate: true, + ColumnExtraComponent: MySQLColumnExtra, + paritionNameCaseSensitivity: true, + enableIndexesFullTextType: true, + enableAutoIncrement: true, + type2ColumnType: { + id: 'int', + name: 'varchar', + date: 'datetime', + time: 'timestamp', + }, +}; + +const functionConfig: IDataSourceModeConfig['schema']['func'] = { + params: ['paramName', 'dataType', 'dataLength'], + defaultValue: { + dataLength: 45, + }, + dataNature: true, + sqlSecurity: true, + deterministic: true, +}; + +const procedureConfig: IDataSourceModeConfig['schema']['proc'] = { + params: ['paramName', 'paramMode', 'dataType', 'dataLength'], + defaultValue: { + dataLength: 45, + }, + dataNature: true, + sqlSecurity: true, + deterministic: true, +}; + +const items: Record = { + [ConnectType.DORIS]: { + connection: { + address: { + items: ['ip', 'port'], + }, + account: true, + sys: false, + ssl: false, + jdbcDoc: + 'https://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html', + }, + features: { + task: [ + TaskType.ASYNC, + TaskType.DATAMOCK, + TaskType.SQL_PLAN, + TaskType.DATA_ARCHIVE, + TaskType.DATA_DELETE, + TaskType.IMPORT, + TaskType.EXPORT, + TaskType.EXPORT_RESULT_SET, + ], + obclient: true, + recycleBin: false, + sessionManage: true, + sqlExplain: true, + export: { + fileLimit: false, + snapshot: false, + }, + }, + schema: { + table: tableConfig, + func: functionConfig, + proc: procedureConfig, + innerSchema: ['information_schema', 'test', 'mysql'], + }, + sql: { + language: 'mysql', + escapeChar: '`', + }, + }, +}; + +if (haveOCP()) { + delete items[ConnectType.DORIS]; +} + +export default items; diff --git a/src/common/datasource/index.tsx b/src/common/datasource/index.tsx index a07116e1e..9a7e82d0d 100644 --- a/src/common/datasource/index.tsx +++ b/src/common/datasource/index.tsx @@ -21,10 +21,13 @@ import obOracle from './oceanbase/oboracle'; import obMySQL from './oceanbase/obmysql'; import oracle from './oracle'; import MySQL from './mysql'; +import Doris from './doris'; import { ReactComponent as OBSvg } from '@/svgr/source_ob.svg'; import { ReactComponent as DBOBSvg } from '@/svgr/database_oceanbase.svg'; import { ReactComponent as MySQLSvg } from '@/svgr/mysql.svg'; import { ReactComponent as DBMySQLSvg } from '@/svgr/database_mysql.svg'; +import { ReactComponent as DorisSvg } from '@/svgr/doris.svg'; +import { ReactComponent as DBDorisSvg } from '@/svgr/database_doris.svg'; import { ReactComponent as OracleSvg } from '@/svgr/oracle.svg'; import { ReactComponent as DBOracleSvg } from '@/svgr/database_oracle.svg'; @@ -57,6 +60,15 @@ const _styles = { component: DBMySQLSvg, }, }, + [IDataSourceType.Doris]: { + icon: { + component: DorisSvg, + color: '#09C7F7', + }, + dbIcon: { + component: DBDorisSvg, + }, + }, [IDataSourceType.Oracle]: { icon: { component: OracleSvg, @@ -104,6 +116,7 @@ function register( register(IDataSourceType.OceanBase, obOracle); register(IDataSourceType.OceanBase, obMySQL); register(IDataSourceType.MySQL, MySQL); +register(IDataSourceType.Doris, Doris); register(IDataSourceType.Oracle, oracle); function getAllConnectTypes(ds?: IDataSourceType): ConnectType[] { diff --git a/src/component/AddDataSourceDropdown/index.tsx b/src/component/AddDataSourceDropdown/index.tsx index f62622041..61bcede8b 100644 --- a/src/component/AddDataSourceDropdown/index.tsx +++ b/src/component/AddDataSourceDropdown/index.tsx @@ -23,6 +23,7 @@ import { ItemType } from 'antd/lib/menu/hooks/useItems'; import { useMemo } from 'react'; interface IProps {} export default function AddDataSourceDropdown(props: IProps) { + const dorisConnectTypes = getAllConnectTypes(IDataSourceType.Doris); const mysqlConnectTypes = getAllConnectTypes(IDataSourceType.MySQL); const obConnectTypes = getAllConnectTypes(IDataSourceType.OceanBase); const result: ItemType[] = useMemo(() => { @@ -42,6 +43,16 @@ export default function AddDataSourceDropdown(props: IProps) { key: t, }); }); + dorisConnectTypes.forEach((t) => { + result.push({ + label: ConnectTypeText[t], + key: t, + }); + }); + result.push({ + type: 'divider', + }); + console.log(123) result.push({ label: formatMessage({ id: 'odc.src.component.AddDataSourceDropdown.BatchImport', @@ -49,7 +60,7 @@ export default function AddDataSourceDropdown(props: IProps) { key: 'batchImport', }); return result; - }, [mysqlConnectTypes, obConnectTypes]); + }, [dorisConnectTypes,mysqlConnectTypes, obConnectTypes]); return ( (null); const obConnectTypes = getAllConnectTypes(IDataSourceType.OceanBase); const mysqlConnectTypes = getAllConnectTypes(IDataSourceType.MySQL); + const dorisConnectTypes = getAllConnectTypes(IDataSourceType.Doris); const oracleConnectTypes = getAllConnectTypes(IDataSourceType.Oracle); const batchImportRef = useRef<{ @@ -142,6 +143,28 @@ const NewDatasourceButton: React.FC<{ } if (oracleConnectTypes?.length) { } + if (dorisConnectTypes?.length) { + results.push({ + type: 'divider', + }); + results = results.concat( + dorisConnectTypes.map((item) => { + return { + label: ConnectTypeText[item], + key: item, + icon: ( + + ), + }; + }), + ); + } if (!haveOCP()) { results.push({ type: 'divider', diff --git a/src/svgr/database_doris.svg b/src/svgr/database_doris.svg new file mode 100644 index 000000000..c9e978099 --- /dev/null +++ b/src/svgr/database_doris.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/svgr/doris.svg b/src/svgr/doris.svg new file mode 100644 index 000000000..c9e978099 --- /dev/null +++ b/src/svgr/doris.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 9dceb4cb9404b64dd48ba9a3b8abb9cf882da1bd Mon Sep 17 00:00:00 2001 From: ISADBA Date: Mon, 5 Feb 2024 19:34:49 +0800 Subject: [PATCH 2/3] update support TaskType --- src/common/datasource/doris/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/common/datasource/doris/index.tsx b/src/common/datasource/doris/index.tsx index 7c2f694e2..fe8792c77 100644 --- a/src/common/datasource/doris/index.tsx +++ b/src/common/datasource/doris/index.tsx @@ -69,9 +69,7 @@ const items: Record = { features: { task: [ TaskType.ASYNC, - TaskType.DATAMOCK, TaskType.SQL_PLAN, - TaskType.DATA_ARCHIVE, TaskType.DATA_DELETE, TaskType.IMPORT, TaskType.EXPORT, From 03af7adb2e28e6fed350e411f03521c02e04ed78 Mon Sep 17 00:00:00 2001 From: ISADBA Date: Mon, 5 Feb 2024 19:40:04 +0800 Subject: [PATCH 3/3] remote debug info --- src/component/AddDataSourceDropdown/index.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/component/AddDataSourceDropdown/index.tsx b/src/component/AddDataSourceDropdown/index.tsx index 61bcede8b..c3b42e727 100644 --- a/src/component/AddDataSourceDropdown/index.tsx +++ b/src/component/AddDataSourceDropdown/index.tsx @@ -49,10 +49,6 @@ export default function AddDataSourceDropdown(props: IProps) { key: t, }); }); - result.push({ - type: 'divider', - }); - console.log(123) result.push({ label: formatMessage({ id: 'odc.src.component.AddDataSourceDropdown.BatchImport',