-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-39384][SQL] Compile built-in linear regression aggregate functions for JDBC dialect #37188
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -523,4 +523,72 @@ private[v2] trait V2JDBCTest extends SharedSparkSession with DockerIntegrationFu | |
| assert(row(2).isNullAt(0)) | ||
| } | ||
| } | ||
|
|
||
| protected def testRegrIntercept(isDistinct: Boolean = false): Unit = { | ||
| val distinct = if (isDistinct) "DISTINCT " else "" | ||
| test(s"scan with aggregate push-down: REGR_INTERCEPT with distinct: $isDistinct") { | ||
| val df = sql( | ||
| s"SELECT REGR_INTERCEPT(${distinct}bonus, bonus) FROM $catalogAndNamespace." + | ||
| s"${caseConvert("employee")} WHERE dept > 0 GROUP BY dept ORDER BY dept") | ||
| checkFilterPushed(df) | ||
| checkAggregateRemoved(df) | ||
| checkAggregatePushed(df, "REGR_INTERCEPT") | ||
| val row = df.collect() | ||
| assert(row.length === 3) | ||
| assert(row(0).getDouble(0) === 0d) | ||
| assert(row(1).getDouble(0) === 0d) | ||
| assert(row(2).isNullAt(0)) | ||
| } | ||
| } | ||
|
|
||
| protected def testRegrSlope(isDistinct: Boolean = false): Unit = { | ||
| val distinct = if (isDistinct) "DISTINCT " else "" | ||
| test(s"scan with aggregate push-down: REGR_SLOPE with distinct: $isDistinct") { | ||
| val df = sql( | ||
| s"SELECT REGR_SLOPE(${distinct}bonus, bonus) FROM $catalogAndNamespace." + | ||
| s"${caseConvert("employee")} WHERE dept > 0 GROUP BY dept ORDER BY dept") | ||
| checkFilterPushed(df) | ||
| checkAggregateRemoved(df) | ||
| checkAggregatePushed(df, "REGR_SLOPE") | ||
| val row = df.collect() | ||
| assert(row.length === 3) | ||
| assert(row(0).getDouble(0) === 1d) | ||
| assert(row(1).getDouble(0) === 1d) | ||
| assert(row(2).isNullAt(0)) | ||
| } | ||
| } | ||
|
|
||
| protected def testRegrR2(isDistinct: Boolean = false): Unit = { | ||
| val distinct = if (isDistinct) "DISTINCT " else "" | ||
| test(s"scan with aggregate push-down: REGR_R2 with distinct: $isDistinct") { | ||
| val df = sql( | ||
| s"SELECT REGR_R2(${distinct}bonus, bonus) FROM $catalogAndNamespace." + | ||
| s"${caseConvert("employee")} WHERE dept > 0 GROUP BY dept ORDER BY dept") | ||
| checkFilterPushed(df) | ||
| checkAggregateRemoved(df) | ||
| checkAggregatePushed(df, "REGR_R2") | ||
| val row = df.collect() | ||
| assert(row.length === 3) | ||
| assert(row(0).getDouble(0) === 1d) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: can we write 1.0 instead of 1d? just seems clearer, here and elsewhere
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for the comment.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
| assert(row(1).getDouble(0) === 1d) | ||
| assert(row(2).isNullAt(0)) | ||
| } | ||
| } | ||
|
|
||
| protected def testRegrSXY(isDistinct: Boolean = false): Unit = { | ||
| val distinct = if (isDistinct) "DISTINCT " else "" | ||
| test(s"scan with aggregate push-down: REGR_SXY with distinct: $isDistinct") { | ||
| val df = sql( | ||
| s"SELECT REGR_SXY(${distinct}bonus, bonus) FROM $catalogAndNamespace." + | ||
| s"${caseConvert("employee")} WHERE dept > 0 GROUP BY dept ORDER BY dept") | ||
| checkFilterPushed(df) | ||
| checkAggregateRemoved(df) | ||
| checkAggregatePushed(df, "REGR_SXY") | ||
| val row = df.collect() | ||
| assert(row.length === 3) | ||
| assert(row(0).getDouble(0) === 20000d) | ||
| assert(row(1).getDouble(0) === 5000d) | ||
| assert(row(2).getDouble(0) === 0d) | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto for others.