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

[BugFix] Fix a typo in class StarRocksDynamicSinkFunction #355

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,20 +423,20 @@ private void validateTableStructure(TableSchema flinkSchema) {
throw new IllegalArgumentException("Couldn't get the sink table's column info.");
}
// validate primary keys
List<String> primayKeys = new ArrayList<>();
List<String> primaryKeys = new ArrayList<>();
for (int i = 0; i < rows.size(); i++) {
String keysType = rows.get(i).get("COLUMN_KEY").toString();
if (!"PRI".equals(keysType)) {
continue;
}
primayKeys.add(rows.get(i).get("COLUMN_NAME").toString().toLowerCase());
primaryKeys.add(rows.get(i).get("COLUMN_NAME").toString().toLowerCase());
}
if (!primayKeys.isEmpty()) {
if (!primaryKeys.isEmpty()) {
if (!constraint.isPresent()) {
throw new IllegalArgumentException("Primary keys not defined in the sink `TableSchema`.");
}
if (constraint.get().getColumns().size() != primayKeys.size() ||
!constraint.get().getColumns().stream().allMatch(col -> primayKeys.contains(col.toLowerCase()))) {
if (constraint.get().getColumns().size() != primaryKeys.size() ||
!constraint.get().getColumns().stream().allMatch(col -> primaryKeys.contains(col.toLowerCase()))) {
throw new IllegalArgumentException("Primary keys of the flink `TableSchema` do not match with the ones from starrocks table.");
}
sinkOptions.enableUpsertDelete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public synchronized void invoke(T value, Context context) throws Exception {
if (value instanceof StarRocksSinkRowDataWithMeta) {
StarRocksSinkRowDataWithMeta data = (StarRocksSinkRowDataWithMeta)value;
if (Strings.isNullOrEmpty(data.getDatabase()) || Strings.isNullOrEmpty(data.getTable()) || null == data.getDataRows()) {
LOG.warn(String.format("json row data not fullfilled. {database: %s, table: %s, dataRows: %s}", data.getDatabase(), data.getTable(), data.getDataRows()));
LOG.warn(String.format("json row data not fulfilled. {database: %s, table: %s, dataRows: %s}", data.getDatabase(), data.getTable(), data.getDataRows()));
return;
}
sinkManager.writeRecords(data.getDatabase(), data.getTable(), data.getDataRows());
Expand Down