@@ -913,6 +913,10 @@ pub enum TableFactor {
913
913
/// Optional version qualifier to facilitate table time-travel, as
914
914
/// supported by BigQuery and MSSQL.
915
915
version : Option < TableVersion > ,
916
+ // Optional table function modifier to generate the ordinality for column.
917
+ /// For example, `SELECT * FROM generate_series(1, 10) WITH ORDINALITY AS t(a, b);`
918
+ /// [WITH ORDINALITY](https://www.postgresql.org/docs/current/functions-srf.html), supported by Postgres.
919
+ with_ordinality : bool ,
916
920
/// [Partition selection](https://dev.mysql.com/doc/refman/8.0/en/partitioning-selection.html), supported by MySQL.
917
921
partitions : Vec < Ident > ,
918
922
} ,
@@ -948,6 +952,7 @@ pub enum TableFactor {
948
952
array_exprs : Vec < Expr > ,
949
953
with_offset : bool ,
950
954
with_offset_alias : Option < Ident > ,
955
+ with_ordinality : bool ,
951
956
} ,
952
957
/// The `JSON_TABLE` table-valued function.
953
958
/// Part of the SQL standard, but implemented only by MySQL, Oracle, and DB2.
@@ -1293,6 +1298,7 @@ impl fmt::Display for TableFactor {
1293
1298
with_hints,
1294
1299
version,
1295
1300
partitions,
1301
+ with_ordinality,
1296
1302
} => {
1297
1303
write ! ( f, "{name}" ) ?;
1298
1304
if !partitions. is_empty ( ) {
@@ -1301,6 +1307,9 @@ impl fmt::Display for TableFactor {
1301
1307
if let Some ( args) = args {
1302
1308
write ! ( f, "({})" , display_comma_separated( args) ) ?;
1303
1309
}
1310
+ if * with_ordinality {
1311
+ write ! ( f, " WITH ORDINALITY" ) ?;
1312
+ }
1304
1313
if let Some ( alias) = alias {
1305
1314
write ! ( f, " AS {alias}" ) ?;
1306
1315
}
@@ -1354,9 +1363,14 @@ impl fmt::Display for TableFactor {
1354
1363
array_exprs,
1355
1364
with_offset,
1356
1365
with_offset_alias,
1366
+ with_ordinality,
1357
1367
} => {
1358
1368
write ! ( f, "UNNEST({})" , display_comma_separated( array_exprs) ) ?;
1359
1369
1370
+ if * with_ordinality {
1371
+ write ! ( f, " WITH ORDINALITY" ) ?;
1372
+ }
1373
+
1360
1374
if let Some ( alias) = alias {
1361
1375
write ! ( f, " AS {alias}" ) ?;
1362
1376
}
0 commit comments