diff --git a/src/common/datasource/doris/index.tsx b/src/common/datasource/doris/index.tsx new file mode 100644 index 000000000..fe8792c77 --- /dev/null +++ b/src/common/datasource/doris/index.tsx @@ -0,0 +1,104 @@ +/* + * 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.SQL_PLAN, + 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..c3b42e727 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,12 @@ export default function AddDataSourceDropdown(props: IProps) { key: t, }); }); + dorisConnectTypes.forEach((t) => { + result.push({ + label: ConnectTypeText[t], + key: t, + }); + }); result.push({ label: formatMessage({ id: 'odc.src.component.AddDataSourceDropdown.BatchImport', @@ -49,7 +56,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