Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-21572

USE DATABASE & USE CATALOG fails with quoted identifiers containing characters to be escaped in Flink SQL client.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 1.12.0, 1.12.1
    • None
    • Table SQL / Client
    • None

    Description

      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. 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
       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);
           }

      Attachments

        1. image-2021-03-03-10-38-27-341.png
          19 kB
          Xiaoguang Sun
        2. image-2021-03-03-10-38-59-521.png
          19 kB
          Xiaoguang Sun

        Issue Links

          Activity

            People

              Unassigned Unassigned
              xexplorer Xiaoguang Sun
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: