Skip to content

[CH] Support skewness aggregate function#12294

Open
navaneethsujith09 wants to merge 1 commit into
apache:mainfrom
navaneethsujith09:skewness-aggregate-support
Open

[CH] Support skewness aggregate function#12294
navaneethsujith09 wants to merge 1 commit into
apache:mainfrom
navaneethsujith09:skewness-aggregate-support

Conversation

@navaneethsujith09

Copy link
Copy Markdown

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.

Comment on lines +66 to +73
// for skewness
struct SkewnessNameStruct
{
static constexpr auto spark_name = "skewness";
static constexpr auto ch_name = "skewSamp";
};

static const AggregateFunctionParserRegister<AggregateFunctionParserStddev<SkewnessNameStruct>> registerer_skewness;
assertThrows[UnsupportedOperationException] {
spark.sql(sql).show
}
compareResultsAgainstVanillaSpark(sql, true, { _ => })
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.

2 participants