Skip to content

Conversation

mdayakar
Copy link
Contributor

HIVE-26493: Hive throws error when querying a view that was created successfully

What changes were proposed in this pull request?

While creating view, if column names are specified and the view definition is enclosed within the brackets then view creation is ok but while selecting the data from view, as here user provided column names the view definition is becoming like select col1 as c1 from ((select col1 from tab)) v0, here view definition is already enclosed within brackets and we also adding an extra brackets again, which is causing compile failure.
So as a part of fix, if view definition is already enclosed within brackets then not adding the brackets again.

Why are the changes needed?

Without fix, the data from view cannot be selected.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Using q tests
mvn -Dtest=TestMiniLlapLocalCliDriver -Dqfile=viewdef_within_brackets.q -pl itests/qtest -Pitests

Copy link
Contributor

@thomasrebele thomasrebele left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link


String expandedText = ctx.getTokenRewriteStream().toString(select.getTokenStartIndex(), select.getTokenStopIndex());

if (imposedSchema != null) {
Copy link
Contributor

@kasakrisz kasakrisz Sep 30, 2025

Choose a reason for hiding this comment

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

Storing the extra brackets in the expanded text is not necessary even when column names are not specified so trimming them could be moved before this if statement.

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.

4 participants