Skip to content
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

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

zhangshenghang
Copy link
Member

@zhangshenghang zhangshenghang commented Nov 19, 2024

Purpose of this pull request

close #8060

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

Copy link
Member

@Hisoka-X Hisoka-X left a 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!

Comment on lines +202 to +203
options.put("username", readonlyConfig.get(USERNAME));
options.put("password", readonlyConfig.get(PASSWORD));
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert.

Comment on lines +43 to +64
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(
Copy link
Member

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]*)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature][Clickhouse] Support sink savemode
2 participants