Skip to content

Commit eb0ec92

Browse files
authored
Merge pull request #252 from qianmoQ/1.22.0-SNAPSHOT
New Feature for support some table engine
2 parents e0668f2 + b8a609d commit eb0ec92

9 files changed

Lines changed: 265 additions & 70 deletions

File tree

src/renderer/assets/i18n/en.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@
235235
"sqlite": "The engine allows to import and export data to SQLite and supports queries to SQLite tables directly from ClickHouse.",
236236
"odbc": "Allows ClickHouse to connect to external databases via ODBC",
237237
"mongodb": "MongoDB engine is read-only table engine which allows to read data (SELECT queries) from remote MongoDB collection. Engine supports only non-nested data types. INSERT queries are not supported.",
238-
"default": "Default table engine"
238+
"default": "Default table engine",
239+
"mysql": "The MySQL engine allows you to perform SELECT and INSERT queries on data that is stored on a remote MySQL server."
239240
},
240241
"property": {
241242
"timeSeconds": "Retention time in RAM (unit per second)",
@@ -305,5 +306,15 @@
305306
},
306307
"formatter": {
307308
"migrate_data": "Need to migrate {0} data, please confirm whether to migrate?"
309+
},
310+
"engine": {
311+
"table": {
312+
"hive": {
313+
"description": "The Hive engine allows you to perform SELECT quries on HDFS Hive table.",
314+
"uri": "Hive Metastore address, egg: thrift://host:port",
315+
"database": "Remote database name",
316+
"table": "Remote table name"
317+
}
318+
}
308319
}
309320
}

src/renderer/assets/i18n/zh.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@
236236
"sqlite": "The engine allows to import and export data to SQLite and supports queries to SQLite tables directly from ClickHouse.",
237237
"odbc": "Allows ClickHouse to connect to external databases via ODBC",
238238
"mongodb": "MongoDB engine is read-only table engine which allows to read data (SELECT queries) from remote MongoDB collection. Engine supports only non-nested data types. INSERT queries are not supported.",
239-
"default": "默认表引擎"
239+
"default": "默认表引擎",
240+
"mysql": "The MySQL engine allows you to perform SELECT and INSERT queries on data that is stored on a remote MySQL server."
240241
},
241242
"property": {
242243
"timeSeconds": "Retention time in RAM (unit per second)",
@@ -306,5 +307,15 @@
306307
},
307308
"formatter": {
308309
"migrate_data": "需要迁移{0}条数据, 请确认是否迁移?"
310+
},
311+
"engine": {
312+
"table": {
313+
"hive": {
314+
"description": "The Hive engine allows you to perform SELECT quries on HDFS Hive table.",
315+
"uri": "Hive Metastore address, egg: thrift://host:port",
316+
"database": "Remote database name",
317+
"table": "Remote table name"
318+
}
319+
}
309320
}
310321
}

src/renderer/components/table/create/table.create.component.html

