Szehon Ho created SPARK-61805:
---------------------------------
Summary: Defer constant-folding failures in MERGE actions
Key: SPARK-61805
URL: https://issues.apache.org/jira/browse/SPARK-61805
Project: Spark
Issue Type: Bug
Components: SQL
Affects Versions: 5.0.0
Reporter: Szehon Ho
With ANSI mode enabled, MERGE can fail during constant folding while evaluating
an expression in a clause that is never reached.
For a MERGE-capable target with schema (pk INT, salary BIGINT, dep STRING),
target row (1, 100, 'hr'), and source row (1, 10, 'hr'):
{code:sql}
MERGE INTO target t
USING source s
ON t.pk = s.pk
WHEN MATCHED AND s.salary < 0 THEN UPDATE SET salary = 1 DIV 0
WHEN MATCHED THEN UPDATE SET salary = s.salary
{code}
Expected: update salary to 10.
Actual: DIVIDE_BY_ZERO during optimization, although the first action is not
selected.
Conditions in later clauses and expressions in other match types can fail the
same way. MergeRows evaluates only the applicable clause list and stops at the
first matching clause, but ConstantFolding does not currently treat instruction
children as conditional.
The fix can reuse the existing conditional-expression error deferral for
MergeRows.Instruction children. Successful expressions still fold; failures
remain runtime expressions and still raise errors if reached.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]