Skip to content

Conversation

@okumin
Copy link
Contributor

@okumin okumin commented May 2, 2024

What changes were proposed in this pull request?

ANSI SQL supports column aliases for CTEs. Hive also supports it but it fails when CTEs are materialized.

https://issues.apache.org/jira/browse/HIVE-28208

Why are the changes needed?

This patch allows materialized CTEs to obey the standard.

Does this PR introduce any user-facing change?

No. The affected queries never succeed now.

Is the change a dependency upgrade?

No.

How was this patch tested?

I added test queries to cte_mat_1.q.

@github-actions github-actions bot requested a review from miklosgergely May 2, 2024 16:40
@okumin okumin force-pushed the HIVE-28208-cte-mat-column-list branch from 54e45a8 to 1fdc90a Compare May 2, 2024 16:44
if (columns != null) {
FieldSchema col = new FieldSchema();
if (!("".equals(nm[0])) && nm[1] != null) {
if (i < withColList.size()) {
Copy link
Contributor Author

@okumin okumin May 2, 2024

Choose a reason for hiding this comment

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

Using an input name when is shorter than the input. This follows the behavior of non-materialized CTEs.
If I understand correctly, with-column-list is supported only when the number of columns is exactly equal to that of the query expression. So, it could be an option to disallow colInfos.size() != withColList.size().

set hive.optimize.cte.materialize.threshold=2;
set hive.optimize.cte.materialize.full.aggregate.only=false;
-- Use a format that retains column names
set hive.default.fileformat=parquet;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default one positionally accesses physical columns, and we can't find some kinds of errors.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 2, 2024

Quality Gate Passed Quality Gate passed

Issues
6 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

Issues
6 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@deniskuzZ
Copy link
Member

cc @zabetak

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Sep 17, 2024
@github-actions github-actions bot closed this Sep 24, 2024
@okumin okumin deleted the HIVE-28208-cte-mat-column-list branch October 11, 2025 01:57
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