morozov commented on code in PR #4014:
URL: https://github.com/apache/flink-cdc/pull/4014#discussion_r2100905842
##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-sqlserver-cdc/src/main/java/org/apache/flink/cdc/connectors/sqlserver/source/utils/SqlServerUtils.java:
##########
@@ -361,12 +361,16 @@ private static String quoteSchemaAndTable(TableId
tableId) {
return quoted.toString();
}
- public static String quote(String dbOrTableName) {
- return "[" + dbOrTableName + "]";
+ /**
+ * @link <a
+ *
href="https://learn.microsoft.com/en-us/sql/t-sql/functions/quotename-transact-sql">QUOTENAME</a>
+ */
+ public static String quote(String name) {
+ return "[" + name.replace("]", "]]") + "]";
Review Comment:
I could write a separate test for this specific function (e.g. create a
table, introspect it and confirm that the column name is what's expected), but
I cannot make Flink CDC correctly capture changes from such a table (e.g.
`customers [1]` (see the code changes:
https://github.com/morozov/flink-cdc/commit/06971c30440b5f4f53a8a2048221b7947d4fe6b8).
If I rename the test table from `customers` to `customers [1]`, the task
will fail with the following error:
> To use incremental snapshot, 'scan.incremental.snapshot.chunk.key-column'
must be set when the table doesn't have primary keys
The reason is that Debezium's `JdbcConnection#readSchema()` incorrectly
introspects the schema of the table. Specifically, it cannot find its columns.
A similar problem was fixed with introspecting table names with the backslash
in them (https://github.com/debezium/debezium/pull/4206), but introspection of
tables with other special characters in the name (which is I believe `%`, `_`,
`[` and similar) is still broken.
Alternatively, I can revert this change (although, I'm quite confident that
the modified logic is correct).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]