Skip to content

Commit c0b9cd1

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 15fba9f47c
1 parent 6c8cf53 commit c0b9cd1

File tree

275 files changed

+21093
-12815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+21093
-12815
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ set(DUCKDB_SRC_FILES
158158
src/duckdb/ub_src_function.cpp
159159
src/duckdb/ub_src_function_cast.cpp
160160
src/duckdb/ub_src_function_cast_union.cpp
161+
src/duckdb/ub_src_function_cast_variant.cpp
161162
src/duckdb/ub_src_function_pragma.cpp
162163
src/duckdb/ub_src_function_scalar_compressed_materialization.cpp
163164
src/duckdb/ub_src_function_scalar.cpp
@@ -171,6 +172,7 @@ set(DUCKDB_SRC_FILES
171172
src/duckdb/ub_src_function_scalar_string_regexp.cpp
172173
src/duckdb/ub_src_function_scalar_struct.cpp
173174
src/duckdb/ub_src_function_scalar_system.cpp
175+
src/duckdb/ub_src_function_scalar_variant.cpp
174176
src/duckdb/ub_src_function_table_arrow.cpp
175177
src/duckdb/ub_src_function_table.cpp
176178
src/duckdb/ub_src_function_table_system.cpp

src/duckdb/extension/core_functions/scalar/string/instr.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ static unique_ptr<BaseStatistics> InStrPropagateStats(ClientContext &context, Fu
5050
}
5151

5252
ScalarFunction InstrFun::GetFunction() {
53-
return ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR}, LogicalType::BIGINT,
54-
ScalarFunction::BinaryFunction<string_t, string_t, int64_t, InstrOperator>, nullptr, nullptr,
55-
InStrPropagateStats);
53+
auto function = ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR}, LogicalType::BIGINT,
54+
ScalarFunction::BinaryFunction<string_t, string_t, int64_t, InstrOperator>, nullptr,
55+
nullptr, InStrPropagateStats);
56+
function.collation_handling = FunctionCollationHandling::PUSH_COMBINABLE_COLLATIONS;
57+
return function;
5658
}
5759

5860
} // namespace duckdb

