Skip to content

Commit

Permalink
Merge branch 'duckdb:main' into window-progress
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkfish authored Apr 18, 2024
2 parents ce6d2cd + f6e169b commit eadb2cf
Show file tree
Hide file tree
Showing 345 changed files with 4,880 additions and 2,647 deletions.
2 changes: 1 addition & 1 deletion .github/config/extensions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ aws,https://github.com/duckdb/duckdb_aws,f7b8729f1cce5ada5d4add70e1486de50763fb9
azure,https://github.com/duckdb/duckdb_azure,09623777a366572bfb8fa53e47acdf72133a360e,
spatial,https://github.com/duckdb/duckdb_spatial,8ac803e986ccda34f32dee82a7faae95b72b3492,
iceberg,https://github.com/duckdb/duckdb_iceberg,d89423c2ff90a0b98a093a133c8dfe2a55b9e092,
vss,https://github.com/duckdb/duckdb_vss,9038b50cefb8bfd6b8ab8a254d3c728f3f172d15,
vss,https://github.com/duckdb/duckdb_vss,8145f41d97178e82bed3376215eb8d02bcf1eec5,
2 changes: 1 addition & 1 deletion .github/config/out_of_tree_extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ endif()
duckdb_extension_load(vss
LOAD_TESTS
GIT_URL https://github.com/duckdb/duckdb_vss
GIT_TAG 9038b50cefb8bfd6b8ab8a254d3c728f3f172d15
GIT_TAG 8145f41d97178e82bed3376215eb8d02bcf1eec5
TEST_DIR test/sql
)
32 changes: 22 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ if (EXTENSION_STATIC_BUILD AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif()

option(DISABLE_UNITY "Disable unity builds." FALSE)
option(USE_WASM_THREADS "Should threads be used" FALSE)
if (${USE_WASM_THREADS})
set(WASM_THREAD_FLAGS
-pthread
-sSHARED_MEMORY=1
)
endif()

option(FORCE_COLORED_OUTPUT
"Always produce ANSI-colored output (GNU/Clang only)." FALSE)
Expand Down Expand Up @@ -553,7 +560,6 @@ include_directories(third_party/fast_float)
include_directories(third_party/re2)
include_directories(third_party/miniz)
include_directories(third_party/utf8proc/include)
include_directories(third_party/miniparquet)
include_directories(third_party/concurrentqueue)
include_directories(third_party/pcg)
include_directories(third_party/tdigest)
Expand Down Expand Up @@ -810,10 +816,11 @@ function(build_loadable_extension_directory NAME OUTPUT_DIRECTORY EXTENSION_VERS
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${TARGET_NAME}> $<TARGET_FILE:${TARGET_NAME}>.lib
)
# Compile the library into the actual wasm file
string(TOUPPER ${NAME} EXTENSION_NAME_UPPERCASE)
add_custom_command(
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND emcc $<TARGET_FILE:${TARGET_NAME}>.lib -o $<TARGET_FILE:${TARGET_NAME}> -sSIDE_MODULE=1 -O3
COMMAND emcc $<TARGET_FILE:${TARGET_NAME}>.lib -o $<TARGET_FILE:${TARGET_NAME}> -O3 -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="_${NAME}_init" ${WASM_THREAD_FLAGS} ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS}
)
endif()
add_custom_command(
Expand Down Expand Up @@ -846,7 +853,7 @@ function(build_static_extension NAME PARAMETERS)
endfunction()

# Internal extension register function
function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH)
function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH LINKED_LIBS)
string(TOLOWER ${NAME} EXTENSION_NAME_LOWERCASE)
string(TOUPPER ${NAME} EXTENSION_NAME_UPPERCASE)

Expand All @@ -868,6 +875,8 @@ function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PA
endif()
endif()

set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS "${LINKED_LIBS}" PARENT_SCOPE)

# Allows explicitly disabling extensions that may be specified in other configurations
if (NOT ${DONT_BUILD} AND NOT ${EXTENSION_TESTS_ONLY})
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_SHOULD_BUILD TRUE PARENT_SCOPE)
Expand All @@ -893,7 +902,7 @@ function(register_extension NAME DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PA
endfunction()

# Downloads the external extension repo at the specified commit and calls register_extension
macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH APPLY_PATCHES SUBMODULES)
macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TESTS PATH INCLUDE_PATH TEST_PATH APPLY_PATCHES LINKED_LIBS SUBMODULES)
include(FetchContent)
if (${APPLY_PATCHES})
set(PATCH_COMMAND python3 ${CMAKE_SOURCE_DIR}/scripts/apply_extension_patches.py ${CMAKE_SOURCE_DIR}/.github/patches/extensions/${NAME}/)
Expand Down Expand Up @@ -921,6 +930,8 @@ macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TEST
endif()

