Skip to content

Commit

Permalink
feat: support expressions for count and offset in the Fetch operator
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamachor committed Nov 22, 2024
1 parent 708a7b8 commit 3b25a08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
22 changes: 17 additions & 5 deletions proto/substrait/algebra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,23 @@ message CrossRel {
message FetchRel {
RelCommon common = 1;
Rel input = 2;
// the offset expressed in number of records
int64 offset = 3;
// the amount of records to return
// use -1 to signal that ALL records should be returned
int64 count = 4;
oneof offset_mode {
// the offset expressed in number of records
// Deprecated: use `offset_expr` instead
int64 offset = 3 [deprecated = true];
// Expression evaluated into an integer specifying the number of records to
// skip.
Expression offset_expr = 5;
}
oneof count_mode {
// the amount of records to return
// use -1 to signal that ALL records should be returned
// Deprecated: use `count_expr` instead
int64 count = 4 [deprecated = true];
// Expression evaluated into an integer specifying the number of records to
// return. -1 signals that all records should be returned.
Expression count_expr = 6;
}
substrait.extensions.AdvancedExtension advanced_extension = 10;
}

Expand Down
10 changes: 5 additions & 5 deletions site/docs/relations/logical_relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ The fetch operation eliminates records outside a desired window. Typically corre

### Fetch Properties

| Property | Description | Required |
| -------- | --------------------------------------------------------------------- | ------------------------ |
| Input | A relational input, typically with a desired orderedness property. | Required |
| Offset | A non-negative integer. Declares the offset for retrieval of records. | Optional, defaults to 0. |
| Count | A non-negative integer or -1. Declares the number of records that should be returned. -1 signals that ALL records should be returned. | Required |
| Property | Description | Required |
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------ |
| Input | A relational input, typically with a desired orderedness property. | Required |
| Offset Expression | An expression which evaluates to a non-negative integer. Declares the offset for retrieval of records. | Optional, defaults to 0. |
| Count Expression | An expression which evaluates to a non-negative integer or -1. Declares the number of records that should be returned. -1 signals that ALL records should be returned. | Required |

=== "FetchRel Message"

Expand Down

0 comments on commit 3b25a08

Please sign in to comment.