generated from duckdb/extension-template
-
Notifications
You must be signed in to change notification settings - Fork 1
release: bump duckdb to 1.3 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule duckdb
updated
from 7c0cc5 to ad1273
Submodule extension-ci-tools
updated
9 files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,3 @@ | ||
| // This header prefixes the auto-generated vortex.h with #pragma once. | ||
| #pragma once | ||
|
|
||
|
|
||
| // Include Vortex FFI, with the DuckDB FFI feature | ||
| #ifndef ENABLE_DUCKDB_FFI | ||
| #define ENABLE_DUCKDB_FFI | ||
| #endif | ||
|
|
||
| #include "vortex.h" | ||
| #include "vortex.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,77 +1,162 @@ | ||
| #pragma once | ||
| #define ENABLE_DUCKDB_FFI | ||
|
|
||
| #include "duckdb.hpp" | ||
| #include "duckdb/common/unique_ptr.hpp" | ||
|
|
||
| #include "vortex.hpp" | ||
| #include "vortex_error.hpp" | ||
| #include "vortex_session.hpp" | ||
|
|
||
| namespace vortex { | ||
|
|
||
| struct DType { | ||
| explicit DType(vx_dtype *dtype) : dtype(dtype) { | ||
| } | ||
|
|
||
| static duckdb::unique_ptr<DType> FromDuckDBTable(const std::vector<duckdb_logical_type> &column_types, | ||
| const std::vector<unsigned char> &column_nullable, | ||
| const std::vector<const char *> &column_names) { | ||
| D_ASSERT(column_names.size() == column_nullable.size()); | ||
| D_ASSERT(column_names.size() == column_types.size()); | ||
|
|
||
| #include <duckdb/common/unique_ptr.hpp> | ||
| auto dtype = Try([&](auto err) { | ||
| return vx_duckdb_logical_type_to_dtype(column_types.data(), column_nullable.data(), column_names.data(), | ||
| column_names.size(), err); | ||
| }); | ||
|
|
||
| struct VortexConversionCache { | ||
| explicit VortexConversionCache(const unsigned long cache_id) : cache(vx_conversion_cache_create(cache_id)) { | ||
| return duckdb::make_uniq<DType>(dtype); | ||
| } | ||
|
|
||
| ~VortexConversionCache() { | ||
| ~DType() { | ||
| if (dtype != nullptr) { | ||
| vx_dtype_free(dtype); | ||
| } | ||
| } | ||
|
|
||
| vx_dtype *dtype; | ||
| }; | ||
|
|
||
| struct ConversionCache { | ||
| explicit ConversionCache(const unsigned long cache_id) : cache(vx_conversion_cache_create(cache_id)) { | ||
| } | ||
|
|
||
| ~ConversionCache() { | ||
| vx_conversion_cache_free(cache); | ||
| } | ||
|
|
||
| vx_conversion_cache *cache; | ||
| }; | ||
|
|
||
| struct VortexFileReader { | ||
| explicit VortexFileReader(vx_file_reader *file) : file(file) { | ||
| struct FileReader { | ||
| explicit FileReader(vx_file_reader *file) : file(file) { | ||
| } | ||
|
|
||
| ~VortexFileReader() { | ||
| ~FileReader() { | ||
| vx_file_reader_free(file); | ||
| } | ||
|
|
||
| static duckdb::unique_ptr<VortexFileReader> Open(const vx_file_open_options *options) { | ||
| vx_error *error; | ||
| auto file = vx_file_open_reader(options, &error); | ||
| HandleError(error); | ||
| return duckdb::make_uniq<VortexFileReader>(file); | ||
| static duckdb::unique_ptr<FileReader> Open(const vx_file_open_options *options, VortexSession &session) { | ||
| auto file = Try([&](auto err) { return vx_file_open_reader(options, session.session, err); }); | ||
| return duckdb::make_uniq<FileReader>(file); | ||
| } | ||
|
|
||
| vx_array_iterator *Scan(const vx_file_scan_options *options) { | ||
| return Try([&](auto err) { return vx_file_reader_scan(this->file, options, err); }); | ||
| } | ||
|
|
||
| bool CanPrune(const char *filter_expression, unsigned int filter_expression_len) { | ||
| return Try([&](auto err) { | ||
| return vx_file_reader_can_prune(this->file, filter_expression, filter_expression_len, err); | ||
| }); | ||
| } | ||
|
|
||
| uint64_t FileRowCount() { | ||
| return Try([&](auto err) { return vx_file_row_count(file, err); }); | ||
| } | ||
|
|
||
| struct DType DType() { | ||
| return vortex::DType(vx_file_dtype(file)); | ||
| } | ||
|
|
||
| vx_file_reader *file; | ||
| }; | ||
|
|
||
| struct VortexArray { | ||
| explicit VortexArray(vx_array *array) : array(array) { | ||
| struct Array { | ||
| explicit Array(vx_array *array) : array(array) { | ||
| } | ||
|
|
||
| ~VortexArray() { | ||
| ~Array() { | ||
| if (array != nullptr) { | ||
| vx_array_free(array); | ||
| } | ||
| } | ||
|
|
||
| idx_t ToDuckDBVector(idx_t current_row, duckdb_data_chunk output, const VortexConversionCache *cache) const { | ||
| vx_error *error; | ||
| auto idx = vx_array_to_duckdb_chunk(array, current_row, output, cache->cache, &error); | ||
| HandleError(error); | ||
| return idx; | ||
| static duckdb::unique_ptr<Array> FromDuckDBChunk(DType &dtype, duckdb::DataChunk &chunk) { | ||
| auto array = Try([&](auto err) { | ||
| return vx_duckdb_chunk_to_array(reinterpret_cast<duckdb_data_chunk>(&chunk), dtype.dtype, err); | ||
| }); | ||
|
|
||
| return duckdb::make_uniq<Array>(array); | ||
| } | ||
|
|
||
| idx_t ToDuckDBVector(idx_t current_row, duckdb_data_chunk output, const ConversionCache *cache) const { | ||
| return Try([&](auto err) { return vx_array_to_duckdb_chunk(array, current_row, output, cache->cache, err); }); | ||
| } | ||
|
|
||
| vx_array *array; | ||
| }; | ||
|
|
||
| struct VortexArrayStream { | ||
| explicit VortexArrayStream(vx_array_stream *array_stream) : array_stream(array_stream) { | ||
| struct ArrayIterator { | ||
| explicit ArrayIterator(vx_array_iterator *array_iter) : array_iter(array_iter) { | ||
| } | ||
|
|
||
| ~VortexArrayStream() { | ||
| vx_array_stream_free(array_stream); | ||
| ~ArrayIterator() { | ||
| vx_array_iter_free(array_iter); | ||
| } | ||
|
|
||
| duckdb::unique_ptr<VortexArray> NextArray() const { | ||
| vx_error *error; | ||
| auto array = vx_array_stream_next(array_stream, &error); | ||
| HandleError(error); | ||
| duckdb::unique_ptr<Array> NextArray() const { | ||
| auto array = Try([&](auto err) { return vx_array_iter_next(array_iter, err); }); | ||
|
|
||
| if (array == nullptr) { | ||
| return nullptr; | ||
| } | ||
| return duckdb::make_uniq<VortexArray>(array); | ||
|
|
||
| return duckdb::make_uniq<Array>(array); | ||
| } | ||
|
|
||
| vx_array_stream *array_stream; | ||
| vx_array_iterator *array_iter; | ||
| }; | ||
|
|
||
| struct ArrayStreamSink { | ||
| explicit ArrayStreamSink(vx_array_sink *sink, duckdb::unique_ptr<DType> dtype) | ||
| : sink(sink), dtype(std::move(dtype)) { | ||
| } | ||
|
|
||
| static duckdb::unique_ptr<ArrayStreamSink> Create(std::string file_path, duckdb::unique_ptr<DType> &&dtype) { | ||
| auto sink = Try([&](auto err) { return vx_array_sink_open_file(file_path.c_str(), dtype->dtype, err); }); | ||
| return duckdb::make_uniq<ArrayStreamSink>(sink, std::move(dtype)); | ||
| } | ||
|
|
||
| void PushChunk(duckdb::DataChunk &chunk) { | ||
| auto array = Array::FromDuckDBChunk(*dtype, chunk); | ||
| Try([&](auto err) { vx_array_sink_push(sink, array->array, err); }); | ||
| } | ||
|
|
||
| void Close() { | ||
| Try([&](auto err) { vx_array_sink_close(sink, err); }); | ||
| this->sink = nullptr; | ||
| } | ||
|
|
||
| ~ArrayStreamSink() { | ||
| // "should dctor a sink, before closing it | ||
| // If you throw during writes then the stack will be unwound and the destructor is going to be called before the | ||
| // close method is invoked thus triggering following assertion failure and will clobber the exception printing | ||
| // D_ASSERT(sink == nullptr); | ||
| } | ||
|
|
||
| vx_array_sink *sink; | ||
| duckdb::unique_ptr<DType> dtype; | ||
| }; | ||
|
|
||
| } // namespace vortex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,33 @@ | ||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <type_traits> | ||
|
|
||
| #include "duckdb.hpp" | ||
| #include "vortex.hpp" | ||
|
|
||
| namespace vortex { | ||
|
|
||
| inline void HandleError(vx_error *error) { | ||
| if (error != nullptr) { | ||
| auto msg = std::string(vx_error_get_message(error)); | ||
| vx_error_free(error); | ||
| throw duckdb::InvalidInputException(msg); | ||
| } | ||
| } | ||
|
|
||
| template <typename Func> | ||
| auto Try(Func func) { | ||
| vx_error *error = nullptr; | ||
| // Handle both void and non-void return types. | ||
| if constexpr (std::is_void_v<std::invoke_result_t<Func, vx_error **>>) { | ||
| func(&error); | ||
| HandleError(error); | ||
| } else { | ||
| auto result = func(&error); | ||
| HandleError(error); | ||
| return result; | ||
| } | ||
| } | ||
|
|
||
| } // namespace vortex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| #pragma once | ||
|
|
||
| #include "expr.pb.h" | ||
| #include "duckdb/planner/expression.hpp" | ||
| #include "duckdb/planner/table_filter.hpp" | ||
|
|
||
| #include <duckdb/planner/table_filter.hpp> | ||
| #include "expr.pb.h" | ||
|
|
||
| namespace vortex { | ||
| vortex::expr::Expr *table_expression_into_expr(google::protobuf::Arena &arena, duckdb::TableFilter &filter, | ||
| const std::string &column_name); | ||
|
|
||
| vortex::expr::Expr *expression_into_vortex_expr(google::protobuf::Arena &arena, const duckdb::Expression &expr); | ||
|
|
||
| vortex::expr::Expr *flatten_exprs(google::protobuf::Arena &arena, | ||
| const duckdb::vector<vortex::expr::Expr *> &child_filters); | ||
| const duckdb::vector<vortex::expr::Expr *> &child_filters); | ||
| } // namespace vortex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.