Skip to content

test: add SQL file tests for regr_* linear-regression aggregates#4551

Merged
andygrove merged 1 commit into
apache:mainfrom
andygrove:test-regr-aggregate-coverage
Jun 2, 2026
Merged

test: add SQL file tests for regr_* linear-regression aggregates#4551
andygrove merged 1 commit into
apache:mainfrom
andygrove:test-regr-aggregate-coverage

Conversation

@andygrove
Copy link
Copy Markdown
Member

Which issue does this PR close?

N/A. This adds test coverage only.

Rationale for this change

The SQL standard linear-regression aggregates (regr_count, regr_avgx, regr_avgy, regr_sxx, regr_syy, regr_sxy, regr_slope, regr_intercept, regr_r2) had no Comet test coverage. Comet already accelerates several of them natively, because Spark lowers them to Count / Average aggregates that Comet supports, but this was unverified. These tests establish which of the family run natively in Comet versus fall back to Spark, and guard the accelerated ones against future regressions.

What changes are included in this PR?

Adds one SQL file test, spark/src/test/resources/sql-tests/expressions/aggregate/regr.sql, covering all nine regr_* functions over global aggregates, GROUP BY, all-NULL input, and single-pair input (only rows where both y and x are non-null contribute).

  • regr_count, regr_avgx, regr_avgy run natively. They use the default query mode, which asserts the query executes on Comet without falling back to Spark and matches Spark exactly.
  • regr_sxx, regr_syy, regr_sxy, regr_slope, regr_intercept, regr_r2 currently fall back to Spark, so they use query spark_answer_only to validate result correctness against Spark.

How are these changes tested?

This PR is test-only. The new file runs under CometSqlFileTestSuite, which executes each query through both Spark and Comet and compares results; the default query blocks additionally assert native (non-fallback) Comet execution. Verified locally:

./mvnw test -Dsuites="org.apache.comet.CometSqlFileTestSuite regr" -Dtest=none

Result: the single discovered test file passes.

Copy link
Copy Markdown
Contributor

@mbutrovich mbutrovich left a comment

Choose a reason for hiding this comment

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

Tests are good! Thanks @andygrove!

@andygrove andygrove merged commit e93d1e9 into apache:main Jun 2, 2026
50 checks passed
@andygrove andygrove deleted the test-regr-aggregate-coverage branch June 2, 2026 14:07
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.

2 participants