-
Notifications
You must be signed in to change notification settings - Fork 3k
JDBC catalog fix namespaceExists check #8340
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
JDBC catalog fix namespaceExists check #8340
Conversation
4e19e0b to
c2dedf0
Compare
dramaticlly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @ismailsimsek for the fix!
dramaticlly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
@rdblue @nastra @jackye1995 can you help review the change for JDBC bug fix #8321 ? |
amogh-jahagirdar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR @ismailsimsek and sorry for the delay on reviewing this, it looks like the issue was reported again #8832 . I think we would want to get rid of the pattern based "LIKE" search though. I'd expect getNamespace should always be an exact lookup based on the specified name. What are your thoughts? @ismailsimsek @dramaticlly @nastra
|
@ismailsimsek it looks like this has unnecessary changes and refactors quite a bit. Can you revert the unnecessary changes and add to the PR description how this solves the problem? Thank you! |
bfbd41e to
2046a40
Compare
|
@rdblue @dramaticlly resolved the issue with pure sql, and rolled back previous changes. could you please review it again? |
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
Outdated
Show resolved
Hide resolved
| assertThat(catalog.namespaceExists(Namespace.of("testDb."))).isFalse(); | ||
| assertThat(catalog.namespaceExists(Namespace.of("testDb.ns"))).isFalse(); | ||
| assertThat(catalog.namespaceExists(Namespace.of("testDb.ns_"))).isFalse(); | ||
| assertThat(catalog.namespaceExists(Namespace.of("testDb%"))).isFalse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these false cases, can you run them twice? Once like this and once with a namespace that would match if the special character were not escaped.
|
Thanks, @ismailsimsek! Looks a lot better now. I like the new fix using ESCAPE. I think we just need to have more test cases now. |
| + " ( " | ||
| + TABLE_NAMESPACE | ||
| + " LIKE ? LIMIT 1"; | ||
| + " = ? OR " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for separate out for both equality check and prefix check with escape.
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
Outdated
Show resolved
Hide resolved
| assertThat(catalog.namespaceExists(testNamespace)).isTrue(); | ||
| assertThat(catalog.namespaceExists(Namespace.of("test.Db", "ns1"))).isTrue(); | ||
| // TODO FIX handle Dot (its namespace SEPERATOR)? in the namespace levels. currently its | ||
| // accepted and threaded as a level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what problem you're referring to, but in general Iceberg avoids needing to escape the . character by mandating that ambiguous names are not allowed. That is, you can either have ["a", "b"] -> "a.b" or ["a.b"] -> "a.b" but you can't have both objects since they have a conflicting name ("a.b"). This is how many places work, including column indexing, and no one ever has a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @rdblue , I didn't know this as well. Is this mandate come from implementation of createNamespace() method? Trying to understand how it was enforced
rdblue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than the test cases for . that I think should be removed.
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
Outdated
Show resolved
Hide resolved
amogh-jahagirdar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits., thanks @ismailsimsek for following up on this. From a testing perspective, it looks like you're covering all the cases so thanks for adding all those.
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
Outdated
Show resolved
Hide resolved
|
@rdblue @amogh-jahagirdar can you take another look? I think it's awesome if we can merge this fix. |
amogh-jahagirdar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patience and follow through on this PR @ismailsimsek , from my side everything looks good. I'll hold if @rdblue has any comments before merging
|
Merging, thanks again for this fix @ismailsimsek and your follow-through. Thanks for reviews @dramaticlly @nastra @rdblue |
…he#8340) * JDBC catalog fix namespaceExists check * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Split tests to testCreateNamespaceWithSpecialCharacter * Organize and split testCreateNamespace tests * Removed test with `.`, and extended testCreateNamespaceWithBackslashCharacter * Add review improvements (cherry picked from commit 11608e1)
|
Thank you all for reviewing it, @amogh-jahagirdar should we also merge it to 1.4.x branch, for next release? |
…he#8340) * JDBC catalog fix namespaceExists check * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Split tests to testCreateNamespaceWithSpecialCharacter * Organize and split testCreateNamespace tests * Removed test with `.`, and extended testCreateNamespaceWithBackslashCharacter * Add review improvements
…he#8340) * JDBC catalog fix namespaceExists check * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Split tests to testCreateNamespaceWithSpecialCharacter * Organize and split testCreateNamespace tests * Removed test with `.`, and extended testCreateNamespaceWithBackslashCharacter * Add review improvements
…he#8340) * JDBC catalog fix namespaceExists check * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Improve testCreateNamespace test * Split tests to testCreateNamespaceWithSpecialCharacter * Organize and split testCreateNamespace tests * Removed test with `.`, and extended testCreateNamespaceWithBackslashCharacter * Add review improvements
resolves #8321
Currently checking
testDbandtest_bwith sql LIKE clause will return true for both even when second namespace is not exists._,%characters in namespace causing issue, which should be escaped.Extended Query to Escape {
\,_,%} special characters withLIKE {pattern} ESCAPE '\'clauseThe ESCAPE statement is supported by all major Databases: