Skip to content

HIVE-29610: Add support for SQL wildcards (% and _) in SHOW COLUMNS aligning with other SHOW commands#6481

Open
Aggarwal-Raghav wants to merge 2 commits into
apache:masterfrom
Aggarwal-Raghav:HIVE-29610
Open

HIVE-29610: Add support for SQL wildcards (% and _) in SHOW COLUMNS aligning with other SHOW commands#6481
Aggarwal-Raghav wants to merge 2 commits into
apache:masterfrom
Aggarwal-Raghav:HIVE-29610

Conversation

@Aggarwal-Raghav
Copy link
Copy Markdown
Contributor

@Aggarwal-Raghav Aggarwal-Raghav commented May 13, 2026

What changes were proposed in this pull request?

Check HIVE-29610

Why are the changes needed?

ShowColumnsOperation doesn't make use of UDFLike#likePatternToRegExp() and only resolve * regex pattern and not the % which was introduced in HIVE-23359.

Does this PR introduce any user-facing change?

Yes, show columns will start supporint query like SHOW COLUMNS FROM tbl LIKE 'name_%'; and will be backward compatible to support * .

How was this patch tested?

Running the following UT and cluster testing

mvn clean test -Dtest=TestMiniLlapLocalCliDriver -Dqfile=show_columns_inconsistency.q,show_columns.q -Drat.skip -Pitests -pl itests/qtest

Before
Screenshot 2026-05-14 at 12 41 08 AM

After
Screenshot 2026-05-14 at 12 36 58 AM

@Aggarwal-Raghav
Copy link
Copy Markdown
Contributor Author

Aggarwal-Raghav commented May 13, 2026

After HIVE-23359 the behaviour in Hive3 vs Hive4.0.1 for regex pattern was changed i.e. breaking change until HIVE-28292 was merged. The following overloaded method where literalize=false and greedyMatch=true there the support for * was restored. Once such example where breaking change still exists is ShowDatabasesOperation.

public static String likePatternToRegExp(String likePattern, boolean literalize, boolean greedyMatch)

In show_coloums.q SHOW SORTED COLUMNS in foo_n7 from test_db "col+"; the + doesn't work and i guess it never worked.

@Aggarwal-Raghav
Copy link
Copy Markdown
Contributor Author

CC @wecharyu @deniskuzZ , requesting for review and feedback on the approach.

@Aggarwal-Raghav
Copy link
Copy Markdown
Contributor Author

UT failure is un-related. will re-run post review comments

Copy link
Copy Markdown
Contributor

@soumyakanti3578 soumyakanti3578 left a comment

Choose a reason for hiding this comment

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

Overall this looks quite good, but needs cleaning up in a few places and also needs more tests.

Comment on lines +86 to +89
} else if (n == '%') {
sb.append(greedyMatch ? ".*" : ".*?");
} else if (n == '*' && !literalize) {
sb.append(greedyMatch ? ".*" : ".*?");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe combine these together?
Also add a small comment explaining the condition

Comment on lines +12 to +14
SHOW TABLES LIKE 'wild%';
SHOW TABLES LIKE 'wild*';
SHOW TABLES LIKE 'none|wildcard_table';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These seem out of scope as this PR is fixing SHOW COLUMNS ... LIKE.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: A more relevant name for this? show_columns_like.q ?

id_secondary INT,
name_first STRING,
name_last STRING
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add columns here to tests case insensitivity? Since we are using Pattern.CASE_INSENSITIVE

SHOW TABLES LIKE 'none|wildcard_table';

SHOW COLUMNS FROM wildcard_table LIKE 'id%';
SHOW COLUMNS FROM wildcard_table LIKE 'name_%';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here we are really testing %, and not _. Can we add more tests for the single char wildcard?
Also add more tests for empty results, like abc%, id__, for example.

@sonarqubecloud
Copy link
Copy Markdown

@Aggarwal-Raghav
Copy link
Copy Markdown
Contributor Author

Thanks for the review @soumyakanti3578 , I've addressed the review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants