Skip to content

Conversation

@bomeng
Copy link
Contributor

@bomeng bomeng commented Apr 6, 2016

What changes were proposed in this pull request?

LIKE is commonly used in SHOW TABLES / FUNCTIONS etc DDL. In the pattern, user can use | or * as wildcards.

  1. Currently, we used replaceAll() to replace * with .*, but the replacement was scattered in several places; I have created an utility method and use it in all the places;
  2. Consistency with Hive: the pattern is case insensitive in Hive and white spaces will be trimmed, but current pattern matching does not do that. For example, suppose we have tables (t1, t2, t3), SHOW TABLES LIKE ' T* ' will list all the t-tables. Please use Hive to verify it.
  3. Combined with |, the result will be sorted. For pattern like ' B*|a* ', it will list the result in a-b order.

I've made some changes to the utility method to make sure we will get the same result as Hive does.

How was this patch tested?

A new method was created in StringUtil and test cases were added.

@andrewor14

@SparkQA
Copy link

SparkQA commented Apr 6, 2016

Test build #55114 has finished for PR 12206 at commit b76ccd8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

subPattern =>
try {
val regex = ("(?i)" + subPattern.replaceAll("\\*", ".*")).r
funcNames ++= names.filter{name => regex.pattern.matcher(name).matches()}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: filter { name => ... }

@andrewor14
Copy link
Contributor

LGTM, just a few style nits

@andrewor14
Copy link
Contributor

I'll fix those myself on merge actually. Merging into master.

@asfgit asfgit closed this in 5abd02c Apr 6, 2016
@bomeng
Copy link
Contributor Author

bomeng commented Apr 6, 2016

@andrewor14 Cool, thanks. I will pay more attention to the coding style next time.

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.

3 participants