@@ -52,8 +52,8 @@ use mz_expr::func::variadic::{
5252} ;
5353use mz_expr:: virtual_syntax:: AlgExcept ;
5454use mz_expr:: {
55- Id , LetRecLimit , LocalId , MapFilterProject , MirScalarExpr , RowSetFinishing , TableFunc ,
56- func as expr_func,
55+ Id , LetRecLimit , LocalId , MapFilterProject , MirScalarExpr , REPEAT_ROW_NAME , RowSetFinishing ,
56+ TableFunc , func as expr_func,
5757} ;
5858use mz_ore:: assert_none;
5959use mz_ore:: collections:: CollectionExt ;
@@ -66,6 +66,7 @@ use mz_repr::adt::char::CharLength;
6666use mz_repr:: adt:: numeric:: { NUMERIC_DATUM_MAX_PRECISION , NumericMaxScale } ;
6767use mz_repr:: adt:: timestamp:: TimestampPrecision ;
6868use mz_repr:: adt:: varchar:: VarCharMaxLength ;
69+ use mz_repr:: namespaces:: MZ_CATALOG_SCHEMA ;
6970use mz_repr:: {
7071 CatalogItemId , ColumnIndex , ColumnName , Datum , RelationDesc , RelationVersionSelector ,
7172 ReprColumnType , Row , RowArena , SqlColumnType , SqlRelationType , SqlScalarType ,
@@ -2826,6 +2827,14 @@ fn plan_scalar_table_funcs(
28262827 }
28272828 return Ok ( ( expr, scope) ) ;
28282829 }
2830+ if table_funcs. keys ( ) . any ( is_repeat_row) {
2831+ // Note: Would be also caught by WITH ORDINALITY checking for `repeat_row`, but then the
2832+ // error message would be misleading, because it would refer to WITH ORDINALITY.
2833+ bail_unsupported ! ( format!(
2834+ "{} in a SELECT clause with multiple table functions" ,
2835+ REPEAT_ROW_NAME
2836+ ) ) ;
2837+ }
28292838 // Otherwise, plan as usual, emulating the ROWS FROM behavior
28302839 let ( expr, mut scope, num_cols) =
28312840 plan_rows_from_internal ( & rows_from_qcx, table_funcs. keys ( ) , None ) ?;
@@ -3111,6 +3120,14 @@ fn plan_rows_from(
31113120 alias : Option < & TableAlias > ,
31123121 with_ordinality : bool ,
31133122) -> Result < ( HirRelationExpr , Scope ) , PlanError > {
3123+ // The `repeat_row` function is not supported in ROWS FROM.
3124+ if functions. iter ( ) . any ( is_repeat_row) {
3125+ // Note: Would be also caught by WITH ORDINALITY checking for `repeat_row`, but then the
3126+ // error message would be misleading, because it would refer to WITH ORDINALITY instead of
3127+ // ROWS FROM.
3128+ bail_unsupported ! ( format!( "{} in ROWS FROM" , REPEAT_ROW_NAME ) ) ;
3129+ }
3130+
31143131 // If there's only a single table function, planning proceeds as if `ROWS
31153132 // FROM` hadn't been written at all.
31163133 if let [ function] = functions {
@@ -3155,6 +3172,10 @@ fn plan_rows_from(
31553172 Ok ( ( expr, scope) )
31563173}
31573174
3175+ fn is_repeat_row ( f : & Function < Aug > ) -> bool {
3176+ f. name . full_name_str ( ) . as_str ( ) == format ! ( "{}.{}" , MZ_CATALOG_SCHEMA , REPEAT_ROW_NAME )
3177+ }
3178+
31583179/// Plans an expression coalescing multiple table functions. Each table
31593180/// function is followed by its row ordinality. The entire expression is
31603181/// followed by the coalesced row ordinality.
0 commit comments