cj-zhukov commented on PR #395:
URL: https://github.com/apache/datafusion-spark/pull/395#issuecomment-7083559136

   > This is an automated first-pass review, so a human reviewer should still 
look at it.
   > 
   > Thanks for the PR. Reusing the nested-type validation for planning is a 
nice approach, the `ToJsonOption` enum makes adding more options 
straightforward, and the `.slt` coverage is thorough, including sliced input, 
`LargeList`, `FixedSizeList` and list views. I ran the PR locally and fmt, 
clippy, the `to_json` unit tests, `to_json.slt` in both modes and the docs 
generation check all pass. I found no correctness or performance problems. CI 
has not run yet, so a committer will need to approve the workflow.
   > 
   > I have two questions.
   > 
   > **Option errors surface at execution.** `ToJsonOptions::try_new` runs in 
`invoke_with_args` and returns `plan_err!`. That covers an unsupported option 
name, a bad boolean, a NULL map and a non-constant map. As a result `SELECT 
to_json(array(1), map('pretty','true')) FROM (SELECT 1 WHERE false)` returns no 
error, while the same query with one row fails. Type errors are caught earlier 
in `return_type`, so the two kinds of error now behave differently. Could 
constant options be validated in `return_field_from_args` using 
`scalar_arguments`, so these errors surface at planning? The runtime check 
could stay as a fallback for a non-constant map. A small `.slt` with an empty 
input would pin this down.
   > 
   > **NULL option values.** In `ToJsonOptions::try_new`, the comment "Spark 
turns a NULL value into the string "null"" sits on a branch that a literal NULL 
cannot reach, because `map('ignoreNullFields', NULL)` is rejected earlier in 
`check_options_type` for its `Null` value type. Only a typed NULL such as 
`CAST(NULL AS STRING)` gets there, and it then fails with "must be true or 
false, got 'null'". Where does the "null" string behavior come from? I could 
not confirm it from Spark's source and I think Spark may fail on a NULL option 
value instead. If PySpark confirms it, please add an `.slt` record and cite it 
in the comment. If not, I would return a clear error for a NULL option value 
and drop the branch.
   
   Thanks for the detailed review, @andygrove.
   
   **Option errors at execution:** that makes sense. I'll validate constant 
options at planning time and add an `.slt` case with empty input.
   
   **NULL option values:** I'll double-check this against PySpark and come back 
with the details and an `.slt` record.


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