srowen commented on code in PR #37188:
URL: https://github.com/apache/spark/pull/37188#discussion_r921090568
##########
connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/V2JDBCTest.scala:
##########
@@ -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)
Review Comment:
Nit: can we write 1.0 instead of 1d? just seems clearer, here and elsewhere
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]