message(STATUS "Load extension '${NAME}' from ${URL} @ ${GIT_SHORT_COMMIT}")

string(TOUPPER ${NAME} EXTENSION_NAME_UPPERCASE)
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "${GIT_SHORT_COMMIT}" PARENT_SCOPE)

if ("${INCLUDE_PATH}" STREQUAL "")
Expand All @@ -935,13 +946,13 @@ macro(register_external_extension NAME URL COMMIT DONT_LINK DONT_BUILD LOAD_TEST
set(TEST_FULL_PATH "${${NAME}_extension_fc_SOURCE_DIR}/${TEST_PATH}")
endif()

register_extension(${NAME} ${DONT_LINK} ${DONT_BUILD} ${LOAD_TESTS} ${${NAME}_extension_fc_SOURCE_DIR}/${PATH} "${INCLUDE_FULL_PATH}" "${TEST_FULL_PATH}")
register_extension(${NAME} ${DONT_LINK} ${DONT_BUILD} ${LOAD_TESTS} ${${NAME}_extension_fc_SOURCE_DIR}/${PATH} "${INCLUDE_FULL_PATH}" "${TEST_FULL_PATH}" "${LINKED_LIBS}")
endmacro()

function(duckdb_extension_load NAME)
# Parameter parsing
set(options DONT_LINK DONT_BUILD LOAD_TESTS APPLY_PATCHES)
set(oneValueArgs SOURCE_DIR INCLUDE_DIR TEST_DIR GIT_URL GIT_TAG SUBMODULES EXTENSION_VERSION)
set(oneValueArgs SOURCE_DIR INCLUDE_DIR TEST_DIR GIT_URL GIT_TAG SUBMODULES EXTENSION_VERSION LINKED_LIBS)
cmake_parse_arguments(duckdb_extension_load "${options}" "${oneValueArgs}" "" ${ARGN})

string(TOLOWER ${NAME} EXTENSION_NAME_LOWERCASE)
Expand All @@ -960,12 +971,12 @@ function(duckdb_extension_load NAME)

# Remote Git extension
if (${duckdb_extension_load_DONT_BUILD})
register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "" "" "" "")
register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "" "" "" "" "")
elseif (NOT "${duckdb_extension_load_GIT_URL}" STREQUAL "")
if ("${duckdb_extension_load_GIT_TAG}" STREQUAL "")
error("Git URL specified but no valid GIT_TAG was found for ${NAME} extension")
endif()
register_external_extension(${NAME} "${duckdb_extension_load_GIT_URL}" "${duckdb_extension_load_GIT_TAG}" "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${duckdb_extension_load_INCLUDE_DIR}" "${duckdb_extension_load_TEST_DIR}" "${duckdb_extension_load_APPLY_PATCHES}" "${duckdb_extension_load_SUBMODULES}")
register_external_extension(${NAME} "${duckdb_extension_load_GIT_URL}" "${duckdb_extension_load_GIT_TAG}" "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${duckdb_extension_load_INCLUDE_DIR}" "${duckdb_extension_load_TEST_DIR}" "${duckdb_extension_load_APPLY_PATCHES}" "${duckdb_extension_load_LINKED_LIBS}" "${duckdb_extension_load_SUBMODULES}")
if (NOT "${duckdb_extension_load_EXTENSION_VERSION}" STREQUAL "")
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "${duckdb_extension_load_EXTENSION_VERSION}" PARENT_SCOPE)
endif()
Expand Down Expand Up @@ -1003,7 +1014,7 @@ function(duckdb_extension_load NAME)
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "" PARENT_SCOPE)
endif()
endif()
register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${INCLUDE_PATH_DEFAULT}" "${TEST_PATH_DEFAULT}")
register_extension(${NAME} "${duckdb_extension_load_DONT_LINK}" "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${duckdb_extension_load_SOURCE_DIR}" "${INCLUDE_PATH_DEFAULT}" "${TEST_PATH_DEFAULT}" "${duckdb_extension_load_LINKED_LIBS}")
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/extension_external/${NAME})
# Local extension, default path
message(STATUS "Load extension '${NAME}' from '${CMAKE_CURRENT_SOURCE_DIR}/extension_external'")
Expand All @@ -1012,7 +1023,7 @@ function(duckdb_extension_load NAME)
else()
# Local extension, default path
message(STATUS "Load extension '${NAME}' from '${CMAKE_CURRENT_SOURCE_DIR}/extensions'")
register_extension(${NAME} ${duckdb_extension_load_DONT_LINK} "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/include" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/test/sql")
register_extension(${NAME} ${duckdb_extension_load_DONT_LINK} "${duckdb_extension_load_DONT_BUILD}" "${duckdb_extension_load_LOAD_TESTS}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/include" "${CMAKE_CURRENT_SOURCE_DIR}/extension/${NAME}/test/sql" "${duckdb_extension_load_LINKED_LIBS}")
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION "${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_EXT_VERSION}" PARENT_SCOPE)
endif()

