Skip to content

Support CTE/JOIN usage for PIVOT operator #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

RIC06X
Copy link
Contributor

@RIC06X RIC06X commented Jan 26, 2024

Description

This commit fixed an issue that CTE and JOIN cannot be used with pivot operator.

We added 1 field (Node *context) in FuncExpr Struct to store pivot additional information. FuncExpr will carry the pivot information to ExecMakeTableFunctionResult. In this function, we pass the pivot information into two newly added FunctionCallInfo that we can retrieve at bbf_pivot function.

Issues Resolved

Task: BABEL-4713, BABEL-4714, BABEL-4795

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@RIC06X RIC06X self-assigned this Jan 26, 2024
@RIC06X RIC06X force-pushed the pivot-view-fix-pg16 branch from 42050d7 to 4497316 Compare March 20, 2024 22:23
@RIC06X RIC06X changed the title Support View usage for PIVOT operator Support View/CTE/JOIN usage for PIVOT operator Mar 20, 2024
@RIC06X RIC06X force-pushed the pivot-view-fix-pg16 branch 3 times, most recently from 96d91da to 14cae9f Compare March 21, 2024 19:25
@RIC06X RIC06X force-pushed the pivot-view-fix-pg16 branch from 14cae9f to 359ad18 Compare March 29, 2024 21:56
@RIC06X RIC06X requested a review from rishabhtanwar29 April 5, 2024 07:58
@RIC06X RIC06X force-pushed the pivot-view-fix-pg16 branch 4 times, most recently from 983a0a0 to 3a02cde Compare April 25, 2024 15:50
@RIC06X RIC06X changed the title Support View/CTE/JOIN usage for PIVOT operator Support CTE/JOIN usage for PIVOT operator Apr 25, 2024
RIC06X added 4 commits April 25, 2024 16:41
This commit fixed an issue that view cannot be created or used by stmt
with pivot operator.

Task: BABEL-4673
Signed-off-by: Yanjie Xu <[email protected]>
Modified internal PIVOT information analyzer -> executor passing design.
Supported CTE/VIEW/JOIN as well as function/procedure for PIVOT
operator.

Task: BABEL-4713, BABEL-4714, BABEL-4673
Signed-off-by: Yanjie Xu <[email protected]>
Disable CREATE VIEW ON stmt with PIVOT operator due to pg_dump cannot
dump pivot view with correct dependency and newly added fields in
FuncExpr casued readFunc failed to parse previous minor version string
parsetree during select from view after mVU.

Task: BABEL-4673
Signed-off-by: Yanjie Xu <[email protected]>
Removed newly added pivot fields in fcinfo and set the fcinfo->context
to pivot data when the FuncExpr is a bbf_pivot function

Task: BABEL-4673
Signed-off-by: Yanjie Xu <[email protected]>
@RIC06X RIC06X force-pushed the pivot-view-fix-pg16 branch from 3a02cde to 3fd80cb Compare April 25, 2024 16:42
@@ -18,6 +18,7 @@
#ifndef FMGR_H
#define FMGR_H

#include "nodes/pg_list.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fmgr.h is a header file used by execSRF.c. And List hasn't been used in execSRF.c until we added our pivot logic. So we need to include this to fmgr.h

@RIC06X RIC06X force-pushed the pivot-view-fix-pg16 branch 2 times, most recently from 357858f to 3fd80cb Compare April 26, 2024 04:17
RIC06X added 2 commits April 26, 2024 07:40
Replaced pivot related fields with generic Node * field in FuncCall and
FuncExpr

Task: BABEL-4713, BABEL-4714
Signed-off-by: Yanjie Xu <[email protected]>
Move executor pivot data passing code to Babelfish hook function.

Task: BABEL-4713, BABEL-4714
Signed-off-by: Yanjie Xu <[email protected]>
@forestkeeper forestkeeper merged commit 4295eb2 into babelfish-for-postgresql:BABEL_4_X_DEV__PG_16_X Apr 27, 2024
2 checks passed
roshan0708 pushed a commit to amazon-aurora/postgresql_modified_for_babelfish that referenced this pull request Oct 15, 2024
…resql#299)

This commit fixed an issue that CTE and JOIN cannot be used with pivot operator.

We added 1 field (Node *context) in FuncExpr Struct to store pivot additional information. FuncExpr will carry the pivot information to ExecMakeTableFunctionResult. In this function, we pass the pivot information into two newly added FunctionCallInfo that we can retrieve at bbf_pivot function.

Task: BABEL-4713, BABEL-4714, BABEL-4795 
Signed-off-by: Yanjie Xu <[email protected]>
roshan0708 pushed a commit to amazon-aurora/postgresql_modified_for_babelfish that referenced this pull request Oct 18, 2024
…resql#299)

This commit fixed an issue that CTE and JOIN cannot be used with pivot operator.

We added 1 field (Node *context) in FuncExpr Struct to store pivot additional information. FuncExpr will carry the pivot information to ExecMakeTableFunctionResult. In this function, we pass the pivot information into two newly added FunctionCallInfo that we can retrieve at bbf_pivot function.

Task: BABEL-4713, BABEL-4714, BABEL-4795 
Signed-off-by: Yanjie Xu <[email protected]>
roshan0708 pushed a commit to amazon-aurora/postgresql_modified_for_babelfish that referenced this pull request Oct 18, 2024
…resql#299)

This commit fixed an issue that CTE and JOIN cannot be used with pivot operator.

We added 1 field (Node *context) in FuncExpr Struct to store pivot additional information. FuncExpr will carry the pivot information to ExecMakeTableFunctionResult. In this function, we pass the pivot information into two newly added FunctionCallInfo that we can retrieve at bbf_pivot function.

Task: BABEL-4713, BABEL-4714, BABEL-4795 
Signed-off-by: Yanjie Xu <[email protected]>
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