cloud-fan commented on a change in pull request #35404:
URL: https://github.com/apache/spark/pull/35404#discussion_r804319206
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -4281,6 +4281,53 @@ class SQLQuerySuite extends QueryTest with
SharedSparkSession with AdaptiveSpark
Row(2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22) :: Nil)
}
}
+
+ test("SPARK-38118: Func(wrong_type) in the HAVING claus should throw data
mismatch error") {
+ val e1 = intercept[AnalysisException](
+ sql(
+ """
+ |with t as (select true c)
+ |select t.c
+ |from t
+ |group by t.c
+ |having mean(t.c) > 0d""".stripMargin))
+ assert(e1.message.contains("cannot resolve 'mean(tempresolvedcolumn(t.c))'
due to data type " +
+ "mismatch: function average requires numeric or interval types, not
boolean"))
+
+ val e2 = intercept[AnalysisException](
+ sql(
+ """
+ |with t as (select true c, false d)
+ |select (t.c & t.d) c
+ |from t
+ |group by t.c
+ |having mean(c) > 0d""".stripMargin))
+ assert(e2.message.contains("cannot resolve '(t.c & t.d)' due to data type
mismatch: " +
+ "'(t.c & t.d)' requires integral type, not boolean"))
+
+ val e3 = intercept[AnalysisException](
+ sql(
+ """
+ |with t as (select true c, false d)
+ |select (t.c & t.d) c
+ |from t
+ |group by t.c
+ |having abs(c) > 0d""".stripMargin))
+ assert(e3.message.contains("cannot resolve '(t.c & t.d)' due to data type
mismatch: " +
+ "'(t.c & t.d)' requires integral type, not boolean"))
+
+ val e4 = intercept[AnalysisException](
+ sql(
+ """
+ |with t as (select true c, false d)
Review comment:
column d is not used.
--
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]