Skip to content

Commit 1a99574

Browse files
committed
fix: add applyDefault for clickhouse
1 parent 0f16275 commit 1a99574

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

connectors/clickhouse-connector/src/main/java/io/tapdata/connector/clickhouse/ddl/sqlmaker/ClickhouseSqlMaker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public String buildColumnDefinition(TapTable tapTable, boolean needComment) {
5252

5353

5454
//null to omit
55-
if (tapField.getDefaultValue() != null && !"".equals(tapField.getDefaultValue())) {
55+
if (Boolean.TRUE.equals(applyDefault) && tapField.getDefaultValue() != null && !"".equals(tapField.getDefaultValue())) {
5656
builder.append("DEFAULT").append(' ');
5757
if (tapField.getDefaultValue() instanceof Number) {
5858
builder.append(tapField.getDefaultValue()).append(' ');

connectors/clickhouse-connector/src/main/resources/spec_clickhouse.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,27 @@
332332
"defaultValue": { "propKey": "", "propValue": "" }
333333
}
334334
}
335+
},
336+
"applyDefault": {
337+
"type": "boolean",
338+
"title": "${applyDefault}",
339+
"default": false,
340+
"x-index": 7,
341+
"x-decorator": "FormItem",
342+
"x-component": "Switch",
343+
"x-decorator-props": {
344+
"tooltip": "${applyDefaultTooltip}"
345+
},
346+
"x-reactions": [
347+
{
348+
"dependencies": ["$inputs"],
349+
"fulfill": {
350+
"state": {
351+
"display": "{{$deps[0].length > 0 ? \"visible\":\"hidden\"}}"
352+
}
353+
}
354+
}
355+
]
335356
}
336357
},
337358
"mergeMinutes": {
@@ -408,6 +429,8 @@
408429
"mergeMinutes": "Optimize Interval (Minutes)",
409430
"mixFastWrite": "Mix Fast Write",
410431
"mixFastWriteTooltip": "Enable mix fast write, but the target table will create is_deleted, delete_time columns, insert strategy is used for insert, update, delete, greatly improve performance",
432+
"applyDefault": "Apply default value",
433+
"applyDefaultTooltip": "When the switch is turned on, the default value will be applied to the target. If there are unadapted functions or expressions, it may cause an error",
411434
"doc": "docs/clickhouse_en_US.md"
412435
},
413436
"zh_CN": {
@@ -437,6 +460,8 @@
437460
"mergeMinutes": "合并分区间隔(分钟)",
438461
"mixFastWrite": "混合快速写入",
439462
"mixFastWriteTooltip": "启用混合快速写入,但目标表会多创建is_deleted, delete_time列, 增删改统一使用插入策略大大提升性能",
463+
"applyDefault": "应用默认值",
464+
"applyDefaultTooltip": "开关打开时会将默认值应用到目标,如果有未适配的函数或表达式,可能会导致报错",
440465
"doc": "docs/clickhouse_zh_CN.md"
441466
},
442467
"zh_TW": {
@@ -466,6 +491,8 @@
466491
"mergeMinutes": "合併分區間隔(分鐘)",
467492
"mixFastWrite": "混合快速寫入",
468493
"mixFastWriteTooltip": "啟用混合快速寫入,但目標表會多創建is_deleted, delete_time列, 增刪改統一使用插入策略大大提升性能",
494+
"applyDefault": "應用默認值",
495+
"applyDefaultTooltip": "開關打開時會將默認值應用到目標,如果有未适配的函数或表达式,可能会导致报错",
469496
"doc": "docs/clickhouse_zh_TW.md"
470497
}
471498
},

0 commit comments

Comments
 (0)