dtenedor commented on PR #60367:
URL: https://github.com/apache/spark/pull/60367#issuecomment-6885278369

   Thanks for the second round. All twelve findings are addressed in the new 
commit; each inline thread has a reply with what changed. Two things that have 
no inline thread:
   
   **Tests for the branches the review listed as untested.** Each now has a 
case that fails when the branch is removed:
   
   - `SELECT id FROM people GROUP BY id DISTRIBUTE BY addr?` and `SELECT 1 AS c 
FROM (SELECT 1 AS x) a JOIN (SELECT 2 AS x) b ORDER BY x?` fail with the same 
`UNRESOLVED_COLUMN` error as without `?` (the `RepartitionByExpression` and 
`Sort` cases of `visibleAttributes`).
   - `SELECT id FROM people GROUP BY id HAVING (SELECT max(i.id) FROM people i 
WHERE i.id = people.id AND people.addr.state? IS NULL) > 0` returns both rows 
(the outer `UnresolvedHaving` case with a field that only the outer `?` makes 
optional).
   - `EXECUTE IMMEDIATE 'SELECT p.missing?, ? AS g FROM people p' USING 1, 2` 
and the same statement with `IDENTIFIER('miss' || 'ing')?` fail with 
`UNUSED_SQL_PARAMETER_VALUES` (the `visitDereference` and 
`visitOptionalIdentifierClause` cases of `SubstituteParmsAstBuilder`).
   - `SELECT n.a, n.a? FROM VALUES (NULL) AS t(n)` returns two NULLs 
(`voidBaseIsNull` at the column site).
   - `ParametersSuite`: `SELECT '<emoji>' AS e, :p?FROM range(1)` returns the 
emoji and NULL, with and without a named argument (the code-point lookahead of 
`namedReplacement`).
   - `SELECT named_struct('city', 'x') AS addr FROM people GROUP BY id ORDER BY 
addr.zip?` fails with `UNRESOLVED_COLUMN` for `addr.zip` in both analyzers, the 
same as without `?` (the `resolvingSortOrder` exclusion in the single-pass 
resolver). I verified each new error case against the same statement without 
`?` in a scratch run; all pairs give the same error.
   
   **INSERT queries whose rows decide what is replaced.** I kept `?` allowed in 
the query of every INSERT, and the comments in the validator, the golden file, 
and the PR description now describe that boundary by the kind of statement and 
name the two forms you raised:
   
   - `UPDATE`, `DELETE`, `MERGE`, and `AUTO CDC` exist to modify existing rows, 
so they reject `?` everywhere, including the source query of `MERGE` (now also 
for a `mergeInto` source DataFrame). The harm the rejection targets is a 
predicate that selects existing rows to delete or change, which a missing 
column turns into `NULL IS NULL` or `NULL = x` for every row.
   - The query of an INSERT produces the rows to write, and a missing column 
makes the written rows differ in the same way as in any other query, in `INSERT 
INTO`, a static `INSERT OVERWRITE`, and CTAS alike. In dynamic partition 
overwrite mode, `INSERT OVERWRITE t SELECT v, p? FROM src` writes its rows to 
the NULL partition and replaces that partition: the data lands where the 
written rows say, and no row that the statement did not write is deleted. 
`INSERT ... REPLACE ON/USING` is in the same position, and no built-in Spark 
source implements it.
   - An analyzer check for the dynamic case would make the same SQL text fail 
or succeed depending on `spark.sql.sources.partitionOverwriteMode` or a 
per-write option, and it would have to single out 
`DataFrameWriterV2.overwritePartitions()` while `append()` and 
`overwrite(condition)` keep accepting the same source. The parser rule is 
stable and conf-independent. Only the `REPLACE` condition, a predicate on the 
target table, rejects `?`, like the predicates of UPDATE, DELETE, and MERGE.
   
   If the committers prefer the stricter side, the change is small: 
`OptionalReferenceValidation` would also reject a reference in the query of 
`INSERT ... REPLACE ON/USING`, and `CheckOptionalReferencesInDml` would reject 
unresolved optional references under `OverwritePartitionsDynamic`.
   
   The PR description's INSERT bullet and Tags paragraph are updated as 
suggested.
   


-- 
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]

Reply via email to