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

   Thanks for the review. All 14 findings are addressed in the new commit; each 
inline thread has the details. On the review-level concern and the four 
questions:
   
   **Tag lifetimes.** `OptionalReferences` now documents that the three tags 
(optional name parts, optional markers, the NULL of a missing reference) are 
facts about the statement that every analysis of the plan can rely on, that 
Spark's generic transforms copy them, and that a rule which rebuilds a 
reference another way forwards them with 
`OptionalReferences.withOptionalNamePartsOf` (the HAVING path does). The only 
per-analysis decision, that no resolution step of an operator can resolve an 
optional field extraction, is a node of the plan the analysis builds, 
`LastResortExtractValue`, so the plan the analyzer receives is never written to.
   
   **Unaliased casts over a missing reference are named after NULL.** Kept, and 
documented. An expression over an optional reference is named like any other 
expression, from what it resolved to. Naming it after the reference instead 
would give a stable name for a top-level column, but not for a nested field: 
`CAST(addr.state? AS STRING)` is named `CAST(addr.state AS STRING)` while the 
field exists, so neither `state` nor `CAST(NULL AS STRING)` would match it when 
it is missing. The uniform answer is an alias, which the view advice in the 
description and the golden-file comment now say; a permanent view without one 
fails loudly (`CREATE_PERMANENT_VIEW_WITHOUT_ALIAS`) rather than with a 
changing name.
   
   **INSERT OVERWRITE and REPLACE TABLE AS SELECT.** Kept allowed, and 
documented in `OptionalReferenceValidation` and the description. The line the 
PR draws is whether a missing reference can change which existing rows a 
statement modifies: in `UPDATE`, `DELETE`, `MERGE`, `INSERT ... REPLACE WHERE`, 
and `AUTO CDC`, the condition selects those rows, and `?` in it is rejected. An 
overwrite replaces its rows regardless of the query, and the query is read-only 
data, as for `INSERT INTO`. The golden file has an `INSERT OVERWRITE` with `?` 
in the query.
   
   **A `?` read as an optional reference after a keyword shifts positional 
values.** Taken the second option: a statement with optional references that is 
given more positional values than it has positional markers fails with the new 
`UNUSED_SQL_PARAMETER_VALUES` (SQLSTATE `07001`), in `SubstituteParamsParser` 
and in the legacy `BindParameters` path. The example `SELECT missing?, 
first(DISTINCT ?) AS f, ? AS g` with two values fails instead of binding 5 to 
`g`; a statement without optional references keeps ignoring extra values as 
before. Golden and `ParametersSuite` cases cover both binding modes.
   
   **Path extraction over a missing optional VARIANT reference.** Taken the 
second option: `missing?:a` is NULL (of type VARIANT) in both analyzers, like a 
field or subscript of a missing reference; a written `NULL:a` still fails with 
`COLUMN_IS_NOT_VARIANT_TYPE`. Golden cases cover a present and a missing column.
   
   Also in the new commit: the error condition is renamed to 
`OPTIONAL_REFERENCE_NOT_SUPPORTED` with an `IN_PARTITION_SPEC` subclass, and 
the parse-time numbers of the generated parser (master vs. this branch, conf 
off) are in the description.
   


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