Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #10140: NULL Constant Lists #10142

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Issue #10140: NULL Constant Lists
Don't copy the data for a NULL constant list
as it may not exist.

fixes: #10140
fixes: duckdblabs/duckdb-internal#1006
  • Loading branch information
hawkfish committed Jan 4, 2024
commit 600489aa33a032bed755651135ffd731e6d1b03b
11 changes: 7 additions & 4 deletions src/function/cast/list_casts.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading