Skip to content
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
5 changes: 2 additions & 3 deletions src/duckdb/extension/core_functions/scalar/date/date_part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2671,9 +2671,8 @@ ScalarFunctionSet HoursFun::GetFunctions() {
}

ScalarFunctionSet YearWeekFun::GetFunctions() {
auto set = GetDatePartFunction<DatePart::YearWeekOperator>();
set.SetUnaryArgProperties(ArgProperties().NonDecreasing());
return set;
// Not monotone on the full date domain: see YearWeekOperator::YearWeekFromParts.
return GetDatePartFunction<DatePart::YearWeekOperator>();
}

ScalarFunctionSet DayOfMonthFun::GetFunctions() {
Expand Down
12 changes: 12 additions & 0 deletions src/duckdb/extension/json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,16 @@ void JSONReader::PrepareForReadInternal(JSONReaderScanState &scan_state) {
if (!scan_state.read_buffer.IsSet()) {
scan_state.read_buffer = scan_state.global_allocator.Allocate(scan_state.buffer_capacity);
scan_state.buffer_ptr = char_ptr_cast(scan_state.read_buffer.get());
} else if (scan_state.read_buffer.GetSize() < scan_state.buffer_capacity) {
// the retained auto-detect buffer only holds what was read from the file - it cannot take a full read
auto buffer = scan_state.global_allocator.Allocate(scan_state.buffer_capacity);
if (scan_state.file_read_type == JSONFileReadType::SCAN_ENTIRE_FILE) {
memcpy(buffer.get(), scan_state.buffer_ptr + scan_state.prev_buffer_offset,
scan_state.prev_buffer_remainder);
}
scan_state.read_buffer = std::move(buffer);
scan_state.buffer_ptr = char_ptr_cast(scan_state.read_buffer.get());
return;
}
if (scan_state.file_read_type == JSONFileReadType::SCAN_ENTIRE_FILE) {
// Copy last bit of previous buffer to the beginning if we are doing a single-threaded read
Expand Down Expand Up @@ -1256,6 +1266,7 @@ void JSONReader::ReadNextBufferSeek(JSONReaderScanState &scan_state) {
}

// Now read the file lock-free!
D_ASSERT(read_offset + scan_state.read_size + YYJSON_PADDING_SIZE <= scan_state.read_buffer.GetSize());
file_handle.ReadAtPosition(scan_state.buffer_ptr + read_offset, scan_state.read_size, scan_state.read_position,
scan_state.thread_local_filehandle);
}
Expand Down Expand Up @@ -1284,6 +1295,7 @@ bool JSONReader::ReadNextBufferNoSeek(JSONReaderScanState &scan_state) {
}
scan_state.buffer_index = GetBufferIndex();
PrepareForReadInternal(scan_state);
D_ASSERT(read_offset + request_size + YYJSON_PADDING_SIZE <= scan_state.read_buffer.GetSize());
if (!file_handle.Read(scan_state.buffer_ptr + read_offset, read_size, request_size)) {
return false; // Couldn't read anything
}
Expand Down
8 changes: 4 additions & 4 deletions src/duckdb/generated_extension_loader_package_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int32_t duckdb_extension_core_functions_describe(duckdb_extension_descriptor *de
descriptor->version = 1;
descriptor->name = "core_functions";
descriptor->extension_version = EXT_VERSION_CORE_FUNCTIONS;
descriptor->api_version = "v2.0.0-alpha48780";
descriptor->api_version = "v2.0.0-alpha48877";
descriptor->entry_cpp = (void (*)(void))core_functions_duckdb_cpp_init;
return 0;
}
Expand Down Expand Up @@ -78,7 +78,7 @@ int32_t duckdb_extension_parquet_describe(duckdb_extension_descriptor *descripto
descriptor->version = 1;
descriptor->name = "parquet";
descriptor->extension_version = EXT_VERSION_PARQUET;
descriptor->api_version = "v2.0.0-alpha48780";
descriptor->api_version = "v2.0.0-alpha48877";
descriptor->entry_cpp = (void (*)(void))parquet_duckdb_cpp_init;
return 0;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ int32_t duckdb_extension_icu_describe(duckdb_extension_descriptor *descriptor) {
descriptor->version = 1;
descriptor->name = "icu";
descriptor->extension_version = EXT_VERSION_ICU;
descriptor->api_version = "v2.0.0-alpha48780";
descriptor->api_version = "v2.0.0-alpha48877";
descriptor->entry_cpp = (void (*)(void))icu_duckdb_cpp_init;
return 0;
}
Expand Down Expand Up @@ -144,7 +144,7 @@ int32_t duckdb_extension_json_describe(duckdb_extension_descriptor *descriptor)
descriptor->version = 1;
descriptor->name = "json";
descriptor->extension_version = EXT_VERSION_JSON;
descriptor->api_version = "v2.0.0-alpha48780";
descriptor->api_version = "v2.0.0-alpha48877";
descriptor->entry_cpp = (void (*)(void))json_duckdb_cpp_init;
return 0;
}
Expand Down
10 changes: 10 additions & 0 deletions src/duckdb/src/common/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,16 @@ string FileSystem::GetWorkingDirectory() {
#endif

string FileSystem::JoinPath(const string &a, const string &b) {
// A remote URL may carry a "?query" suffix (object version, requester-pays, an SSE-C key, ...).
// Appending a path segment after it would bury the query mid-path and corrupt both the query and
// the object path, so join onto the path without the query and keep the query at the very end.
auto scheme = a.find("://");
if (scheme != string::npos) {
auto query = a.find('?', scheme + 3);
if (query != string::npos) {
return Path::FromString(a.substr(0, query)).Join(b).ToString() + a.substr(query);
}
}
return Path::FromString(a).Join(b).ToString();
}

Expand Down
5 changes: 1 addition & 4 deletions src/duckdb/src/function/scalar/string/like.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ static bool GlobMatchesBracket(char s, const char *pattern, idx_t plen, idx_t &p
break;
}
bool matches;
if (pattern[pidx + 1] == '-') {
if (pattern[pidx + 1] == '-' && pidx + 2 < plen && pattern[pidx + 2] != ']') {
// range! find the next character in the range
if (pidx + 2 == plen) {
break;
}
auto next_char = pattern[pidx + 2];
// check if the current character is within the range
matches = s >= p && s <= next_char;
Expand Down
25 changes: 24 additions & 1 deletion src/duckdb/src/function/table/arrow_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,27 @@ static bool CanContainNull(const ArrowArray &array, const ValidityMask *parent_m
return parent_mask->CanHaveNull();
}

// Arrow's null type converts to a constant vector, and FlatVector::SetNull needs flat vectors along its recursion
// into STRUCT and ARRAY children, which never reaches LIST contents.
static void FlattenForSetNull(Vector &vector) {
if (vector.GetVectorType() != VectorType::FLAT_VECTOR) {
vector.Flatten();
return;
}
switch (vector.GetType().InternalType()) {
case PhysicalType::STRUCT:
for (auto &entry : StructVector::GetEntries(vector)) {
FlattenForSetNull(entry);
}
break;
case PhysicalType::ARRAY:
FlattenForSetNull(ArrayVector::GetChildMutable(vector));
break;
default:
break;
}
}

void ArrowToDuckDBConversion::ColumnArrowToDuckDBDictionary(Vector &vector, ArrowArray &array, idx_t chunk_offset,
ArrowArrayScanState &array_state, idx_t size,
const ArrowType &arrow_type, int64_t nested_offset,
Expand All @@ -1476,7 +1497,6 @@ void ArrowToDuckDBConversion::ColumnArrowToDuckDBDictionary(Vector &vector, Arro
auto dict_length = NumericCast<idx_t>(array.dictionary->length);
auto base_vector = make_uniq<Vector>(vector.GetType(), dict_length + 1);
ArrowToDuckDBConversion::SetValidityMask(*base_vector, *array.dictionary, 0, dict_length, 0, 0, has_nulls);
FlatVector::ValidityMutable(*base_vector).SetInvalid(dict_length);
auto &dictionary_type = arrow_type.GetDictionary();
auto arrow_physical_type = dictionary_type.GetPhysicalType();
;
Expand All @@ -1502,6 +1522,9 @@ void ArrowToDuckDBConversion::ColumnArrowToDuckDBDictionary(Vector &vector, Arro
// dict_length. Re-extend before sizing so the sentinel slot stays in bounds.
base_vector->Reserve(dict_length + 1);
FlatVector::SetSize(*base_vector, count_t(dict_length + 1));
// nested children of the sentinel slot hold uninitialized data unless they are marked NULL as well
FlattenForSetNull(*base_vector);
FlatVector::SetNull(*base_vector, dict_length, true);
array_state.AddDictionary(std::move(base_vector), array.dictionary);
}
auto offset_type = arrow_type.GetDuckType();
Expand Down
30 changes: 20 additions & 10 deletions src/duckdb/src/function/table/system/duckdb_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ struct DuckDBSettingsData : public GlobalTableFunctionState {
struct DuckDBSettingsBindData : public TableFunctionData {
bool debug = false;
bool deprecated = false;
//! Ignore the debug and deprecated filters
bool include_all = false;

bool Includes(bool is_debug, bool is_deprecated) const {
return include_all || (debug == is_debug && deprecated == is_deprecated);
}
};

static unique_ptr<FunctionData> DuckDBSettingsBind(ClientContext &context, TableFunctionBindInput &input,
Expand All @@ -55,7 +61,7 @@ static unique_ptr<FunctionData> DuckDBSettingsBind(ClientContext &context, Table
return_types.emplace_back(LogicalType::VARIANT());

auto result = make_uniq<DuckDBSettingsBindData>();
for (auto name : {"debug", "deprecated"}) {
for (auto name : {"debug", "deprecated", "include_all"}) {
auto it = input.named_parameters.find(name);
if (it != input.named_parameters.end() && it->second.IsNull()) {
throw InvalidInputException("Cannot use NULL as argument for %s", name);
Expand All @@ -69,6 +75,14 @@ static unique_ptr<FunctionData> DuckDBSettingsBind(ClientContext &context, Table
result->deprecated = it->second.GetValue<bool>();
}

if (auto it = input.named_parameters.find("include_all"); it != input.named_parameters.end()) {
result->include_all = it->second.GetValue<bool>();
}
auto &params = input.named_parameters;
if (result->include_all && (params.find("debug") != params.end() || params.find("deprecated") != params.end())) {
throw InvalidInputException("Cannot combine include_all := true with the debug or deprecated filters");
}

return std::move(result);
}

Expand All @@ -87,10 +101,7 @@ unique_ptr<GlobalTableFunctionState> DuckDBSettingsInit(ClientContext &context,
for (idx_t i = 0; i < options_count; i++) {
auto option = DBConfig::GetOptionByIndex(i);
D_ASSERT(option);
if (bind_data.debug != option->is_debug) {
continue;
}
if (bind_data.deprecated != option->is_deprecated) {
if (!bind_data.Includes(option->is_debug, option->is_deprecated)) {
continue;
}
DuckDBSettingValue value;
Expand Down Expand Up @@ -122,10 +133,7 @@ unique_ptr<GlobalTableFunctionState> DuckDBSettingsInit(ClientContext &context,
result->settings.push_back(std::move(value));
}
for (auto &ext_param : config.GetExtensionSettings()) {
if (bind_data.debug != ext_param.second.is_debug) {
continue;
}
if (bind_data.deprecated != ext_param.second.is_deprecated) {
if (!bind_data.Includes(ext_param.second.is_debug, ext_param.second.is_deprecated)) {
continue;
}
Value setting_val;
Expand Down Expand Up @@ -189,7 +197,9 @@ void DuckDBSettingsFunction(ClientContext &context, TableFunctionInput &data_p,
void DuckDBSettingsFun::RegisterFunction(BuiltinFunctions &set) {
TableFunction settings_fun("duckdb_settings", {}, DuckDBSettingsFunction, DuckDBSettingsBind, DuckDBSettingsInit);
settings_fun.GetSignature().WithTypedKwargs("options", [](TypedKwargs &options) {
options.Add("debug", LogicalType::BOOLEAN).Add("deprecated", LogicalType::BOOLEAN);
options.Add("debug", LogicalType::BOOLEAN)
.Add("deprecated", LogicalType::BOOLEAN)
.Add("include_all", LogicalType::BOOLEAN);
});
set.AddFunction(settings_fun);
}
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/function/table/version/pragma_version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DUCKDB_PATCH_VERSION
#define DUCKDB_PATCH_VERSION "0-alpha48780"
#define DUCKDB_PATCH_VERSION "0-alpha48877"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 0
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 2
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v2.0.0-alpha48780"
#define DUCKDB_VERSION "v2.0.0-alpha48877"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "f8f3f4dcd9"
#define DUCKDB_SOURCE_ID "5bf940c131"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
Loading
Loading