Expand All @@ -1024,6 +1035,7 @@ function(duckdb_extension_load NAME)
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_PATH ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_PATH} PARENT_SCOPE)
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_INCLUDE_PATH ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_INCLUDE_PATH} PARENT_SCOPE)
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_TEST_PATH ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_TEST_PATH} PARENT_SCOPE)
set(DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS ${DUCKDB_EXTENSION_${EXTENSION_NAME_UPPERCASE}_LINKED_LIBS} PARENT_SCOPE)
endfunction()

if(${EXPORT_DLL_SYMBOLS})
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,17 @@ release: ${EXTENSION_CONFIG_STEP}

wasm_mvp: ${EXTENSION_CONFIG_STEP}
mkdir -p ./build/wasm_mvp && \
emcmake cmake $(GENERATOR) ${COMMON_CMAKE_VARS} -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_mvp -DCMAKE_CXX_FLAGS="-DDUCKDB_CUSTOM_PLATFORM=wasm_mvp" && \
emcmake cmake $(GENERATOR) -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_mvp -DCMAKE_CXX_FLAGS="-DDUCKDB_CUSTOM_PLATFORM=wasm_mvp" -DDUCKDB_EXPLICIT_PLATFORM="wasm_mvp" ${COMMON_CMAKE_VARS} ${TOOLCHAIN_FLAGS} && \
emmake make -j8 -Cbuild/wasm_mvp

wasm_eh: ${EXTENSION_CONFIG_STEP}
mkdir -p ./build/wasm_eh && \
emcmake cmake $(GENERATOR) ${COMMON_CMAKE_VARS} -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_eh -DCMAKE_CXX_FLAGS="-fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1 -DDUCKDB_CUSTOM_PLATFORM=wasm_eh" && \
emcmake cmake $(GENERATOR) -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_eh -DCMAKE_CXX_FLAGS="-fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1 -DDUCKDB_CUSTOM_PLATFORM=wasm_eh" -DDUCKDB_EXPLICIT_PLATFORM="wasm_eh" ${COMMON_CMAKE_VARS} ${TOOLCHAIN_FLAGS} && \
emmake make -j8 -Cbuild/wasm_eh

wasm_threads: ${EXTENSION_CONFIG_STEP}
mkdir -p ./build/wasm_threads && \
emcmake cmake $(GENERATOR) ${COMMON_CMAKE_VARS} -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_threads -DCMAKE_CXX_FLAGS="-fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1 -DWITH_WASM_THREADS=1 -DWITH_WASM_SIMD=1 -DWITH_WASM_BULK_MEMORY=1 -DDUCKDB_CUSTOM_PLATFORM=wasm_threads" && \
emcmake cmake $(GENERATOR) -DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -Bbuild/wasm_threads -DCMAKE_CXX_FLAGS="-fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1 -DWITH_WASM_THREADS=1 -DWITH_WASM_SIMD=1 -DWITH_WASM_BULK_MEMORY=1 -DDUCKDB_CUSTOM_PLATFORM=wasm_threads -pthread" -DDUCKDB_EXPLICIT_PLATFORM="wasm_threads" ${COMMON_CMAKE_VARS} -DUSE_WASM_THREADS=1 -DCMAKE_C_FLAGS="-pthread" ${TOOLCHAIN_FLAGS} && \
emmake make -j8 -Cbuild/wasm_threads

cldebug: ${EXTENSION_CONFIG_STEP}
Expand Down Expand Up @@ -443,7 +443,10 @@ generate-files:
python3 scripts/generate_functions.py
python3 scripts/generate_serialization.py
python3 scripts/generate_enum_util.py
python3 tools/pythonpkg/scripts/generate_connection_code.py
./scripts/generate_micro_extended.sh
# Run the formatter again after (re)generating the files
$(MAKE) format-main

bundle-library: release
cd build/release && \
Expand Down
2 changes: 2 additions & 0 deletions data/csv/decimal.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
col_a
3.5215257120407011
2 changes: 1 addition & 1 deletion extension/parquet/column_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void BasicColumnWriter::BeginWrite(ColumnWriterState &state_p) {
auto &page_info = state.page_info[page_idx];
if (page_info.row_count == 0) {
D_ASSERT(page_idx + 1 == state.page_info.size());
state.page_info.erase(state.page_info.begin() + page_idx);
state.page_info.erase_at(page_idx);
break;
}
PageWriteInformation write_info;
Expand Down
2 changes: 2 additions & 0 deletions extension/sqlsmith/statement_simplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ void StatementSimplifier::Simplify(unique_ptr<TableRef> &ref) {
SimplifyOptionalExpression(cp.condition);
SimplifyReplace(ref, cp.left);
SimplifyReplace(ref, cp.right);
SimplifyEnum(cp.type, JoinType::INNER);
SimplifyEnum(cp.ref_type, JoinRefType::REGULAR);
break;
}
case TableReferenceType::EXPRESSION_LIST: {
Expand Down
2 changes: 1 addition & 1 deletion scripts/reduce_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def reduce_query_log(queries, shell, max_time_seconds=300):
print(expected_error)
print("===================================================")

final_query = reduce(sql_query, data_load, shell, expected_error, args.max_time)
final_query = reduce(sql_query, data_load, shell, expected_error, int(args.max_time))
print("Found final reduced query")
print("===================================================")
print(final_query)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}"
STREQUAL "AppleClang")
set(EXIT_TIME_DESTRUCTORS_WARNING TRUE)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -Wexit-time-destructors -Wimplicit-int-conversion -Wshorten-64-to-32 -Wnarrowing"
"${CMAKE_CXX_FLAGS_DEBUG} -Wexit-time-destructors -Wimplicit-int-conversion -Wshorten-64-to-32 -Wnarrowing -Wsign-conversion -Wsign-compare"
)
endif()

