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
20 changes: 10 additions & 10 deletions src/duckdb/extension/json/json_functions/json_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ static unique_ptr<FunctionData> JSONCreateBindParams(ScalarFunction &bound_funct
auto &type = arguments[i]->return_type;
if (arguments[i]->HasParameter()) {
throw ParameterNotResolvedException();
} else if (type == LogicalTypeId::SQLNULL) {
// This is needed for macro's
bound_function.arguments.push_back(type);
} else if (object && i % 2 == 0) {
// Key, must be varchar
if (type != LogicalType::VARCHAR) {
throw BinderException("json_object() keys must be VARCHAR, add an explicit cast to argument \"%s\"",
arguments[i]->GetName());
}
bound_function.arguments.push_back(LogicalType::VARCHAR);
} else {
// Value, cast to types that we can put in JSON
Expand All @@ -128,7 +128,7 @@ static unique_ptr<FunctionData> JSONCreateBindParams(ScalarFunction &bound_funct
static unique_ptr<FunctionData> JSONObjectBind(ClientContext &context, ScalarFunction &bound_function,
vector<unique_ptr<Expression>> &arguments) {
if (arguments.size() % 2 != 0) {
throw InvalidInputException("json_object() requires an even number of arguments");
throw BinderException("json_object() requires an even number of arguments");
}
return JSONCreateBindParams(bound_function, arguments, true);
}
Expand All @@ -141,37 +141,37 @@ static unique_ptr<FunctionData> JSONArrayBind(ClientContext &context, ScalarFunc
static unique_ptr<FunctionData> ToJSONBind(ClientContext &context, ScalarFunction &bound_function,
vector<unique_ptr<Expression>> &arguments) {
if (arguments.size() != 1) {
throw InvalidInputException("to_json() takes exactly one argument");
throw BinderException("to_json() takes exactly one argument");
}
return JSONCreateBindParams(bound_function, arguments, false);
}

static unique_ptr<FunctionData> ArrayToJSONBind(ClientContext &context, ScalarFunction &bound_function,
vector<unique_ptr<Expression>> &arguments) {
if (arguments.size() != 1) {
throw InvalidInputException("array_to_json() takes exactly one argument");
throw BinderException("array_to_json() takes exactly one argument");
}
auto arg_id = arguments[0]->return_type.id();
if (arguments[0]->HasParameter()) {
throw ParameterNotResolvedException();
}
if (arg_id != LogicalTypeId::LIST && arg_id != LogicalTypeId::SQLNULL) {
throw InvalidInputException("array_to_json() argument type must be LIST");
throw BinderException("array_to_json() argument type must be LIST");
}
return JSONCreateBindParams(bound_function, arguments, false);
}

static unique_ptr<FunctionData> RowToJSONBind(ClientContext &context, ScalarFunction &bound_function,
vector<unique_ptr<Expression>> &arguments) {
if (arguments.size() != 1) {
throw InvalidInputException("row_to_json() takes exactly one argument");
throw BinderException("row_to_json() takes exactly one argument");
}
auto arg_id = arguments[0]->return_type.id();
if (arguments[0]->HasParameter()) {
throw ParameterNotResolvedException();
}
if (arguments[0]->return_type.id() != LogicalTypeId::STRUCT && arg_id != LogicalTypeId::SQLNULL) {
throw InvalidInputException("row_to_json() argument type must be STRUCT");
throw BinderException("row_to_json() argument type must be STRUCT");
}
return JSONCreateBindParams(bound_function, arguments, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void PrimitiveColumnWriter::BeginWrite(ColumnWriterState &state_p) {
hdr.type = PageType::DATA_PAGE;
hdr.__isset.data_page_header = true;

hdr.data_page_header.num_values = UnsafeNumericCast<int32_t>(page_info.row_count);
hdr.data_page_header.num_values = NumericCast<int32_t>(page_info.row_count);
hdr.data_page_header.encoding = GetEncoding(state);
hdr.data_page_header.definition_level_encoding = Encoding::RLE;
hdr.data_page_header.repetition_level_encoding = Encoding::RLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ unique_ptr<LocalSinkState> PhysicalBufferedBatchCollector::GetLocalSinkState(Exe
unique_ptr<GlobalSinkState> PhysicalBufferedBatchCollector::GetGlobalSinkState(ClientContext &context) const {
auto state = make_uniq<BufferedBatchCollectorGlobalState>();
state->context = context.shared_from_this();
state->buffered_data = make_shared_ptr<BatchedBufferedData>(state->context);
state->buffered_data = make_shared_ptr<BatchedBufferedData>(context);
return std::move(state);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SinkCombineResultType PhysicalBufferedCollector::Combine(ExecutionContext &conte
unique_ptr<GlobalSinkState> PhysicalBufferedCollector::GetGlobalSinkState(ClientContext &context) const {
auto state = make_uniq<BufferedCollectorGlobalState>();
state->context = context.shared_from_this();
state->buffered_data = make_shared_ptr<SimpleBufferedData>(state->context);
state->buffered_data = make_shared_ptr<SimpleBufferedData>(context);
return std::move(state);
}

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 "2-dev63"
#define DUCKDB_PATCH_VERSION "2-dev86"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 4
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.4.2-dev63"
#define DUCKDB_VERSION "v1.4.2-dev86"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "50f3d64620"
#define DUCKDB_SOURCE_ID "d13e53bbb6"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BatchedBufferedData : public BufferedData {
static constexpr const BufferedData::Type TYPE = BufferedData::Type::BATCHED;

public:
explicit BatchedBufferedData(weak_ptr<ClientContext> context);
explicit BatchedBufferedData(ClientContext &context);

public:
void Append(const DataChunk &chunk, idx_t batch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BufferedData {
enum class Type { SIMPLE, BATCHED };

public:
BufferedData(Type type, weak_ptr<ClientContext> context_p);
BufferedData(Type type, ClientContext &context);
virtual ~BufferedData();

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SimpleBufferedData : public BufferedData {
static constexpr const BufferedData::Type TYPE = BufferedData::Type::SIMPLE;

public:
explicit SimpleBufferedData(weak_ptr<ClientContext> context);
explicit SimpleBufferedData(ClientContext &context);
~SimpleBufferedData() override;

public:
Expand Down
5 changes: 2 additions & 3 deletions src/duckdb/src/main/buffered_data/batched_buffered_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ void BatchedBufferedData::BlockSink(const InterruptState &blocked_sink, idx_t ba
blocked_sinks.emplace(batch, blocked_sink);
}

BatchedBufferedData::BatchedBufferedData(weak_ptr<ClientContext> context)
: BufferedData(BufferedData::Type::BATCHED, std::move(context)), buffer_byte_count(0), read_queue_byte_count(0),
min_batch(0) {
BatchedBufferedData::BatchedBufferedData(ClientContext &context)
: BufferedData(BufferedData::Type::BATCHED, context), buffer_byte_count(0), read_queue_byte_count(0), min_batch(0) {
read_queue_capacity = (idx_t)(static_cast<double>(total_buffer_size) * 0.6);
buffer_capacity = (idx_t)(static_cast<double>(total_buffer_size) * 0.4);
}
Expand Down
5 changes: 2 additions & 3 deletions src/duckdb/src/main/buffered_data/buffered_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

namespace duckdb {

BufferedData::BufferedData(Type type, weak_ptr<ClientContext> context_p) : type(type), context(std::move(context_p)) {
auto client_context = context.lock();
auto &config = ClientConfig::GetConfig(*client_context);
BufferedData::BufferedData(Type type, ClientContext &context_p) : type(type), context(context_p.shared_from_this()) {
auto &config = ClientConfig::GetConfig(context_p);
total_buffer_size = config.streaming_buffer_size;
}

Expand Down
3 changes: 1 addition & 2 deletions src/duckdb/src/main/buffered_data/simple_buffered_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

namespace duckdb {

SimpleBufferedData::SimpleBufferedData(weak_ptr<ClientContext> context)
: BufferedData(BufferedData::Type::SIMPLE, std::move(context)) {
SimpleBufferedData::SimpleBufferedData(ClientContext &context) : BufferedData(BufferedData::Type::SIMPLE, context) {
buffered_count = 0;
buffer_size = total_buffer_size;
}
Expand Down