Skip to content

Commit

Permalink
Merge pull request #90 from duckdb/f-upgrade-3
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Feb 27, 2024
2 parents 4a82721 + 8735f7c commit 03c2306
Show file tree
Hide file tree
Showing 212 changed files with 3,243 additions and 1,994 deletions.
2 changes: 1 addition & 1 deletion rconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def open_utf8(fpath, flags):

include_list += " -DDUCKDB_PLATFORM_RTOOLS=1"
text = text.replace('{{ INCLUDES }}', include_list)
text = text.replace('{{ LINK_FLAGS }}', "-lws2_32")
text = text.replace('{{ LINK_FLAGS }}', "-lws2_32 -lrstrtmgr")

# now write it to the output Makevars
with open_utf8(os.path.join('src', 'Makevars.win'), 'w+') as f:
Expand Down
5 changes: 4 additions & 1 deletion src/duckdb/extension/parquet/parquet_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,10 @@ class ParquetScanFunction {

static idx_t ParquetScanMaxThreads(ClientContext &context, const FunctionData *bind_data) {
auto &data = bind_data->Cast<ParquetReadBindData>();
return std::max(data.initial_file_row_groups, idx_t(1)) * data.files.size();
if (data.files.size() > 1) {
return TaskScheduler::GetScheduler(context).NumberOfThreads();
}
return MaxValue(data.initial_file_row_groups, (idx_t)1);
}

// This function looks for the next available row group. If not available, it will open files from bind_data.files
Expand Down
22 changes: 14 additions & 8 deletions src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ unique_ptr<CreateInfo> TypeCatalogEntry::GetInfo() const {
}

string TypeCatalogEntry::ToSQL() const {
switch (user_type.id()) {
case (LogicalTypeId::ENUM): {
auto create_type_info = GetInfo();
return create_type_info->ToString();
}
default:
throw InternalException("Logical Type can't be used as a User Defined Type");
}
std::stringstream ss;
ss << "CREATE TYPE ";
ss << KeywordHelper::WriteOptionallyQuoted(name);
ss << " AS ";

auto user_type_copy = user_type;

// Strip off the potential alias so ToString doesn't just output the alias
user_type_copy.SetAlias("");
D_ASSERT(user_type_copy.GetAlias().empty());

ss << user_type_copy.ToString();
ss << ";";
return ss.str();
}

} // namespace duckdb
2 changes: 2 additions & 0 deletions src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void ViewCatalogEntry::Initialize(CreateViewInfo &info) {
query = std::move(info.query);
this->aliases = info.aliases;
this->types = info.types;
this->names = info.names;
this->temporary = info.temporary;
this->sql = info.sql;
this->internal = info.internal;
Expand All @@ -32,6 +33,7 @@ unique_ptr<CreateInfo> ViewCatalogEntry::GetInfo() const {
result->sql = sql;
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
result->aliases = aliases;
result->names = names;
result->types = types;
result->temporary = temporary;
result->comment = comment;
Expand Down
19 changes: 15 additions & 4 deletions src/duckdb/src/common/arrow/arrow_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ int ResultArrowArrayStreamWrapper::MyStreamGetSchema(struct ArrowArrayStream *st
if (!stream->release) {
return -1;
}
out->release = nullptr;
auto my_stream = reinterpret_cast<ResultArrowArrayStreamWrapper *>(stream->private_data);
if (!my_stream->column_types.empty()) {
ArrowConverter::ToArrowSchema(out, my_stream->column_types, my_stream->column_names,
my_stream->result->client_properties);
try {
ArrowConverter::ToArrowSchema(out, my_stream->column_types, my_stream->column_names,
my_stream->result->client_properties);
} catch (std::runtime_error &e) {
my_stream->last_error = ErrorData(e);
return -1;
}
return 0;
}

Expand All @@ -89,8 +95,13 @@ int ResultArrowArrayStreamWrapper::MyStreamGetSchema(struct ArrowArrayStream *st
my_stream->column_types = result.types;
my_stream->column_names = result.names;
}
ArrowConverter::ToArrowSchema(out, my_stream->column_types, my_stream->column_names,
my_stream->result->client_properties);
try {
ArrowConverter::ToArrowSchema(out, my_stream->column_types, my_stream->column_names,
my_stream->result->client_properties);
} catch (std::runtime_error &e) {
my_stream->last_error = ErrorData(e);
return -1;
}
return 0;
}

Expand Down
108 changes: 79 additions & 29 deletions src/duckdb/src/common/enum_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "duckdb/common/enums/join_type.hpp"
#include "duckdb/common/enums/joinref_type.hpp"
#include "duckdb/common/enums/logical_operator_type.hpp"
#include "duckdb/common/enums/memory_tag.hpp"
#include "duckdb/common/enums/on_create_conflict.hpp"
#include "duckdb/common/enums/on_entry_not_found.hpp"
#include "duckdb/common/enums/operator_result_type.hpp"
Expand Down Expand Up @@ -62,7 +63,6 @@
#include "duckdb/common/types/conflict_manager.hpp"
#include "duckdb/common/types/hyperloglog.hpp"
#include "duckdb/common/types/row/partitioned_tuple_data.hpp"
#include "duckdb/common/types/row/tuple_data_collection.hpp"
#include "duckdb/common/types/row/tuple_data_states.hpp"
#include "duckdb/common/types/timestamp.hpp"
#include "duckdb/common/types/vector.hpp"
Expand Down Expand Up @@ -3483,6 +3483,79 @@ MapInvalidReason EnumUtil::FromString<MapInvalidReason>(const char *value) {
throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
}

template<>
const char* EnumUtil::ToChars<MemoryTag>(MemoryTag value) {
switch(value) {
case MemoryTag::BASE_TABLE:
return "BASE_TABLE";
case MemoryTag::HASH_TABLE:
return "HASH_TABLE";
case MemoryTag::PARQUET_READER:
return "PARQUET_READER";
case MemoryTag::CSV_READER:
return "CSV_READER";
case MemoryTag::ORDER_BY:
return "ORDER_BY";
case MemoryTag::ART_INDEX:
return "ART_INDEX";
case MemoryTag::COLUMN_DATA:
return "COLUMN_DATA";
case MemoryTag::METADATA:
return "METADATA";
case MemoryTag::OVERFLOW_STRINGS:
return "OVERFLOW_STRINGS";
case MemoryTag::IN_MEMORY_TABLE:
return "IN_MEMORY_TABLE";
case MemoryTag::ALLOCATOR:
return "ALLOCATOR";
case MemoryTag::EXTENSION:
return "EXTENSION";
default:
throw NotImplementedException(StringUtil::Format("Enum value: '%d' not implemented", value));
}
}

template<>
MemoryTag EnumUtil::FromString<MemoryTag>(const char *value) {
if (StringUtil::Equals(value, "BASE_TABLE")) {
return MemoryTag::BASE_TABLE;
}
if (StringUtil::Equals(value, "HASH_TABLE")) {
return MemoryTag::HASH_TABLE;
}
if (StringUtil::Equals(value, "PARQUET_READER")) {
return MemoryTag::PARQUET_READER;
}
if (StringUtil::Equals(value, "CSV_READER")) {
return MemoryTag::CSV_READER;
}
if (StringUtil::Equals(value, "ORDER_BY")) {
return MemoryTag::ORDER_BY;
}
if (StringUtil::Equals(value, "ART_INDEX")) {
return MemoryTag::ART_INDEX;
}
if (StringUtil::Equals(value, "COLUMN_DATA")) {
return MemoryTag::COLUMN_DATA;
}
if (StringUtil::Equals(value, "METADATA")) {
return MemoryTag::METADATA;
}
if (StringUtil::Equals(value, "OVERFLOW_STRINGS")) {
return MemoryTag::OVERFLOW_STRINGS;
}
if (StringUtil::Equals(value, "IN_MEMORY_TABLE")) {
return MemoryTag::IN_MEMORY_TABLE;
}
if (StringUtil::Equals(value, "ALLOCATOR")) {
return MemoryTag::ALLOCATOR;
}
if (StringUtil::Equals(value, "EXTENSION")) {
return MemoryTag::EXTENSION;
}
throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
}

template<>
const char* EnumUtil::ToChars<NType>(NType value) {
switch(value) {
Expand Down Expand Up @@ -4138,6 +4211,8 @@ const char* EnumUtil::ToChars<PendingExecutionResult>(PendingExecutionResult val
return "RESULT_NOT_READY";
case PendingExecutionResult::EXECUTION_ERROR:
return "EXECUTION_ERROR";
case PendingExecutionResult::BLOCKED:
return "BLOCKED";
case PendingExecutionResult::NO_TASKS_AVAILABLE:
return "NO_TASKS_AVAILABLE";
default:
Expand All @@ -4156,6 +4231,9 @@ PendingExecutionResult EnumUtil::FromString<PendingExecutionResult>(const char *
if (StringUtil::Equals(value, "EXECUTION_ERROR")) {
return PendingExecutionResult::EXECUTION_ERROR;
}
if (StringUtil::Equals(value, "BLOCKED")) {
return PendingExecutionResult::BLOCKED;
}
if (StringUtil::Equals(value, "NO_TASKS_AVAILABLE")) {
return PendingExecutionResult::NO_TASKS_AVAILABLE;
}
Expand Down Expand Up @@ -6863,33 +6941,5 @@ WindowExcludeMode EnumUtil::FromString<WindowExcludeMode>(const char *value) {
throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
}

template<>
const char* EnumUtil::ToChars<WithinCollection>(WithinCollection value) {
switch(value) {
case WithinCollection::NO:
return "NO";
case WithinCollection::LIST:
return "LIST";
case WithinCollection::ARRAY:
return "ARRAY";
default:
throw NotImplementedException(StringUtil::Format("Enum value: '%d' not implemented", value));
}
}

template<>
WithinCollection EnumUtil::FromString<WithinCollection>(const char *value) {
if (StringUtil::Equals(value, "NO")) {
return WithinCollection::NO;
}
if (StringUtil::Equals(value, "LIST")) {
return WithinCollection::LIST;
}
if (StringUtil::Equals(value, "ARRAY")) {
return WithinCollection::ARRAY;
}
throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
}

}

10 changes: 10 additions & 0 deletions src/duckdb/src/common/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ string Exception::ToJSON(ExceptionType type, const string &message) {
}

string Exception::ToJSON(ExceptionType type, const string &message, const unordered_map<string, string> &extra_info) {
#ifdef DUCKDB_DEBUG_STACKTRACE
auto extended_extra_info = extra_info;
extended_extra_info["stack_trace"] = Exception::GetStackTrace();
return StringUtil::ToJSONMap(type, message, extended_extra_info);
#else
return StringUtil::ToJSONMap(type, message, extra_info);
#endif
}

bool Exception::UncaughtException() {
Expand Down Expand Up @@ -301,6 +307,10 @@ DependencyException::DependencyException(const string &msg) : Exception(Exceptio
IOException::IOException(const string &msg) : Exception(ExceptionType::IO, msg) {
}

IOException::IOException(const string &msg, const unordered_map<string, string> &extra_info)
: Exception(ExceptionType::IO, msg, extra_info) {
}

MissingExtensionException::MissingExtensionException(const string &msg)
: Exception(ExceptionType::MISSING_EXTENSION, msg) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/src/common/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ string FileSystem::GetWorkingDirectory() {

string FileSystem::JoinPath(const string &a, const string &b) {
// FIXME: sanitize paths
return a + PathSeparator(a) + b;
return a.empty() ? b : a + PathSeparator(a) + b;
}

string FileSystem::ConvertSeparators(const string &path) {
Expand Down
Loading

0 comments on commit 03c2306

Please sign in to comment.