src/duckdb/extension/json/include/json_common.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,19 @@ struct JSONCommon {
353353

354354
template <>
355355
inline char *JSONCommon::WriteVal(yyjson_val *val, yyjson_alc *alc, idx_t &len) {
356-
return yyjson_val_write_opts(val, JSONCommon::WRITE_FLAG, alc, reinterpret_cast<size_t *>(&len), nullptr);
356+
size_t len_size_t;
357+
// yyjson_val_write_opts must not throw
358+
auto ret = yyjson_val_write_opts(val, JSONCommon::WRITE_FLAG, alc, &len_size_t, nullptr);
359+
len = len_size_t;
360+
return ret;
357361
}
358362
template <>
359363
inline char *JSONCommon::WriteVal(yyjson_mut_val *val, yyjson_alc *alc, idx_t &len) {
360-
return yyjson_mut_val_write_opts(val, JSONCommon::WRITE_FLAG, alc, reinterpret_cast<size_t *>(&len), nullptr);
364+
size_t len_size_t;
365+
// yyjson_mut_val_write_opts must not throw
366+
auto ret = yyjson_mut_val_write_opts(val, JSONCommon::WRITE_FLAG, alc, &len_size_t, nullptr);
367+
len = len_size_t;
368+
return ret;
361369
}
362370

363371
struct yyjson_doc_deleter {

src/duckdb/extension/json/json_functions/copy_json.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ static void ThrowJSONCopyParameterException(const string &loption) {
1818
}
1919

2020
static BoundStatement CopyToJSONPlan(Binder &binder, CopyStatement &stmt) {
21+
static const unordered_set<string> SUPPORTED_BASE_OPTIONS {
22+
"compression", "encoding", "use_tmp_file", "overwrite_or_ignore", "overwrite", "append", "filename_pattern",
23+
"file_extension", "per_thread_output", "file_size_bytes",
24+
// "partition_by", unsupported
25+
"return_files", "preserve_order", "return_stats", "write_partition_columns", "write_empty_file",
26+
"hive_file_pattern"};
27+
2128
auto stmt_copy = stmt.Copy();
2229
auto &copy = stmt_copy->Cast<CopyStatement>();
2330
auto &copied_info = *copy.info;
@@ -48,9 +55,7 @@ static BoundStatement CopyToJSONPlan(Binder &binder, CopyStatement &stmt) {
4855
csv_copy_options["suffix"] = {"\n]\n"};
4956
csv_copy_options["new_line"] = {",\n\t"};
5057
}
51-
} else if (loption == "compression" || loption == "encoding" || loption == "per_thread_output" ||
52-
loption == "file_size_bytes" || loption == "use_tmp_file" || loption == "overwrite_or_ignore" ||
53-
loption == "filename_pattern" || loption == "file_extension") {
58+
} else if (SUPPORTED_BASE_OPTIONS.find(loption) != SUPPORTED_BASE_OPTIONS.end()) {
5459
// We support these base options
5560
csv_copy_options.insert(kv);
5661
} else {

src/duckdb/extension/json/json_functions/json_create.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ static void CreateValues(const StructNames &names, yyjson_mut_doc *doc, yyjson_m
608608
case LogicalTypeId::ANY:
609609
case LogicalTypeId::USER:
610610
case LogicalTypeId::TEMPLATE:
611+
case LogicalTypeId::VARIANT:
611612
case LogicalTypeId::CHAR:
612613
case LogicalTypeId::STRING_LITERAL:
613614
case LogicalTypeId::INTEGER_LITERAL:

src/duckdb/extension/json/json_functions/json_pretty.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace duckdb {
55
//! Pretty Print a given JSON Document
66
string_t PrettyPrint(yyjson_val *val, yyjson_alc *alc, Vector &, ValidityMask &, idx_t) {
77
D_ASSERT(alc);
8-
idx_t len;
9-
auto data =
10-
yyjson_val_write_opts(val, JSONCommon::WRITE_PRETTY_FLAG, alc, reinterpret_cast<size_t *>(&len), nullptr);
8+
size_t len_size_t;
9+
auto data = yyjson_val_write_opts(val, JSONCommon::WRITE_PRETTY_FLAG, alc, &len_size_t, nullptr);
10+
idx_t len = len_size_t;
1111
return string_t(data, len);
1212
}
1313

src/duckdb/extension/json/json_functions/json_serialize_plan.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,11 @@ static void JsonSerializePlanFunction(DataChunk &args, ExpressionState &state, V
162162
yyjson_mut_obj_add_false(doc, result_obj, "error");
163163
yyjson_mut_obj_add_val(doc, result_obj, "plans", plans_arr);
164164

165-
idx_t len;
165+
size_t len_size_t;
166166
auto data = yyjson_mut_val_write_opts(result_obj,
167167
info.format ? JSONCommon::WRITE_PRETTY_FLAG : JSONCommon::WRITE_FLAG,
168-
alc, reinterpret_cast<size_t *>(&len), nullptr);
168+
alc, &len_size_t, nullptr);
169+
idx_t len = len_size_t;
169170
if (data == nullptr) {
170171
throw SerializationException(
171172
"Failed to serialize json, perhaps the query contains invalid utf8 characters?");
@@ -185,10 +186,11 @@ static void JsonSerializePlanFunction(DataChunk &args, ExpressionState &state, V
185186
yyjson_mut_obj_add_strcpy(doc, result_obj, entry.first.c_str(), entry.second.c_str());
186187
}
187188

188-
idx_t len;
189+
size_t len_size_t;
189190
auto data = yyjson_mut_val_write_opts(result_obj,
190191
info.format ? JSONCommon::WRITE_PRETTY_FLAG : JSONCommon::WRITE_FLAG,
191-
alc, reinterpret_cast<size_t *>(&len), nullptr);
192+
alc, &len_size_t, nullptr);
193+
idx_t len = len_size_t;
192194
return StringVector::AddString(result, data, len);
193195
}
194196
});

src/duckdb/extension/json/json_functions/json_serialize_sql.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ static void JsonSerializeFunction(DataChunk &args, ExpressionState &state, Vecto
114114

115115
yyjson_mut_obj_add_false(doc, result_obj, "error");
116116
yyjson_mut_obj_add_val(doc, result_obj, "statements", statements_arr);
117-
idx_t len;
117+
size_t len_size_t;
118118
auto data = yyjson_mut_val_write_opts(result_obj,
119119
info.format ? JSONCommon::WRITE_PRETTY_FLAG : JSONCommon::WRITE_FLAG,
120-
alc, reinterpret_cast<size_t *>(&len), nullptr);
120+
alc, &len_size_t, nullptr);
121+
idx_t len = len_size_t;
121122
if (data == nullptr) {
122123
throw SerializationException(
123124
"Failed to serialize json, perhaps the query contains invalid utf8 characters?");
@@ -135,10 +136,11 @@ static void JsonSerializeFunction(DataChunk &args, ExpressionState &state, Vecto
135136
yyjson_mut_obj_add_strcpy(doc, result_obj, entry.first.c_str(), entry.second.c_str());
136137
}
137138

138-
idx_t len;
139+
size_t len_size_t;
139140
auto data = yyjson_mut_val_write_opts(result_obj,
140141
info.format ? JSONCommon::WRITE_PRETTY_FLAG : JSONCommon::WRITE_FLAG,
141-
alc, reinterpret_cast<size_t *>(&len), nullptr);
142+
alc, &len_size_t, nullptr);
143+
idx_t len = len_size_t;
142144
return StringVector::AddString(result, data, len);
143145
}
144146
});

