Skip to content

Commit

Permalink
Merge pull request #40 from ISADBA/baseline/dev-4.2.4
Browse files Browse the repository at this point in the history
feat(datasource): Support new datasource of Doris
  • Loading branch information
HSunboy authored Feb 5, 2024
2 parents af070a8 + 03af7ad commit cb5c09c
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 1 deletion.
104 changes: 104 additions & 0 deletions src/common/datasource/doris/index.tsx
Original file line number Diff line number Diff line change
@@ -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, IDataSourceModeConfig> = {
[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;
13 changes: 13 additions & 0 deletions src/common/datasource/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -57,6 +60,15 @@ const _styles = {
component: DBMySQLSvg,
},
},
[IDataSourceType.Doris]: {
icon: {
component: DorisSvg,
color: '#09C7F7',
},
dbIcon: {
component: DBDorisSvg,
},
},
[IDataSourceType.Oracle]: {
icon: {
component: OracleSvg,
Expand Down Expand Up @@ -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[] {
Expand Down
9 changes: 8 additions & 1 deletion src/component/AddDataSourceDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -42,14 +43,20 @@ 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',
}), //'批量导入'
key: 'batchImport',
});
return result;
}, [mysqlConnectTypes, obConnectTypes]);
}, [dorisConnectTypes,mysqlConnectTypes, obConnectTypes]);
return (
<Dropdown
menu={{
Expand Down
1 change: 1 addition & 0 deletions src/constant/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const ConnectTypeText = {
[ConnectType.CLOUD_OB_ORACLE]: 'OB Cloud Oracle',
[ConnectType.ODP_SHARDING_OB_MYSQL]: 'OB Sharding MySQL',
[ConnectType.MYSQL]: 'MySQL',
[ConnectType.DORIS]: 'Doris',
[ConnectType.ORACLE]: 'Oracle',
};

Expand Down
1 change: 1 addition & 0 deletions src/d.ts/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ export enum ConnectionPropertyType {
export enum IDataSourceType {
OceanBase = 'ob',
MySQL = 'mysql',
Doris = 'doris',
Oracle = 'oracle',
}
3 changes: 3 additions & 0 deletions src/d.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ export enum AuditEventDialectType {
OB_ORACLE = 'OB_ORACLE',
ORACLE = 'ORACLE',
MYSQL = 'MYSQL',
DORIS = 'DORIS',
UNKNOWN = 'UNKNOWN',
}

Expand Down Expand Up @@ -640,6 +641,7 @@ export type ISQLScript = IScriptMeta;

export enum ConnectionMode {
MYSQL = 'MYSQL',
DORIS = 'DORIS',
ORACLE = 'ORACLE',
OB_MYSQL = 'OB_MYSQL',
OB_ORACLE = 'OB_ORACLE',
Expand Down Expand Up @@ -2999,6 +3001,7 @@ export enum ConnectType {
CLOUD_OB_ORACLE = 'CLOUD_OB_ORACLE',
ODP_SHARDING_OB_MYSQL = 'ODP_SHARDING_OB_MYSQL',
MYSQL = 'MYSQL',
DORIS = 'DORIS',
ORACLE = 'ORACLE',
}

Expand Down
23 changes: 23 additions & 0 deletions src/page/Datasource/Datasource/NewDatasourceDrawer/NewButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const NewDatasourceButton: React.FC<{
const [type, setType] = useState<ConnectType>(null);
const obConnectTypes = getAllConnectTypes(IDataSourceType.OceanBase);
const mysqlConnectTypes = getAllConnectTypes(IDataSourceType.MySQL);
const dorisConnectTypes = getAllConnectTypes(IDataSourceType.Doris);
const oracleConnectTypes = getAllConnectTypes(IDataSourceType.Oracle);

const batchImportRef = useRef<{
Expand Down Expand Up @@ -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: (
<Icon
component={getDataSourceStyleByConnectType(item)?.icon?.component}
style={{
color: getDataSourceStyleByConnectType(item)?.icon?.color,
fontSize: '16px',
}}
/>
),
};
}),
);
}
if (!haveOCP()) {
results.push({
type: 'divider',
Expand Down
5 changes: 5 additions & 0 deletions src/svgr/database_doris.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/svgr/doris.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cb5c09c

Please sign in to comment.