diff --git a/src/function/cast/vector_cast_helpers.cpp b/src/function/cast/vector_cast_helpers.cpp index a064b4aca3e..c7aa523eaa0 100644 --- a/src/function/cast/vector_cast_helpers.cpp +++ b/src/function/cast/vector_cast_helpers.cpp @@ -4,7 +4,9 @@ namespace duckdb { // ------- Helper functions for splitting string nested types ------- static bool IsNull(const char *buf, idx_t start_pos, Vector &child, idx_t row_idx) { - if (buf[start_pos] == 'N' && buf[start_pos + 1] == 'U' && buf[start_pos + 2] == 'L' && buf[start_pos + 3] == 'L') { + if ((buf[start_pos] == 'N' || buf[start_pos] == 'n') && (buf[start_pos + 1] == 'U' || buf[start_pos + 1] == 'u') && + (buf[start_pos + 2] == 'L' || buf[start_pos + 2] == 'l') && + (buf[start_pos + 3] == 'L' || buf[start_pos + 3] == 'l')) { FlatVector::SetNull(child, row_idx, true); return true; } diff --git a/test/sql/types/struct/struct_cast.test b/test/sql/types/struct/struct_cast.test index 91303e432a0..2046e00a392 100644 --- a/test/sql/types/struct/struct_cast.test +++ b/test/sql/types/struct/struct_cast.test @@ -112,3 +112,43 @@ SELECT s::ROW(i BIGINT, j ROW(a BIGINT, b VARCHAR)) FROM nested_structs {'i': 1, 'j': {'a': 2, 'b': NULL}} {'i': 1, 'j': NULL} NULL + +# Issue #12939, NULL used to be case-sensitive +# Testing all permutations for fun +query I +SELECT col::STRUCT(duck INT) +FROM VALUES + ('{"duck": null}'), + ('{"duck": nulL}'), + ('{"duck": nuLl}'), + ('{"duck": nuLL}'), + ('{"duck": nUll}'), + ('{"duck": nUlL}'), + ('{"duck": nULl}'), + ('{"duck": nULL}'), + ('{"duck": Null}'), + ('{"duck": NulL}'), + ('{"duck": NuLl}'), + ('{"duck": NuLL}'), + ('{"duck": NUll}'), + ('{"duck": NUlL}'), + ('{"duck": NULl}'), + ('{"duck": NULL}'), +AS tab(col) +---- +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL} +{'duck': NULL}