Xiaoguang Sun created FLINK-21572:
-------------------------------------
Summary: USE DATABASE & USE CATALOG fails with quoted identifiers containing characters to be escaped in Flink SQL client.
Key: FLINK-21572
URL:
https://issues.apache.org/jira/browse/FLINK-21572 Project: Flink
Issue Type: Bug
Components: Table SQL / Client
Affects Versions: 1.12.1, 1.12.0
Reporter: Xiaoguang Sun
Attachments: image-2021-03-03-10-38-27-341.png, image-2021-03-03-10-38-59-521.png
SQL Client fails when catalog name or database name are quoted and contains characters that must be escaped, for example pulsar-flink connector uses `tenant/namespace` as database name.
It was introduced with [PR Flink 18621|
https://github.com/apache/flink/pull/12923]. The reason is that sql statements restored from parsed sql operation were not quote even if user actually used it. It can be easily fixed by escaping database name and catalog name before using it. Like these
{code:java}
// code java
public class SqlUseCatalog extends SqlCall {
@@ -63,6 +65,6 @@ public class SqlUseCatalog extends SqlCall {
}
public String catalogName() {
- return catalogName.getSimple();
+ return escapeIdentifier(catalogName.getSimple());
}
}
@@ -57,7 +59,9 @@ public class SqlUseDatabase extends SqlCall {
}
public String[] fullDatabaseName() {
- return databaseName.names.toArray(new String[0]);
+ return databaseName.names.stream()
+ .map(EncodingUtils::escapeIdentifier)
+ .toArray(String[]::new);
}{code}
!image-2021-03-03-10-38-59-521.png!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)