Skip to content

Support extended stats creation on expressions#8501

Merged
colm-mchugh merged 4 commits intocitusdata:mainfrom
visridha:visridha/add_stats_creation_on_expressions
Mar 10, 2026
Merged

Support extended stats creation on expressions#8501
colm-mchugh merged 4 commits intocitusdata:mainfrom
visridha:visridha/add_stats_creation_on_expressions

Conversation

@visridha
Copy link
Copy Markdown
Contributor

@visridha visridha commented Mar 9, 2026

DESCRIPTION: Support extended stats creation on expressions
CREATE STATISTICS today gets pushed to the shards only if the statistics is on a column expression. However, PG14 added support for expressions (opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and deparse the exprs and add it to the statistics call.

Copy link
Copy Markdown
Contributor

@colm-mchugh colm-mchugh left a comment

Choose a reason for hiding this comment

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

I left a couple of code questions and test suggestions, nice addition overall, thx.

* cannot be found.
*/
Relation relation = table_open(relOid, AccessShareLock);
ParseState *pstate = make_parsestate(NULL);
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.

A take-it-or-leave-it suggestion: acquire the table lock and create the ParseState once at the top of the function so they're done once regardless of number of expressions in the CREATE STATISTICS. Not essential as we're in DDL, and it may not be worth complicating the code for, but just putting forward for consideration.

@colm-mchugh colm-mchugh merged commit ad2140d into citusdata:main Mar 10, 2026
156 checks passed
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
(cherry picked from commit 23b1446)
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
onurctirtir pushed a commit that referenced this pull request Mar 13, 2026
DESCRIPTION: Support extended stats creation on expressions

CREATE STATISTICS today gets pushed to the shards only if the statistics
is on a column expression. However, PG14 added support for expressions
(opExpr, FuncExprs) etc. This change adds support for it under a GUC.
This reuses the same logic as CHECK constraints to parse, transform, and
deparse the exprs and add it to the statistics call.

(cherry picked from commit ad2140d)

Conflicts:
	src/backend/distributed/deparser/deparse_statistics_stmts.c
onurctirtir added a commit that referenced this pull request Mar 13, 2026
…le the feature (#8512)

Removing the GUC introduced at
#8501 as it's not needed at all.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onurctirtir <16804727+onurctirtir@users.noreply.github.com>
(cherry picked from commit 84ddcd9)
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