Yang Jie created SPARK-61337:
--------------------------------
Summary: CHECK constraint violation messages list a function name
without parentheses or a variable as a column
Key: SPARK-61337
URL: https://issues.apache.org/jira/browse/SPARK-61337
Project: Spark
Issue Type: Improvement
Components: SQL
Affects Versions: 5.0.0
Reporter: Yang Jie
A write that checks a CHECK constraint through its predicateSql
(ResolveTableConstraints) lists, in the CHECK_CONSTRAINT_VIOLATION message,
every name the parsed condition reads. A name that the analysis resolves to
something other than a column of the row is listed as if it were one:
{noformat}
DECLARE VARIABLE v STRING DEFAULT 'x';
CREATE TABLE t (id INT, owner STRING, CONSTRAINT c1 CHECK (owner = current_user
OR owner = v));
INSERT INTO t VALUES (1, '');
-- CHECK_CONSTRAINT_VIOLATION ... values:
-- - owner :
-- - current_user : <the user>
-- - v : x
{noformat}
A CREATE TABLE constraint is checked this way whenever its predicate has no V2
form, and so is any constraint whose stored predicate does not convert back to
Catalyst.
The message could leave out the values that have no references, computed once,
for example in CheckInvariant, rather than in a rule that runs in every
iteration of the analysis.
Raised in https://github.com/apache/spark/pull/59545#discussion_r4515521827
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]