Pastoray commented on PR #420:
URL: https://github.com/apache/datafusion-spark/pull/420#issuecomment-7307622920

   Thanks @andygrove, this was useful. I ran each scenario rather than 
reasoning about it. The fixes are in a follow-up commit.
   
   **1. Nullability of widened items and fields: you were right, fixed.**
   `complex_type` only consulted `force_nullable` for the map key filter. Spark 
ORs it in for array items, struct fields *and* map values 
(`findTypeForComplex`), so I added `nullable_after_cast` and use it for all 
three. With ANSI on, a non-nullable `List<Utf8>` and `List<Int32>` now widen to 
a nullable `List<Int64>`. Without ANSI they stay non-nullable, since a cast to 
string cannot return NULL. Unit tests cover lists, structs and map values, and 
they fail if the fix is removed.
   
   **2. ANSI `array` tests did not distinguish the new behavior: fixed.**
   They now assert `arrow_typeof`, pinning `List(Int64)`, `List(Float64)` and 
`List(Boolean)`. Agreed that the earlier value-only records likely passed 
before the change. The description's "fail before this change" holds for the 
`if` and non-ANSI cases and now for these too.
   
   **3. Unparseable string in ANSI mode.**
   `array(1::INT, 'a')` and `if(false, 1::INT, 'a')` with ANSI on raise an 
error (`Cannot cast string 'a' to value of Int64 type`) and do not return NULL. 
That matches Spark in raising, but the message is DataFusion's, not 
`CAST_INVALID_INPUT`. I added tests that record this, with a comment. Matching 
Spark's error depends on the cast porting in #88, which is out of scope here.
   
   **4. Struct coverage: added.**
   Unit tests cover matching names in both modes, nullability, and mismatched 
names, counts and field order. There are also slt cases for `array` of structs 
with ANSI on and off and for mismatched names (`DATA_DIFF_TYPES`).
   
   **5. Documentation: added.**
   The `#[user_doc]` text of `if` and `array` now describes the ANSI and 
non-ANSI string promotion and the error for BOOLEAN/BINARY mixed with a string. 
I regenerated `docs/functions` with `dev/update_function_docs.sh`, and only 
those two files changed.
   
   One note: the ANSI flag is a `bool`, not an `EvalMode`. These functions have 
no `try_` variant, and `greatest`/`least` and the shared `type_coercion` rules 
already take a `bool`.


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