src/duckdb/extension/json/json_functions/json_table_in_out.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ static void InitializeLocalState(JSONTableInOutLocalState &lstate, DataChunk &in
244244
// Parse path, default to root if not given
245245
Value path_value("$");
246246
if (input.data.size() > 1) {
247-
path_value = ConstantVector::GetData<string_t>(input.data[1])[0];
247+
auto &path_vector = input.data[1];
248+
if (ConstantVector::IsNull(path_vector)) {
249+
return;
250+
}
251+
path_value = ConstantVector::GetData<string_t>(path_vector)[0];
248252
}
249253

250254
if (JSONReadFunctionData::CheckPath(path_value, lstate.path, lstate.len) == JSONCommon::JSONPathType::WILDCARD) {

src/duckdb/extension/parquet/column_reader.cpp

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ void ColumnReader::InitializeRead(idx_t row_group_idx_p, const vector<ColumnChun
192192
D_ASSERT(chunk->__isset.meta_data);
193193

194194
if (chunk->__isset.file_path) {
195-
throw std::runtime_error("Only inlined data files are supported (no references)");
195+
throw InvalidInputException("Failed to read file \"%s\": Only inlined data files are supported (no references)",
196+
Reader().GetFileName());
196197
}
197198

198199
// ugh. sometimes there is an extra offset for the dict. sometimes it's wrong.
@@ -252,7 +253,7 @@ void ColumnReader::PrepareRead(optional_ptr<const TableFilter> filter, optional_
252253
}
253254
// some basic sanity check
254255
if (page_hdr.compressed_page_size < 0 || page_hdr.uncompressed_page_size < 0) {
255-
throw std::runtime_error("Page sizes can't be < 0");
256+
throw InvalidInputException("Failed to read file \"%s\": Page sizes can't be < 0", Reader().GetFileName());
256257
}
257258

258259
if (PageIsFilteredOut(page_hdr)) {
@@ -273,7 +274,8 @@ void ColumnReader::PrepareRead(optional_ptr<const TableFilter> filter, optional_
273274
PreparePage(page_hdr);
274275
auto dictionary_size = page_hdr.dictionary_page_header.num_values;
275276
if (dictionary_size < 0) {
276-
throw std::runtime_error("Invalid dictionary page header (num_values < 0)");
277+
throw InvalidInputException("Failed to read file \"%s\": Invalid dictionary page header (num_values < 0)",
278+
Reader().GetFileName());
277279
}
278280
dictionary_decoder.InitializeDictionary(dictionary_size, filter, filter_state, HasDefines());
279281
break;
@@ -297,7 +299,7 @@ void ColumnReader::PreparePageV2(PageHeader &page_hdr) {
297299
}
298300
if (chunk->meta_data.codec == CompressionCodec::UNCOMPRESSED) {
299301
if (page_hdr.compressed_page_size != page_hdr.uncompressed_page_size) {
300-
throw std::runtime_error("Page size mismatch");
302+
throw InvalidInputException("Failed to read file \"%s\": Page size mismatch", Reader().GetFileName());
301303
}
302304
uncompressed = true;
303305
}
@@ -310,8 +312,10 @@ void ColumnReader::PreparePageV2(PageHeader &page_hdr) {
310312
auto uncompressed_bytes = page_hdr.data_page_header_v2.repetition_levels_byte_length +
311313
page_hdr.data_page_header_v2.definition_levels_byte_length;
312314
if (uncompressed_bytes > page_hdr.uncompressed_page_size) {
313-
throw std::runtime_error("Page header inconsistency, uncompressed_page_size needs to be larger than "
314-
"repetition_levels_byte_length + definition_levels_byte_length");
315+
throw InvalidInputException(
316+
"Failed to read file \"%s\": header inconsistency, uncompressed_page_size needs to be larger than "
317+
"repetition_levels_byte_length + definition_levels_byte_length",
318+
Reader().GetFileName());
315319
}
316320
reader.ReadData(*protocol, block->ptr, uncompressed_bytes);
317321

@@ -368,7 +372,8 @@ void ColumnReader::DecompressInternal(CompressionCodec::type codec, const_data_p
368372
duckdb_lz4::LZ4_decompress_safe(const_char_ptr_cast(src), char_ptr_cast(dst),
369373
UnsafeNumericCast<int32_t>(src_size), UnsafeNumericCast<int32_t>(dst_size));
370374
if (res != NumericCast<int>(dst_size)) {
371-
throw std::runtime_error("LZ4 decompression failure");
375+
throw InvalidInputException("Failed to read file \"%s\": LZ4 decompression failure",
376+
Reader().GetFileName());
372377
}
373378
break;
374379
}
@@ -377,22 +382,27 @@ void ColumnReader::DecompressInternal(CompressionCodec::type codec, const_data_p
377382
size_t uncompressed_size = 0;
378383
auto res = duckdb_snappy::GetUncompressedLength(const_char_ptr_cast(src), src_size, &uncompressed_size);
379384
if (!res) {
380-
throw std::runtime_error("Snappy decompression failure");
385+
throw InvalidInputException("Failed to read file \"%s\": Snappy decompression failure",
386+
Reader().GetFileName());
381387
}
382388
if (uncompressed_size != dst_size) {
383-
throw std::runtime_error("Snappy decompression failure: Uncompressed data size mismatch");
389+
throw InvalidInputException(
390+
"Failed to read file \"%s\": Snappy decompression failure: Uncompressed data size mismatch",
391+
Reader().GetFileName());
384392
}
385393
}
386394
auto res = duckdb_snappy::RawUncompress(const_char_ptr_cast(src), src_size, char_ptr_cast(dst));
387395
if (!res) {
388-
throw std::runtime_error("Snappy decompression failure");
396+
throw InvalidInputException("Failed to read file \"%s\": Snappy decompression failure",
397+
Reader().GetFileName());
389398
}
390399
break;
391400
}
392401
case CompressionCodec::ZSTD: {
393402
auto res = duckdb_zstd::ZSTD_decompress(dst, dst_size, src, src_size);
394403
if (duckdb_zstd::ZSTD_isError(res) || res != dst_size) {
395-
throw std::runtime_error("ZSTD Decompression failure");
404+
throw InvalidInputException("Failed to read file \"%s\": ZSTD Decompression failure",
405+
Reader().GetFileName());
396406
}
397407
break;
398408
}
@@ -405,7 +415,8 @@ void ColumnReader::DecompressInternal(CompressionCodec::type codec, const_data_p
405415
auto res = duckdb_brotli::BrotliDecoderDecompressStream(state, &src_size_size_t, &src, &dst_size_size_t, &dst,
406416
&total_out);
407417
if (res != duckdb_brotli::BROTLI_DECODER_RESULT_SUCCESS) {
408-
throw std::runtime_error("Brotli Decompression failure");
418+
throw InvalidInputException("Failed to read file \"%s\": Brotli Decompression failure",
419+
Reader().GetFileName());
409420
}
410421
duckdb_brotli::BrotliDecoderDestroyInstance(state);
411422
break;
@@ -414,18 +425,21 @@ void ColumnReader::DecompressInternal(CompressionCodec::type codec, const_data_p
414425
default: {
415426
duckdb::stringstream codec_name;
416427
codec_name << codec;
417-
throw std::runtime_error("Unsupported compression codec \"" + codec_name.str() +
418-
"\". Supported options are uncompressed, brotli, gzip, lz4_raw, snappy or zstd");
428+
throw InvalidInputException("Failed to read file \"%s\": Unsupported compression codec \"%s\". Supported "
429+
"options are uncompressed, brotli, gzip, lz4_raw, snappy or zstd",
430+
Reader().GetFileName(), codec_name.str());
419431
}
420432
}
421433
}
422434

423435
void ColumnReader::PrepareDataPage(PageHeader &page_hdr) {
424436
if (page_hdr.type == PageType::DATA_PAGE && !page_hdr.__isset.data_page_header) {
425-
throw std::runtime_error("Missing data page header from data page");
437+
throw InvalidInputException("Failed to read file \"%s\": Missing data page header from data page",
438+
Reader().GetFileName());
426439
}
427440
if (page_hdr.type == PageType::DATA_PAGE_V2 && !page_hdr.__isset.data_page_header_v2) {
428-
throw std::runtime_error("Missing data page header from data page v2");
441+
throw InvalidInputException("Failed to read file \"%s\": Missing data page header from data page v2",
442+
Reader().GetFileName());
429443
}
430444

431445
bool is_v1 = page_hdr.type == PageType::DATA_PAGE;
@@ -492,7 +506,7 @@ void ColumnReader::PrepareDataPage(PageHeader &page_hdr) {
492506
break;
493507

494508
default:
495-
throw std::runtime_error("Unsupported page encoding");
509+
throw InvalidInputException("Failed to read file \"%s\": Unsupported page encoding", Reader().GetFileName());
496510
}
497511
}
498512

0 commit comments

Comments
 (0)