Skip to content

Commit

Permalink
Merge pull request #10142 from hawkfish/list-cast
Browse files Browse the repository at this point in the history
Issue #10140: NULL Constant Lists
  • Loading branch information
Mytherin committed Jan 5, 2024
2 parents 731829d + 600489a commit 2663d50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/function/cast/list_casts.cpp
Expand Up @@ -38,11 +38,14 @@ bool ListCast::ListToListCast(Vector &source, Vector &result, idx_t count, CastP
// only handle constant and flat vectors here for now
if (source.GetVectorType() == VectorType::CONSTANT_VECTOR) {
result.SetVectorType(source.GetVectorType());
ConstantVector::SetNull(result, ConstantVector::IsNull(source));
const bool is_null = ConstantVector::IsNull(source);
ConstantVector::SetNull(result, is_null);

auto ldata = ConstantVector::GetData<list_entry_t>(source);
auto tdata = ConstantVector::GetData<list_entry_t>(result);
*tdata = *ldata;
if (!is_null) {
auto ldata = ConstantVector::GetData<list_entry_t>(source);
auto tdata = ConstantVector::GetData<list_entry_t>(result);
*tdata = *ldata;
}
} else {
source.Flatten(count);
result.SetVectorType(VectorType::FLAT_VECTOR);
Expand Down
6 changes: 6 additions & 0 deletions test/fuzzer/duckfuzz/list_try_cast.test
Expand Up @@ -26,3 +26,9 @@ query I
SELECT TRY_CAST(v AS INTEGER[]) FROM strings;
----
[42, NULL, 84, NULL, 100]

# Issue #10140 (used to crash)
statement error
SELECT DISTINCT OPERATOR ( / ) + ARRAY [ ] :: INTERVAL SECONDS [ ] [ ] :: SETOF NCHAR ARRAY :: FLOAT ;
----
No function matches the given name and argument types

0 comments on commit 2663d50

Please sign in to comment.