-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][Clickhouse] Support sink savemode #8086
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @zhangshenghang ! Looks great!
options.put("username", readonlyConfig.get(USERNAME)); | ||
options.put("password", readonlyConfig.get(PASSWORD)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not put username/password into options.
@@ -63,6 +63,7 @@ public class ClickhouseSinkWriter | |||
this.proxy = new ClickhouseProxy(option.getShardMetadata().getDefaultShard().getNode()); | |||
this.shardRouter = new ShardRouter(proxy, option.getShardMetadata()); | |||
this.statementMap = initStatementMap(); | |||
System.out.println(123); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert.
if (tableSchema.getPrimaryKey() != null) { | ||
primaryKey = | ||
tableSchema.getPrimaryKey().getColumnNames().stream() | ||
.map(r -> "`" + r + "`") | ||
.collect(Collectors.joining(",")); | ||
} | ||
String uniqueKey = ""; | ||
if (!tableSchema.getConstraintKeys().isEmpty()) { | ||
uniqueKey = | ||
tableSchema.getConstraintKeys().stream() | ||
.flatMap(c -> c.getColumnNames().stream()) | ||
.map(r -> "`" + r.getColumnName() + "`") | ||
.collect(Collectors.joining(",")); | ||
} | ||
SqlTemplate.canHandledByTemplateWithPlaceholder( | ||
template, | ||
SaveModePlaceHolder.ROWTYPE_PRIMARY_KEY.getPlaceHolder(), | ||
primaryKey, | ||
TablePath.of(database, table).getFullName(), | ||
ClickhouseConfig.SAVE_MODE_CREATE_TEMPLATE.key()); | ||
template = | ||
template.replaceAll( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about put template parse into common module? Not only one connector use same logic.
|
||
public class CreateTableParser { | ||
|
||
private static final Pattern COLUMN_PATTERN = Pattern.compile("`?(\\w+)`?\\s*([\\w|\\W]*)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Purpose of this pull request
close #8060
Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide
release-note
.