Expand Down
4 changes: 2 additions & 2 deletions src/common/adbc/nanoarrow/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
namespace duckdb_nanoarrow {

void *ArrowMalloc(int64_t size) {
return malloc(size);
return malloc(size_t(size));
}

void *ArrowRealloc(void *ptr, int64_t size) {
return realloc(ptr, size);
return realloc(ptr, size_t(size));
}

void ArrowFree(void *ptr) {
Expand Down
6 changes: 3 additions & 3 deletions src/common/adbc/nanoarrow/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int64_t ArrowMetadataSizeOf(const char *metadata) {

int64_t size = sizeof(int32_t);
while (ArrowMetadataReaderRead(&reader, &key, &value) == NANOARROW_OK) {
size += sizeof(int32_t) + key.n_bytes + sizeof(int32_t) + value.n_bytes;
size += sizeof(int32_t) + uint64_t(key.n_bytes) + sizeof(int32_t) + uint64_t(value.n_bytes);
}

return size;
Expand All @@ -89,7 +89,7 @@ ArrowErrorCode ArrowMetadataGetValue(const char *metadata, const char *key, cons
struct ArrowStringView target_key_view = {key, static_cast<int64_t>(strlen(key))};
value_out->data = default_value;
if (default_value != NULL) {
value_out->n_bytes = strlen(default_value);
value_out->n_bytes = int64_t(strlen(default_value));
} else {
value_out->n_bytes = 0;
}
Expand All @@ -101,7 +101,7 @@ ArrowErrorCode ArrowMetadataGetValue(const char *metadata, const char *key, cons

while (ArrowMetadataReaderRead(&reader, &key_view, &value) == NANOARROW_OK) {
int key_equal = target_key_view.n_bytes == key_view.n_bytes &&
strncmp(target_key_view.data, key_view.data, key_view.n_bytes) == 0;
strncmp(target_key_view.data, key_view.data, size_t(key_view.n_bytes)) == 0;
if (key_equal) {
value_out->data = value.data;
value_out->n_bytes = value.n_bytes;
Expand Down
13 changes: 7 additions & 6 deletions src/common/adbc/nanoarrow/schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ ArrowErrorCode ArrowSchemaSetFormat(struct ArrowSchema *schema, const char *form

if (format != NULL) {
size_t format_size = strlen(format) + 1;
schema->format = (const char *)ArrowMalloc(format_size);
schema->format = (const char *)ArrowMalloc(int64_t(format_size));
if (schema->format == NULL) {
return ENOMEM;
}
Expand All @@ -338,7 +338,7 @@ ArrowErrorCode ArrowSchemaSetName(struct ArrowSchema *schema, const char *name)

if (name != NULL) {
size_t name_size = strlen(name) + 1;
schema->name = (const char *)ArrowMalloc(name_size);
schema->name = (const char *)ArrowMalloc(int64_t(name_size));
if (schema->name == NULL) {
return ENOMEM;
}
Expand All @@ -357,13 +357,13 @@ ArrowErrorCode ArrowSchemaSetMetadata(struct ArrowSchema *schema, const char *me
}

if (metadata != NULL) {
size_t metadata_size = ArrowMetadataSizeOf(metadata);
auto metadata_size = ArrowMetadataSizeOf(metadata);
schema->metadata = (const char *)ArrowMalloc(metadata_size);
if (schema->metadata == NULL) {
return ENOMEM;
}

memcpy((void *)schema->metadata, metadata, metadata_size);
memcpy((void *)schema->metadata, metadata, size_t(metadata_size));
} else {
schema->metadata = NULL;
}
Expand All @@ -377,15 +377,16 @@ ArrowErrorCode ArrowSchemaAllocateChildren(struct ArrowSchema *schema, int64_t n
}

if (n_children > 0) {
schema->children = (struct ArrowSchema **)ArrowMalloc(n_children * sizeof(struct ArrowSchema *));
schema->children =
(struct ArrowSchema **)ArrowMalloc(int64_t(uint64_t(n_children) * sizeof(struct ArrowSchema *)));

if (schema->children == NULL) {
return ENOMEM;
}

schema->n_children = n_children;

memset(schema->children, 0, n_children * sizeof(struct ArrowSchema *));
memset(schema->children, 0, uint64_t(n_children) * sizeof(struct ArrowSchema *));

for (int64_t i = 0; i < n_children; i++) {
schema->children[i] = (struct ArrowSchema *)ArrowMalloc(sizeof(struct ArrowSchema));
Expand Down
1 change: 1 addition & 0 deletions src/common/arrow/appender/bool_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace duckdb {
void ArrowBoolData::Initialize(ArrowAppendData &result, const LogicalType &type, idx_t capacity) {
auto byte_count = (capacity + 7) / 8;
result.main_buffer.reserve(byte_count);
(void)AppendValidity; // silence a compiler warning about unused static function
}

void ArrowBoolData::Append(ArrowAppendData &append_data, Vector &input, idx_t from, idx_t to, idx_t input_size) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/arrow/appender/struct_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ArrowStructData::Finalize(ArrowAppendData &append_data, const LogicalType &
auto &child_types = StructType::GetChildTypes(type);
ArrowAppender::AddChildren(append_data, child_types.size());
result->children = append_data.child_pointers.data();
result->n_children = child_types.size();
result->n_children = NumericCast<int64_t>(child_types.size());
for (idx_t i = 0; i < child_types.size(); i++) {
auto &child_type = child_types[i].second;
append_data.child_arrays[i] = *ArrowAppender::FinalizeChild(child_type, std::move(append_data.child_data[i]));
Expand Down
3 changes: 2 additions & 1 deletion src/common/arrow/appender/union_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void ArrowUnionData::Initialize(ArrowAppendData &result, const LogicalType &type
auto child_buffer = ArrowAppender::InitializeChild(child.second, capacity, result.options);
result.child_data.push_back(std::move(child_buffer));
}
(void)AppendValidity; // silence a compiler warning about unused static functiondep
}

void ArrowUnionData::Append(ArrowAppendData &append_data, Vector &input, idx_t from, idx_t to, idx_t input_size) {
Expand Down Expand Up @@ -61,7 +62,7 @@ void ArrowUnionData::Finalize(ArrowAppendData &append_data, const LogicalType &t
auto &child_types = UnionType::CopyMemberTypes(type);
ArrowAppender::AddChildren(append_data, child_types.size());
result->children = append_data.child_pointers.data();
result->n_children = child_types.size();
result->n_children = NumericCast<int64_t>(child_types.size());
for (idx_t i = 0; i < child_types.size(); i++) {
auto &child_type = child_types[i].second;
append_data.child_arrays[i] = *ArrowAppender::FinalizeChild(child_type, std::move(append_data.child_data[i]));
Expand Down
Loading

0 comments on commit eadb2cf

Please sign in to comment.