@@ -913,6 +913,10 @@ pub enum TableFactor {
913913 /// Optional version qualifier to facilitate table time-travel, as
914914 /// supported by BigQuery and MSSQL.
915915 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 ,
916920 /// [Partition selection](https://dev.mysql.com/doc/refman/8.0/en/partitioning-selection.html), supported by MySQL.
917921 partitions : Vec < Ident > ,
918922 } ,
@@ -948,6 +952,7 @@ pub enum TableFactor {
948952 array_exprs : Vec < Expr > ,
949953 with_offset : bool ,
950954 with_offset_alias : Option < Ident > ,
955+ with_ordinality : bool ,
951956 } ,
952957 /// The `JSON_TABLE` table-valued function.
953958 /// Part of the SQL standard, but implemented only by MySQL, Oracle, and DB2.
@@ -1293,6 +1298,7 @@ impl fmt::Display for TableFactor {
12931298 with_hints,
12941299 version,
12951300 partitions,
1301+ with_ordinality,
12961302 } => {
12971303 write ! ( f, "{name}" ) ?;
12981304 if !partitions. is_empty ( ) {
@@ -1301,6 +1307,9 @@ impl fmt::Display for TableFactor {
13011307 if let Some ( args) = args {
13021308 write ! ( f, "({})" , display_comma_separated( args) ) ?;
13031309 }
1310+ if * with_ordinality {
1311+ write ! ( f, " WITH ORDINALITY" ) ?;
1312+ }
13041313 if let Some ( alias) = alias {
13051314 write ! ( f, " AS {alias}" ) ?;
13061315 }
@@ -1354,9 +1363,14 @@ impl fmt::Display for TableFactor {
13541363 array_exprs,
13551364 with_offset,
13561365 with_offset_alias,
1366+ with_ordinality,
13571367 } => {
13581368 write ! ( f, "UNNEST({})" , display_comma_separated( array_exprs) ) ?;
13591369
1370+ if * with_ordinality {
1371+ write ! ( f, " WITH ORDINALITY" ) ?;
1372+ }
1373+
13601374 if let Some ( alias) = alias {
13611375 write ! ( f, " AS {alias}" ) ?;
13621376 }
0 commit comments