@@ -3784,10 +3784,7 @@ pub enum TableFunc {
3784
3784
relation : RelationType ,
3785
3785
} ,
3786
3786
RegexpMatches ,
3787
- /// Evaluates the inner table function, expands its results into unary (repeating each row as
3788
- /// many times as the diff indicates), and appends an integer corresponding to the ordinal
3789
- /// position (starting from 1). For example, it numbers the elements of a list when calling
3790
- /// `unnest_list`.
3787
+ /// Implements the WITH ORDINALITY clause.
3791
3788
///
3792
3789
/// Don't construct `TableFunc::WithOrdinality` manually! Use the `with_ordinality` constructor
3793
3790
/// function instead, which checks whether the given table function supports `WithOrdinality`.
@@ -3798,6 +3795,11 @@ pub enum TableFunc {
3798
3795
/// Private enum variant of `TableFunc`. Don't construct this directly, but use
3799
3796
/// `TableFunc::with_ordinality` instead.
3800
3797
///
3798
+ /// Evaluates the inner table function, expands its results into unary (repeating each row as
3799
+ /// many times as the diff indicates), and appends an integer corresponding to the ordinal
3800
+ /// position (starting from 1). For example, it numbers the elements of a list when calling
3801
+ /// `unnest_list`.
3802
+ ///
3801
3803
/// TODO(ggevay): This struct (and its field) is pub only temporarily, until we make
3802
3804
/// `FlatMapElimination` not dive into it.
3803
3805
#[ derive( Clone , Debug , Eq , PartialEq , Ord , PartialOrd , Serialize , Deserialize , Hash , MzReflect ) ]
@@ -3832,8 +3834,7 @@ impl TableFunc {
3832
3834
inner : Box :: new ( inner) ,
3833
3835
} ) ) ,
3834
3836
// IMPORTANT: Before adding a new table function here, consider negative diffs:
3835
- // `WithOrdinality::eval` currently asserts that the inner table function never emits
3836
- // negative diffs.
3837
+ // `WithOrdinality::eval` will panic if the inner table function emits a negative diff.
3837
3838
_ => None ,
3838
3839
}
3839
3840
}
@@ -3974,6 +3975,7 @@ impl RustType<ProtoTableFunc> for TableFunc {
3974
3975
}
3975
3976
3976
3977
impl TableFunc {
3978
+ /// Executes `self` on the given input row (`datums`).
3977
3979
pub fn eval < ' a > (
3978
3980
& ' a self ,
3979
3981
datums : & ' a [ Datum < ' a > ] ,
@@ -4334,13 +4336,19 @@ impl fmt::Display for TableFunc {
4334
4336
}
4335
4337
4336
4338
impl WithOrdinality {
4339
+ /// Executes the `self.inner` table function on the given input row (`datums`), and zips
4340
+ /// 1, 2, 3, ... to the result as a new column. We need to expand rows with non-1 diffs into the
4341
+ /// corresponding number of rows with unit diffs, because the ordinality column will have
4342
+ /// different values for each copy.
4343
+ ///
4344
+ /// # Panics
4345
+ ///
4346
+ /// Panics if the `inner` table function emits a negative diff.
4337
4347
fn eval < ' a > (
4338
4348
& ' a self ,
4339
4349
datums : & ' a [ Datum < ' a > ] ,
4340
4350
temp_storage : & ' a RowArena ,
4341
4351
) -> Result < Box < dyn Iterator < Item = ( Row , Diff ) > + ' a > , EvalError > {
4342
- // zip 1, 2, 3, 4, ... to the output of the table function. We need to blow up non-1 diffs,
4343
- // because the ordinality column will have different values for each copy.
4344
4352
let mut next_ordinal: i64 = 1 ;
4345
4353
let it = self
4346
4354
. inner
0 commit comments