Skip to content

Commit

Permalink
Patch substrait
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin committed Feb 28, 2024
1 parent 0f66ff8 commit e663f20
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/config/out_of_tree_extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ if (NOT WIN32)
LOAD_TESTS DONT_LINK
GIT_URL https://github.com/duckdb/substrait
GIT_TAG 870bab8725d1123905296bfb1f35ce737434e0b3
APPLY_PATCHES
)
endif()
38 changes: 38 additions & 0 deletions .github/patches/extensions/substrait/substrait.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/src/to_substrait.cpp b/src/to_substrait.cpp
index 03d9778..d2429c6 100644
--- a/src/to_substrait.cpp
+++ b/src/to_substrait.cpp
@@ -777,8 +777,31 @@ substrait::Rel *DuckDBToSubstrait::TransformLimit(LogicalOperator &dop) {
auto stopn = res->mutable_fetch();
stopn->set_allocated_input(TransformOp(*dop.children[0]));

- stopn->set_offset(dlimit.offset_val);
- stopn->set_count(dlimit.limit_val);
+ idx_t limit_val;
+ idx_t offset_val;
+
+ switch(dlimit.limit_val.Type()) {
+ case LimitNodeType::CONSTANT_VALUE:
+ limit_val = dlimit.limit_val.GetConstantValue();
+ break;
+ case LimitNodeType::UNSET:
+ limit_val = 2ULL << 62ULL;
+ break;
+ default:
+ throw InternalException("Unsupported limit value type");
+ }
+ switch(dlimit.offset_val.Type()) {
+ case LimitNodeType::CONSTANT_VALUE:
+ offset_val = dlimit.offset_val.GetConstantValue();
+ break;
+ case LimitNodeType::UNSET:
+ offset_val = 0;
+ break;
+ default:
+ throw InternalException("Unsupported offset value type");
+ }
+ stopn->set_offset(offset_val);
+ stopn->set_count(limit_val);
return res;
}

0 comments on commit e663f20

Please sign in to comment.