Skip to content

Conversation

@ismailsimsek
Copy link
Contributor

@ismailsimsek ismailsimsek commented Aug 16, 2023

resolves #8321

Currently checking testDb and test_b with 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 with LIKE {pattern} ESCAPE '\' clause

The ESCAPE statement is supported by all major Databases:

@github-actions github-actions bot added the core label Aug 16, 2023
@ismailsimsek ismailsimsek force-pushed the fix_jdbc_ctalog_namespace_exists branch 2 times, most recently from 4e19e0b to c2dedf0 Compare August 16, 2023 21:07
Copy link
Contributor

@dramaticlly dramaticlly left a 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!

Copy link
Contributor

@dramaticlly dramaticlly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dramaticlly
Copy link
Contributor

@rdblue @nastra @jackye1995 can you help review the change for JDBC bug fix #8321 ?

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a 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

@rdblue
Copy link
Contributor

rdblue commented Oct 20, 2023

@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!

@ismailsimsek ismailsimsek force-pushed the fix_jdbc_ctalog_namespace_exists branch from bfbd41e to 2046a40 Compare October 20, 2023 09:50
@ismailsimsek
Copy link
Contributor Author

@rdblue @dramaticlly resolved the issue with pure sql, and rolled back previous changes. could you please review it again?

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();
Copy link
Contributor

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.

@rdblue
Copy link
Contributor

rdblue commented Oct 20, 2023

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 "
Copy link
Contributor

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.

@ismailsimsek ismailsimsek requested a review from rdblue October 21, 2023 08:36
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
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

@rdblue rdblue left a 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.

@ismailsimsek
Copy link
Contributor Author

@nastra @Fokko if you have time, could you please review it too? it should be ready.

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a 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.

@dramaticlly
Copy link
Contributor

@rdblue @amogh-jahagirdar can you take another look? I think it's awesome if we can merge this fix.

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a 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

@amogh-jahagirdar
Copy link
Contributor

Merging, thanks again for this fix @ismailsimsek and your follow-through. Thanks for reviews @dramaticlly @nastra @rdblue

@amogh-jahagirdar amogh-jahagirdar merged commit 11608e1 into apache:main Dec 13, 2023
ismailsimsek added a commit to ismailsimsek/iceberg that referenced this pull request Dec 13, 2023
…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)
@ismailsimsek
Copy link
Contributor Author

Thank you all for reviewing it, @amogh-jahagirdar should we also merge it to 1.4.x branch, for next release?
created PR for it if makes sense #9291

lisirrx pushed a commit to lisirrx/iceberg that referenced this pull request Jan 4, 2024
…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
geruh pushed a commit to geruh/iceberg that referenced this pull request Jan 26, 2024
…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
devangjhabakh pushed a commit to cdouglas/iceberg that referenced this pull request Apr 22, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

5 participants