vranes commented on code in PR #58657:
URL: https://github.com/apache/spark/pull/58657#discussion_r4017551885
##########
sql/core/src/test/scala/org/apache/spark/sql/AsOfJoinSQLSuite.scala:
##########
@@ -336,6 +375,22 @@ class AsOfJoinSQLSuite extends QueryTest with
SharedSparkSession {
assert(asOfJoin.rightSortExprs.nonEmpty)
}
+ test("ARRAY<STRUCT> MATCH_CONDITION with mismatched element names and types
is rejected") {
+ // Element structs differ in name (x vs y) and type (INT vs BIGINT).
+ // Widening differing types requires matching field names, so the query
fails.
+ val sqlText =
+ """
+ |SELECT r.a
+ |FROM VALUES (ARRAY(named_struct('x', CAST(5 AS INT)))) AS t(a)
+ |ASOF JOIN (
+ | SELECT * FROM VALUES (ARRAY(named_struct('y', CAST(5 AS BIGINT))))
AS r(a)
+ |) r
+ | MATCH_CONDITION (t.a >= r.a)
+ |""".stripMargin
+ val e = intercept[AnalysisException](sql(sqlText))
+ assert(e.getCondition == "DATATYPE_MISMATCH.BINARY_OP_DIFF_TYPES")
Review Comment:
Switched to `checkError`, pinning left/right/sqlExpr and the query context.
Thanks!
--
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]