You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "haizhou-zhao (via GitHub)" <gi...@apache.org> on 2023/08/14 16:53:11 UTC

[GitHub] [iceberg] haizhou-zhao opened a new issue, #8321: [JDBC Catalog on PostgreSQL] Undesired query result from namespace with underscore in the name

haizhou-zhao opened a new issue, #8321:
URL: https://github.com/apache/iceberg/issues/8321

   ### Apache Iceberg version
   
   1.2.1
   
   ### Query engine
   
   None
   
   ### Please describe the bug 🐞
   
   In JDBC Catalog, get namespace query with performed using SQL's "like" statement:
   
   Reference: https://github.com/apache/iceberg/blob/master/core/src/main/java/org/apache/iceberg/jdbc/JdbcUtil.java#L129
   
   However, the namespace names are not escaped (treated as string literal), and therefore could be incorrectly treated as a regex string and produce undesired query result.
   
   For example, the following step could trigger this issue on JDBC Catalog backed by PostgreSQL engine:
   
   1. create 200 namespaces with name `my_ns_1_1`, `my_ns_2_1`, ..., `my_ns_200_1`
   2. create `my_ns_1_2`, this will fail
   
   Reason:
   When JDBC Catalog create namespace, it will check if the namespace already exist. When checking whether `my_ns_1_2` exists, the SQL statement runs against PostgreSQL and the result is:
   ```
   iceberg=> select table_namespace from iceberg_tables where catalog_name = 'jdbc' and table_namespace like 'my_ns_1_2%' limit 1;
     table_namespace   
   --------------------
      my_ns_112_1
   (1 row)
   ```
   Here, against our intention, the string `my_ns_1_2` is treated as a regex by PostgreSQL, instead of a string literal.
   
   Suggested solution:
   When querying with SQL "like" statement, regex key characters have to be escaped, such as `'%'` and `'_'`.


-- 
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: issues-unsubscribe@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] RussellSpitzer commented on issue #8321: [JDBC Catalog on PostgreSQL] Undesired query result from namespace with underscore in the name

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on issue #8321:
URL: https://github.com/apache/iceberg/issues/8321#issuecomment-1677728115

   I do not know of anyone on our side using JDBC Catalog


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] [JDBC Catalog on PostgreSQL] Undesired query result from namespace with underscore in the name [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar closed issue #8321: [JDBC Catalog on PostgreSQL] Undesired query result from namespace with underscore in the name
URL: https://github.com/apache/iceberg/issues/8321


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] dramaticlly commented on issue #8321: [JDBC Catalog on PostgreSQL] Undesired query result from namespace with underscore in the name

Posted by "dramaticlly (via GitHub)" <gi...@apache.org>.
dramaticlly commented on issue #8321:
URL: https://github.com/apache/iceberg/issues/8321#issuecomment-1677720627

   @ismailsimsek @rdblue @nastra wondering if you guys ever running into similar problems?


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] dramaticlly commented on issue #8321: [JDBC Catalog on PostgreSQL] Undesired query result from namespace with underscore in the name

Posted by "dramaticlly (via GitHub)" <gi...@apache.org>.
dramaticlly commented on issue #8321:
URL: https://github.com/apache/iceberg/issues/8321#issuecomment-1677783572

   unit test repro in TestJdbcCatalog.java
   
   ```java
     @Test
     public void testCreateNamespace() {
       Namespace testNamespace = Namespace.of("testDb");
       assertThat(catalog.namespaceExists(testNamespace)).isFalse();
       // Test with no metadata
       catalog.createNamespace(testNamespace);
       assertThat(catalog.namespaceExists(testNamespace)).isTrue();
   
       Namespace underscore = Namespace.of("test_b");
       assertThat(catalog.namespaceExists(underscore))
               .as("Should false to namespace doesn't exist")
               .isFalse();
     }
   ```


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org