Lines changed: 108 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -37,78 +37,119 @@
3737
<div [nzSpan]="24" nz-col>
3838
</div>
3939
<div [nzSpan]="24" nz-col>
40-
<form nz-form>
41-
<nz-divider nzOrientation="left" nzPlain nzText="{{'common.basic'|translate}}"></nz-divider>
42-
<nz-form-item>
43-
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.engine'|translate}}</nz-form-label>
44-
<nz-form-control [nzSm]="14" [nzXs]="24">
45-
<nz-tag [nzColor]="'#2db7f5'">{{configure.type}}</nz-tag>
46-
</nz-form-control>
47-
</nz-form-item>
48-
<nz-form-item>
49-
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.name'|translate}}</nz-form-label>
50-
<nz-form-control [nzSm]="14" [nzXs]="24">
51-
<input (change)="handlerValidate()" [(ngModel)]="configure.targetName" name="name" nz-input type="text"/>
52-
</nz-form-control>
53-
</nz-form-item>
54-
55-
<nz-divider nzOrientation="left" nzPlain nzText="{{'common.column'|translate}}"></nz-divider>
56-
<div nz-row [nzGutter]="[4, 8]">
57-
<nz-form-item *ngFor="let column of columns; let i = index">
58-
<nz-form-control>
59-
<div nz-row [nzGutter]="[4, 8]">
60-
<div [nzSpan]="2" nz-col>
61-
<button nz-button nzType="primary" nzDanger nzShape="circle" nz-tooltip
62-
nzTooltipTitle="{{'common.delete'|translate}}" (click)="handlerRemoveColumn(column)">
63-
<i class="fa fa-trash"></i>
40+
<form nz-form style="margin-top: 10px;">
41+
<nz-tabset nzAnimated="false">
42+
<!-- Basic Settings -->
43+
<nz-tab [nzTitle]="basicSettingTemplate">
44+
<ng-template #basicSettingTemplate>
45+
<i nz-icon nzType="build"></i>
46+
{{'common.basic'|translate}}
47+
</ng-template>
48+
<nz-form-item>
49+
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.engine'|translate}}</nz-form-label>
50+
<nz-form-control [nzSm]="14" [nzXs]="24">
51+
<nz-tag [nzColor]="'#2db7f5'">{{configure.type}}</nz-tag>
52+
</nz-form-control>
53+
</nz-form-item>
54+
<nz-form-item>
55+
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.name'|translate}}</nz-form-label>
56+
<nz-form-control [nzSm]="14" [nzXs]="24">
57+
<input (change)="handlerValidateStep('Basic')" [(ngModel)]="configure.targetName" name="name" nz-input
58+
type="text"/>
59+
</nz-form-control>
60+
</nz-form-item>
61+
</nz-tab>
62+
<!-- Column Settings -->
63+
<nz-tab [nzDisabled]="!validated.basic" [nzTitle]="columnSettingTemplate">
64+
<ng-template #columnSettingTemplate>
65+
<i nz-icon nzType="delete-column"></i>
66+
{{'common.column'|translate}}
67+
</ng-template>
68+
<div nz-row [nzGutter]="[4, 8]">
69+
<nz-form-item *ngFor="let column of columns; let i = index">
70+
<nz-form-control>
71+
<div nz-row [nzGutter]="[4, 8]">
72+
<div [nzSpan]="2" nz-col>
73+
<button nz-button nzType="primary" nzDanger nzShape="circle" nz-tooltip
74+
nzTooltipTitle="{{'common.delete'|translate}}" (click)="handlerRemoveColumn(column)">
75+
<i class="fa fa-trash"></i>
76+
</button>
77+
</div>
78+
<div [nzSpan]="8" nz-col>
79+
<input [(ngModel)]="column.name" nz-input type="text" [ngModelOptions]="{standalone: true}"
80+
placeholder="{{'common.column'|translate}}{{'common.name'|translate}}"
81+
(ngModelChange)="handlerValidateStep('Column')" style="width: 100%;"/>
82+
</div>
83+
<div [nzSpan]="6" nz-col>
84+
<nz-select [(ngModel)]="column.type" [ngModelOptions]="{standalone: true}"
85+
style="width: 130px;">
86+
<nz-option nzValue="{{type}}" nzLabel="{{type}}" *ngFor="let type of columnTypes"></nz-option>
87+
</nz-select>
88+
</div>
89+
<div [nzSpan]="6" nz-col>
90+
<input [(ngModel)]="column.description" nz-input type="text"
91+
[ngModelOptions]="{standalone: true}"/>
92+
</div>
93+
<div [nzSpan]="2" nz-col>
94+
<nz-switch nz-tooltip nzTooltipTitle="{{'common.nullable'|translate}}?"
95+
[(ngModel)]="column.empty"
96+
[ngModelOptions]="{standalone: true}">
97+
</nz-switch>
98+
</div>
99+
</div>
100+
</nz-form-control>
101+
</nz-form-item>
102+
<nz-form-item [nzSpan]="24" nz-col>
103+
<nz-form-control>
104+
<button nz-button nzType="dashed" (click)="handlerAddColumn()" nz-tooltip
105+
nzTooltipTitle="{{'common.add'|translate}}">
106+
<i class="fa fa-plus"></i>
64107
</button>
65-
</div>
66-
<div [nzSpan]="8" nz-col>
67-
<input [(ngModel)]="column.name" nz-input type="text" [ngModelOptions]="{standalone: true}"
68-
placeholder="{{'common.column'|translate}}{{'common.name'|translate}}" style="width: 100%;"/>
69-
</div>
70-
<div [nzSpan]="6" nz-col>
71-
<nz-select [(ngModel)]="column.type" [ngModelOptions]="{standalone: true}" style="width: 130px;">
72-
<nz-option nzValue="{{type}}" nzLabel="{{type}}" *ngFor="let type of columnTypes"></nz-option>
73-
</nz-select>
74-
</div>
75-
<div [nzSpan]="6" nz-col>
76-
<input [(ngModel)]="column.description" nz-input type="text"
77-
[ngModelOptions]="{standalone: true}"/>
78-
</div>
79-
<div [nzSpan]="2" nz-col>
80-
<nz-switch nz-tooltip nzTooltipTitle="{{'common.nullable'|translate}}?" [(ngModel)]="column.empty"
81-
[ngModelOptions]="{standalone: true}">
82-
</nz-switch>
83-
</div>
84-
</div>
85-
</nz-form-control>
86-
</nz-form-item>
87-
<nz-form-item [nzSpan]="24" nz-col>
88-
<nz-form-control>
89-
<button nz-button nzType="dashed" (click)="handlerAddColumn()" nz-tooltip
90-
nzTooltipTitle="{{'common.add'|translate}}">
91-
<i class="fa fa-plus"></i>
92-
</button>
93-
</nz-form-control>
94-
</nz-form-item>
95-
</div>
96-
97-
<div *ngIf="configure.properties?.length > 0">
98-
<nz-divider nzOrientation="left" nzPlain nzText="{{'common.property'|translate}}"></nz-divider>
99-
<app-component-property [properties]="configure.properties" [experimental]="configure.experimental"
100-
(emitter)="handlerComponentEmitter($event, true)">
101-
</app-component-property>
102-
</div>
103-
104-
<nz-collapse nzAccordion *ngIf="configure.optionalProperties?.length > 0">
105-
<nz-collapse-panel nzHeader="{{'common.property'|translate}} [{{'common.optional'|translate}}]">
108+
</nz-form-control>
109+
</nz-form-item>
110+
</div>
111+
</nz-tab>
112+
<!-- Properties Settings -->
113+
<nz-tab *ngIf="configure.properties?.length > 0" [nzDisabled]="!validated.column"
114+
[nzTitle]="propertySettingTemplate">
115+
<ng-template #propertySettingTemplate>
116+
<i nz-icon nzType="property-safety"></i>
117+
{{'common.property'|translate}}
118+
</ng-template>
119+
<app-component-property [properties]="configure.properties" [experimental]="configure.experimental"
120+
(emitter)="handlerComponentEmitter($event, true)">
121+
</app-component-property>
122+
</nz-tab>
123+
<!-- Properties[Optional] Settings -->
124+
<nz-tab *ngIf="configure.optionalProperties?.length> 0" [nzTitle]="propertyOptionalSettingTemplate">
125+
<ng-template #propertyOptionalSettingTemplate>
126+
<i nz-icon nzType="property-safety"></i>
127+
{{'common.property'|translate}}
128+
</ng-template>
106129
<app-component-property [properties]="configure.optionalProperties"
107130
[experimental]="configure.experimental"
108131
(emitter)="handlerComponentEmitter($event, false)">
109132
</app-component-property>
110-
</nz-collapse-panel>
111-
</nz-collapse>
133+
</nz-tab>
134+
<!-- Partition Settings -->
135+
<nz-tab *ngIf="configure.partitionConfigure?.enable" [nzDisabled]="!validated.property"
136+
[nzTitle]="partitionSettingTemplate">
137+
<ng-template #partitionSettingTemplate>
138+
<i nz-icon nzType="partition"></i>
139+
{{'common.partition'|translate}}
140+
</ng-template>
141+
<nz-form-item>
142+
<nz-form-label [nzSm]="6" [nzXs]="24">{{'common.column'|translate}}</nz-form-label>
143+
<nz-form-control [nzSm]="14" [nzXs]="24">
144+
<nz-select nzMode="multiple" [(ngModel)]="configure.partitionConfigure.columns"
145+
[ngModelOptions]="{standalone: true}">
146+
<nz-option *ngFor="let column of columns" [nzLabel]="column.name"
147+
[nzValue]="column.name"></nz-option>
148+
</nz-select>
149+
</nz-form-control>
150+
</nz-form-item>
151+
</nz-tab>
152+
</nz-tabset>
112153
</form>
113154
</div>
114155
</div>

src/renderer/components/table/create/table.create.component.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export class CreateTableComponent extends BaseComponent implements AfterViewInit
2828
selectValue: string;
2929
columns: ColumnModel[] = new Array();
3030
columnTypes: string[] = new Array();
31+
validated = {
32+
basic: false,
33+
column: false,
34+
property: false
35+
}
3136

3237
constructor(private tableService: TableService,
3338
private dataSourceService: DatasourceService,
@@ -71,6 +76,30 @@ export class CreateTableComponent extends BaseComponent implements AfterViewInit
7176
this.configure = cloneDeep(value);
7277
}
7378

79+
handlerValidateStep(step: string) {
80+
switch (step) {
81+
case 'Basic':
82+
if (StringUtils.isNotEmpty(this.configure.targetName)) {
83+
this.validated.basic = true;
84+
} else {
85+
this.validated.basic = false;
86+
}
87+
break;
88+
case 'Column':
89+
const emptyCount = this.columns.filter(column => StringUtils.isEmpty(column.name)).length;
90+
if (emptyCount === 0) {
91+
this.validated.column = true;
92+
} else {
93+
this.validated.column = false;
94+
}
95+
break;
96+
case 'Property':
97+
this.validated.property = this.configure.validate;
98+
break;
99+
}
100+
this.handlerValidate();
101+
}
102+
74103
handlerValidate() {
75104
let flag;
76105
if (this.configure.validate != undefined) {
@@ -107,7 +136,7 @@ export class CreateTableComponent extends BaseComponent implements AfterViewInit
107136
} else {
108137
this.configure.optionalProperties = $event.properties;
109138
}
110-
this.handlerValidate();
139+
this.handlerValidateStep('Property');
111140
}
112141

