Skip to content
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

SNOW-1619625: Add exact search for schema #2012

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sfc-gh-dprzybysz
Copy link
Collaborator

@sfc-gh-dprzybysz sfc-gh-dprzybysz commented Dec 19, 2024

Overview

SNOW-1619625

Pre-review self checklist

  • PR branch is updated with all the changes from master branch
  • The code is correctly formatted (run mvn -P check-style validate)
  • New public API is not unnecessary exposed (run mvn verify and inspect target/japicmp/japicmp.html)
  • The pull request name is prefixed with SNOW-XXXX:
  • Code is in compliance with internal logging requirements

@sfc-gh-dprzybysz sfc-gh-dprzybysz force-pushed the SNOW-1636286-add-exact-search-for-schema branch 2 times, most recently from bf139a8 to 27b4e8b Compare December 19, 2024 12:23
@sfc-gh-dprzybysz sfc-gh-dprzybysz force-pushed the SNOW-1636286-add-exact-search-for-schema branch 2 times, most recently from 114c4e8 to fff1aaf Compare January 9, 2025 09:12
@sfc-gh-dprzybysz sfc-gh-dprzybysz marked this pull request as ready for review January 9, 2025 11:39
@sfc-gh-dprzybysz sfc-gh-dprzybysz requested a review from a team as a code owner January 9, 2025 11:39
@sfc-gh-dprzybysz sfc-gh-dprzybysz changed the title SNOW-1636286: Add exact search for schema SNOW-1619625: Add exact search for schema Jan 9, 2025
@sfc-gh-dprzybysz sfc-gh-dprzybysz force-pushed the SNOW-1636286-add-exact-search-for-schema branch from fff1aaf to a305db8 Compare January 13, 2025 13:05
@sfc-gh-dprzybysz sfc-gh-dprzybysz force-pushed the SNOW-1636286-add-exact-search-for-schema branch from a305db8 to 6b4abb6 Compare January 14, 2025 07:01
if (schemaPattern != null
if (isExactSchema) {
String escapedSchema =
schemaPattern.replaceAll("_", "\\\\\\\\_").replaceAll("%", "\\\\\\\\%");

Choose a reason for hiding this comment

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

Can you help me understand this?
Why so many backslashes?
Would it make sense to introduce an escape function, similarly to escapeSingleQuoteForLikeCommand?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to escape _ or % with \\ for like parameter and 8x \ in result replacement is the way to achieve that:

String schemaPattern = "test_bla%123";
String escapedSchema = schemaPattern.replaceAll("_", "\\\\\\\\_").replaceAll("%", "\\\\\\\\%");
System.out.println(escapedSchema);

results in test\\_bla\\%123

the operation is used once so extract function is not necessary

@sfc-gh-dprzybysz sfc-gh-dprzybysz force-pushed the SNOW-1636286-add-exact-search-for-schema branch from 6b4abb6 to db59f44 Compare January 14, 2025 13:11
@sfc-gh-dprzybysz sfc-gh-dprzybysz force-pushed the SNOW-1636286-add-exact-search-for-schema branch from db59f44 to 95c06ca Compare January 14, 2025 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants