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

Added logic to OVERRIDE CREATE DATABASE SQL #653

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added table name to exception logs when there is a column mismatch
  • Loading branch information
subkanthi committed Jun 23, 2024
commit f6953691b6c5feccbcda931d777914599b84a5a0
Original file line number Diff line number Diff line change
@@ -138,17 +138,17 @@ private boolean executePreparedStatement(String insertQuery, String topicName,

if (CdcRecordState.CDC_RECORD_STATE_BEFORE == getCdcSectionBasedOnOperation(record.getCdcOperation())) {
insertPreparedStatement(entry.getKey().right, ps, record.getBeforeModifiedFields(), record, record.getBeforeStruct(),
true, config, columnToDataTypeMap, engine);
true, config, columnToDataTypeMap, engine, tableName);
} else if (CdcRecordState.CDC_RECORD_STATE_AFTER == getCdcSectionBasedOnOperation(record.getCdcOperation())) {
insertPreparedStatement(entry.getKey().right, ps, record.getAfterModifiedFields(), record, record.getAfterStruct(),
false, config, columnToDataTypeMap, engine);
false, config, columnToDataTypeMap, engine, tableName);
} else if (CdcRecordState.CDC_RECORD_STATE_BOTH == getCdcSectionBasedOnOperation(record.getCdcOperation())) {
if (engine != null && engine.getEngine().equalsIgnoreCase(DBMetadata.TABLE_ENGINE.COLLAPSING_MERGE_TREE.getEngine())) {
insertPreparedStatement(entry.getKey().right, ps, record.getBeforeModifiedFields(), record, record.getBeforeStruct(),
true, config, columnToDataTypeMap, engine);
true, config, columnToDataTypeMap, engine, tableName);
}
insertPreparedStatement(entry.getKey().right, ps, record.getAfterModifiedFields(), record, record.getAfterStruct(),
false, config, columnToDataTypeMap, engine);
false, config, columnToDataTypeMap, engine, tableName);
} else {
log.error("INVALID CDC RECORD STATE");
}
@@ -205,7 +205,7 @@ public void insertPreparedStatement(Map<String, Integer> columnNameToIndexMap, P
ClickHouseStruct record, Struct struct, boolean beforeSection,
ClickHouseSinkConnectorConfig config,
Map<String, String> columnNameToDataTypeMap,
DBMetadata.TABLE_ENGINE engine) throws Exception {
DBMetadata.TABLE_ENGINE engine, String tableName) throws Exception {


// int index = 1;
@@ -247,11 +247,12 @@ public void insertPreparedStatement(Map<String, Integer> columnNameToIndexMap, P
// if the field is not present.
// If the record was not supplied, we need to set it as null.
// Ignore version and sign columns.
if(colName.equalsIgnoreCase(versionColumn) || colName.equalsIgnoreCase(signColumn)) {
if(colName.equalsIgnoreCase(versionColumn) || colName.equalsIgnoreCase(signColumn) ||
colName.equalsIgnoreCase(replacingMergeTreeDeleteColumn)) {

} else {
log.error(String.format("********** ERROR: Database(%s), ClickHouse column %s not present in source ************", databaseName, colName));
log.error(String.format("********** ERROR: Database(%s), Setting column %s to NULL might fail for non-nullable columns ************", databaseName, colName));
log.error(String.format("********** ERROR: Database(%s), Table(%s), ClickHouse column %s not present in source ************", databaseName, tableName, colName));
log.error(String.format("********** ERROR: Database(%s), Table(%s), Setting column %s to NULL might fail for non-nullable columns ************", databaseName, tableName, colName));
}
ps.setNull(index, Types.OTHER);
continue;
Loading