113142
handlerPrevious(): void {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { PropertyModel } from "@renderer/model/property.model";
2+
import { TranslateUtils } from "@renderer/utils/translate.utils";
3+
import { DatabaseModel } from "@renderer/model/database.model";
4+
import { DatabaseEnum } from "@renderer/enum/database.enum";
5+
import { PropertyEnum } from "@renderer/enum/property.enum";
6+
7+
const hiveProperties = new Array();
8+
hiveProperties.push(PropertyModel.builder('uri',
9+
TranslateUtils.getValue('common.uri'),
10+
TranslateUtils.getValue('engine.table.hive.uri'),
11+
TranslateUtils.getValue('engine.table.hive.uri'),
12+
null,
13+
false,
14+
true));
15+
hiveProperties.push(PropertyModel.builder('database',
16+
TranslateUtils.getValue('common.database'),
17+
TranslateUtils.getValue('engine.table.hive.database'),
18+
TranslateUtils.getValue('engine.table.hive.database'),
19+
null,
20+
false));
21+
hiveProperties.push(PropertyModel.builder('table',
22+
TranslateUtils.getValue('common.table'),
23+
TranslateUtils.getValue('engine.table.hive.table'),
24+
TranslateUtils.getValue('engine.table.hive.table'),
25+
null,
26+
false));
27+
const HiveTableEngine = DatabaseModel.builder(DatabaseEnum.hive.toString(),
28+
TranslateUtils.getValue('engine.table.hive.description'),
29+
DatabaseEnum.hive,
30+
hiveProperties,
31+
false,
32+
PropertyEnum.name);
33+
34+
HiveTableEngine.partitionConfigure.enable = true;
35+
HiveTableEngine.supportedSource = [DatabaseEnum.clickhosue];
36+
37+
export { HiveTableEngine };

src/renderer/config/table.config.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { StringUtils } from '@renderer/utils/string.utils';
55
import { TranslateUtils } from '@renderer/utils/translate.utils';
66
import { PropertyModel } from '@renderer/model/property.model';
77
import { PropertyEnum } from '@renderer/enum/property.enum';
8+
import { HiveTableEngine } from "@renderer/config/engine/table/engine.table.hive.config";
89

910
@Injectable()
1011
export class TableConfig {
@@ -258,6 +259,53 @@ export class TableConfig {
258259
mongodb.supportedSource = [DatabaseEnum.clickhosue];
259260
integrationEngines.push(mongodb);
260261

262+
// MySQL
263+
const mysqlProperties = new Array();
264+
mysqlProperties.push(PropertyModel.builder('uri',
265+
TranslateUtils.getValue('common.uri'),
266+
TranslateUtils.getValue('placeholder.uri'),
267+
TranslateUtils.getValue('tooltip.property.mongodb.uri'),
268+
null,
269+
false,
270+
true));
271+
mysqlProperties.push(PropertyModel.builder('database',
272+
TranslateUtils.getValue('common.database'),
273+
TranslateUtils.getValue('placeholder.database'),
274+
TranslateUtils.getValue('tooltip.property.database'),
275+
null,
276+
false));
277+
mysqlProperties.push(PropertyModel.builder('table',
278+
TranslateUtils.getValue('common.table'),
279+
TranslateUtils.getValue('placeholder.table'),
280+
TranslateUtils.getValue('tooltip.property.table'),
281+
null,
282+
false));
283+
mysqlProperties.push(PropertyModel.builder('username',
284+
TranslateUtils.getValue('common.username'),
285+
TranslateUtils.getValue('tooltip.property.username'),
286+
TranslateUtils.getValue('tooltip.property.username'),
287+
null,
288+
false,
289+
true));
290+
mysqlProperties.push(PropertyModel.builder('password',
291+
TranslateUtils.getValue('common.password'),
292+
TranslateUtils.getValue('tooltip.property.password'),
293+
TranslateUtils.getValue('tooltip.property.password'),
294+
null,
295+
false,
296+
true));
297+
const mysql = DatabaseModel.builder(DatabaseEnum.mysql.toString(),
298+
TranslateUtils.getValue('tooltip.table.mysql'),
299+
DatabaseEnum.mysql,
300+
mysqlProperties,
301+
false,
302+
PropertyEnum.name);
303+
mysql.supportedSource = [DatabaseEnum.clickhosue];
304+
integrationEngines.push(mysql);
305+
306+
// Hive
307+
integrationEngines.push(HiveTableEngine);
308+
261309
integrationTable.engines = integrationEngines;
262310
tableEngines.push(integrationTable);
263311
return tableEngines;

src/renderer/enum/database.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export enum DatabaseEnum {
1616
sqlite = 'SQLite',
1717
odbc = 'ODBC',
1818
mongodb = 'MongoDB',
19+
hive = 'Hive',
1920

2021
// DataSource Type
2122
clickhosue = 'ClickHouse',

0 commit comments

Comments
 (0)