Skip to content

[CH] Support skewness aggregate function#12294

Merged
taiyang-li merged 9 commits into
apache:mainfrom
navaneethsujith09:skewness-aggregate-support
Jun 27, 2026
Merged

[CH] Support skewness aggregate function#12294
taiyang-li merged 9 commits into
apache:mainfrom
navaneethsujith09:skewness-aggregate-support

Conversation

@navaneethsujith09

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Support the skewness aggregate function in the ClickHouse backend:

  • Maps Spark's skewness to ClickHouse's skewSamp
  • Adds NaN→NULL conversion to match Spark's behavior when fewer than 3 non-null values are present
  • Removes skewness from the unsupported function blacklist in CHExpressionUtil.scala

How was this patch tested?

Updated GlutenClickhouseCountDistinctSuite

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.8

Copilot AI review requested due to automatic review settings June 14, 2026 18:35
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR appears to add ClickHouse/native handling for Spark’s skewness aggregate and adjusts ClickHouse backend validation and tests accordingly.

Changes:

  • Register skewness aggregate mapping to ClickHouse skewSamp in the local engine parser.
  • Remove SKEWNESS from the ClickHouse expression validator map (previously always-invalid).
  • Update an existing ClickHouse backend test to stop asserting an exception and instead compare results against vanilla Spark.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
cpp-ch/local-engine/Parser/aggregate_function_parser/SimpleStatisticsFunctions.cpp Registers skewness by mapping Spark name to ClickHouse aggregate function.
backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala Removes the explicit validator entry that previously forced SKEWNESS to be unsupported.
backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseCountDistinctSuite.scala Changes test behavior from expecting failure to result comparison (allowing fallback).
Comments suppressed due to low confidence (1)

backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala:1

  • Removing SKEWNESS -> DefaultValidator() flips skewness from explicitly unsupported (since DefaultValidator returns false) to whatever the map’s default behavior is when an entry is missing. If the goal is to support skewness, it’s more robust to add an explicit validator for SKEWNESS (e.g., numeric input types) rather than relying on implicit defaults, and pair it with a test that confirms the intended backend behavior.
/*

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI review requested due to automatic review settings June 23, 2026 05:46
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings June 24, 2026 01:27
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@taiyang-li

taiyang-li commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@navaneethsujith09 ci failed because

[2026-06-25T02:06:32.618Z] [INFO] --- scalastyle-maven-plugin:1.0.0:check (default) @ backends-clickhouse ---

[2026-06-25T02:06:35.113Z] error file=/home/jenkins/agent/workspace/gluten/gluten-ci/ut-stage-1/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseCountDistinctSuite.scala message=File line length exceeds 100 characters line=108

[2026-06-25T02:06:35.117Z] Saving to outputFile=/home/jenkins/agent/workspace/gluten/gluten-ci/ut-stage-1/backends-clickhouse/scalastyle-output.xml

[2026-06-25T02:06:35.117Z] Processed 231 file(s)

[2026-06-25T02:06:35.117Z] Found 1 errors

[2026-06-25T02:06:35.117Z] Found 0 warnings

[2026-06-25T02:06:35.117Z] Found 0 infos

please fix it.

Copilot AI review requested due to automatic review settings June 25, 2026 18:21

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@taiyang-li taiyang-li left a comment

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.

LGTM

@taiyang-li taiyang-li merged commit fb646be into apache:main Jun 27, 2026
7 checks passed
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