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 thread ql/src/java/org/apache/hadoop/hive/ql/udf/UDFLike.java Outdated
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.

These tests were out of place in the show columns test file. You can add these in an appropriate file for show tables if these are missing.

Comment thread ql/src/test/queries/clientpositive/show_columns_inconsistency.q Outdated
Comment thread ql/src/test/queries/clientpositive/show_columns_inconsistency.q Outdated
Comment thread ql/src/test/queries/clientpositive/show_columns_inconsistency.q Outdated
@sonarqubecloud
Copy link
Copy Markdown

@Aggarwal-Raghav
Copy link
Copy Markdown
Contributor Author

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

SHOW COLUMNS FROM wildcard_table LIKE 'another_mixed_col';
SHOW COLUMNS FROM wildcard_table LIKE 'id*';
SHOW COLUMNS FROM wildcard_table LIKE 'id_primary|name_first';

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.

I think we still need to test escape sequences. For example, add another column to the table - idxprimary or something similar, and test with

SHOW COLUMNS FROM wildcard_table LIKE 'id\_primary';

which should return just id_primary and not idxprimary.

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