Repository: DerekStride/tree-sitter-sql (language: python)

Issue:
feat: add parenthesized select and cte select statements
Addresses a remaining issue in #145 

It works, but I am not so super happy with it. I had to enter alot of associativity rules. Maybe that was necessary, since the change is so high up in the AST and it affects parenthesis.

Also, I am always about creating the anonymous nodes to reduce code replication like in `_cte_select_variants`.

P.S.
For MySQL, this is documented: https://dev.mysql.com/doc/refman/8.0/en/parenthesized-query-expressions.html

feat: add parenthesized select and cte select statements
Addresses a remaining issue in #145 

It works, but I am not so super happy with it. I had to enter alot of associativity rules. Maybe that was necessary, since the change is so high up in the AST and it affects parenthesis.

Also, I am always about creating the anonymous nodes to reduce code replication like in `_cte_select_variants`.

P.S.
For MySQL, this is documented: https://dev.mysql.com/doc/refman/8.0/en/parenthesized-query-expressions.html



Discussion / hints:

Fix patch:
diff --git a/grammar.js b/grammar.js
index 41c43266..62224a73 100644
--- a/grammar.js
+++ b/grammar.js
@@ -8,6 +8,17 @@ module.exports = grammar({
     $.marginalia,
   ],
 
+  conflicts: $ => [
+    [$.object_reference, $._qualified_field],
+    [$.object_reference],
+    // TODO these two have internal conflicts because of optional parenthesized
+    // settings which can be interpreted as _subsequent statements_ due to our
+    // current handling of statement delimiters in program nodes. Remove once
+    // we have expressed programs as delimited sequences of statements.
+    [$._vacuum_table],
+    [$._compute_stats],
+  ],
+
   precedences: $ => [
     [
       'binary_is',
@@ -441,8 +452,8 @@ module.exports = grammar({
 
     // TODO: should qualify against /\\b(0?[1-9]|[1-4][0-9]|5[0-4])\\b/g
     float: $  => choice(
-      prec(0, parametric_type($, $.keyword_float, ['precision'])),
-      prec(1, unsigned_type($, parametric_type($, $.keyword_float, ['precision', 'scale']))),
+      parametric_type($, $.keyword_float, ['precision']),
+      unsigned_type($, parametric_type($, $.keyword_float, ['precision', 'scale'])),
     ),
 
     double: $ => choice(
@@ -491,7 +502,13 @@ module.exports = grammar({
     statement: $ => seq(
       choice(
         $._ddl_statement,
-        $._dml_statement,
+        $._dml_read,
+        $._dml_write,
+        seq(
+          '(',
+          $._dml_read,
+          ')',
+        ),
       ),
       optional(';'),
     ),
@@ -501,6 +518,7 @@ module.exports = grammar({
       $._alter_statement,
       $._drop_statement,
       $._rename_statement,
+      $._optimize_statement,
     ),
 
     _cte: $ => seq(
@@ -514,18 +532,28 @@ module.exports = grammar({
         ),
     ),
 
-    _dml_statement: $ => seq(
-      optional(
-          $._cte
+    _dml_write: $ => seq(
+      seq(
+        optional(
+          $._cte,
+        ),
+        choice(
+          $._delete_statement,
+          $._insert_statement,
+          $._update_statement,
+        ),
       ),
+    ),
+
+    _dml_read: $ => seq(
       choice(
-        $._select_statement,
-        $._delete_statement,
-        $._insert_statement,
-        $._update_statement,
-        $._optimize_statement,
+        seq(
+          optional(
+            $._cte
+          ),
+          $._select_statement,
+        ),
       ),
-      optional($.window_clause),
     ),
 
     cte: $ => seq(
@@ -612,22 +640,23 @@ module.exports = grammar({
     ),
 
     select_expression: $ => seq(
-      $._select_expression,
+      $.term,
       repeat(
         seq(
           ',',
-          $._select_expression,
+          $.term,
         ),
       ),
     ),
 
-    _select_expression: $ => choice(
-      $.all_fields,
-      $.term,
-    ),
-
     term: $ => seq(
-      field("value", $._expression),
+      field(
+        'value',
+        choice(
+          $.all_fields,
+          $._expression,
+        ),
+      ),
       optional($._alias),
     ),
 
@@ -642,7 +671,7 @@ module.exports = grammar({
       optional(
         $.keyword_only,
       ),
-      $.table_reference,
+      $.object_reference,
       optional($.where),
       optional($.order_by),
       optional($.limit),
@@ -696,7 +725,7 @@ module.exports = grammar({
         ),
         $.keyword_table,
         optional($._if_not_exists),
-        $.table_reference,
+        $.object_reference,
         choice(
           seq(
             $.column_definitions,
@@ -755,7 +784,7 @@ module.exports = grammar({
         optional($.keyword_recursive),
         $.keyword_view,
         optional($._if_not_exists),
-        $.table_reference,
+        $.object_reference,
         optional(paren_list($.identifier)),
         $.keyword_as,
         $.create_query,
@@ -781,7 +810,7 @@ module.exports = grammar({
         $.keyword_materialized,
         $.keyword_view,
         optional($._if_not_exists),
-        $.table_reference,
+        $.object_reference,
         $.keyword_as,
         $.create_query,
         optional(
@@ -1015,7 +1044,7 @@ module.exports = grammar({
       $.keyword_on,
       optional($.keyword_only),
       seq(
-        $.table_reference,
+        $.object_reference,
         optional(
           seq(
             $.keyword_using,
@@ -1050,7 +1079,7 @@ module.exports = grammar({
         $.keyword_tables,
       ),
       optional($._if_exists),
-      $.table_reference,
+      $.object_reference,
       optional(
         choice(
           $.keyword_nowait,
@@ -1061,7 +1090,7 @@ module.exports = grammar({
         )
       ),
       $.keyword_to,
-      $.table_reference,
+      $.object_reference,
       repeat(
         seq(
           ',',
@@ -1071,16 +1100,16 @@ module.exports = grammar({
     ),
 
     _rename_table_names: $ => seq(
-      $.table_reference,
+      $.object_reference,
       $.keyword_to,
-      $.table_reference,
+      $.object_reference,
     ),
 
     alter_table: $ => seq(
       $.keyword_alter,
       $.keyword_table,
       optional($._if_exists),
-      $.table_reference,
+      $.object_reference,
       choice(
         seq(
           $._alter_specifications,
@@ -1120,7 +1149,7 @@ module.exports = grammar({
     add_constraint: $ => seq(
       $.keyword_add,
       $.keyword_constraint,
-      $.field,
+      $.identifier,
       $.constraint,
     ),
 
@@ -1214,7 +1243,7 @@ module.exports = grammar({
       $.keyword_alter,
       $.keyword_view,
       optional($._if_exists),
-      $.table_reference,
+      $.object_reference,
       choice(
         // TODO Postgres allows a single "alter column" to set or drop default
         $.rename_object,
@@ -1236,7 +1265,7 @@ module.exports = grammar({
       $.keyword_drop,
       $.keyword_table,
       optional($._if_exists),
-      $.table_reference,
+      $.object_reference,
       optional(
         $.keyword_cascade,
       ),
@@ -1246,7 +1275,7 @@ module.exports = grammar({
       $.keyword_drop,
       $.keyword_view,
       optional($._if_exists),
-      $.table_reference,
+      $.object_reference,
       optional(
         $.keyword_cascade,
       ),
@@ -1267,7 +1296,7 @@ module.exports = grammar({
       optional(
         seq(
             $.keyword_on,
-            $.table_reference,
+            $.object_reference,
         ),
       ),
     ),
@@ -1275,7 +1304,7 @@ module.exports = grammar({
     rename_object: $ => seq(
       $.keyword_rename,
       $.keyword_to,
-      $.table_reference,
+      $.object_reference,
     ),
 
     set_schema: $ => seq(
@@ -1290,17 +1319,14 @@ module.exports = grammar({
       $.identifier,
     ),
 
-    table_reference: $ => seq(
+    object_reference: $ => seq(
       optional(
         seq(
           field('schema', $.identifier),
           '.',
         ),
       ),
-      choice(
-        field('name', $.identifier),
-        field('name', alias($._literal_string, $.identifier)),
-      ),
+      field('name', $.identifier),
     ),
 
     _insert_statement: $ => seq(
@@ -1327,14 +1353,15 @@ module.exports = grammar({
           $.keyword_overwrite, // Spark SQL
         ),
       ),
-      $.table_reference,
+      $.object_reference,
       optional($.table_partition), // Spark SQL
       optional(
         seq(
           $.keyword_as,
-          field('table_alias', $._alias_identifier)
+          field('alias', $.identifier)
         ),
       ),
+      // TODO we need a test for `insert...set`
       choice(
         $._insert_values,
         $._set_values,
@@ -1397,7 +1424,7 @@ module.exports = grammar({
       seq(
         $.keyword_analyze,
         $.keyword_table,
-        $.table_reference,
+        $.object_reference,
         optional($._partition_spec),
         $.keyword_compute,
         $.keyword_statistics,
@@ -1422,7 +1449,7 @@ module.exports = grammar({
           $.keyword_incremental,
         ),
         $.keyword_stats,
-        $.table_reference,
+        $.object_reference,
         optional(
           choice(
             paren_list(repeat1($.field)),
@@ -1436,7 +1463,7 @@ module.exports = grammar({
       // Athena/Iceberg
       seq(
         $.keyword_optimize,
-        $.table_reference,
+        $.object_reference,
         $.keyword_rewrite,
         $.keyword_data,
         $.keyword_using,
@@ -1455,21 +1482,17 @@ module.exports = grammar({
           )
         ),
         $.keyword_table,
-        $.table_reference,
-        repeat(seq(',', $.table_reference)),
+        $.object_reference,
+        repeat(seq(',', $.object_reference)),
       ),
     ),
 
     _vacuum_table: $ => seq(
       $.keyword_vacuum,
       optional($._vacuum_option),
-      $.table_reference,
+      $.object_reference,
       optional(
-        seq(
-          optional(
-            paren_list($.field)
-          )
-        )
+        paren_list($.field)
       ),
     ),
 
@@ -1633,7 +1656,12 @@ module.exports = grammar({
     ),
 
     assignment: $ => seq(
-      field('left', $.field),
+      field('left',
+        alias(
+          $._qualified_field,
+          $.field,
+        ),
+      ),
       '=',
       field('right', $._expression),
     ),
@@ -1749,7 +1777,7 @@ module.exports = grammar({
       optional(
         seq(
           $.keyword_references,
-          $.table_reference,
+          $.object_reference,
           $.ordered_columns,
           optional(
             seq(
@@ -1772,13 +1800,7 @@ module.exports = grammar({
     all_fields: $ => seq(
       optional(
         seq(
-          optional(
-            seq(
-              field('schema', $._alias_identifier),
-              '.',
-            ),
-          ),
-          field('table_alias', $._alias_identifier),
+          $.object_reference,
           '.',
         ),
       ),
@@ -1834,25 +1856,16 @@ module.exports = grammar({
       $.keyword_end,
     ),
 
-    field: $ => prec.left(
-      seq(
-        optional(
-          seq(
-            optional(
-              seq(
-                field('schema', $._alias_identifier),
-                '.',
-              ),
-            ),
-            field('table_alias', $._alias_identifier),
-            '.',
-          ),
-        ),
-        choice(
-            field('name', $.identifier),
-            field('name', alias($._double_quote_string, $.identifier)),
+    field: $ => field('name', $.identifier),
+
+    _qualified_field: $ => seq(
+      optional(
+        seq(
+          $.object_reference,
+          '.',
         ),
       ),
+      field('name', $.identifier),
     ),
 
     implicit_cast: $ => seq(
@@ -1938,17 +1951,20 @@ module.exports = grammar({
       optional($.order_by),
     ),
 
-    invocation: $ => seq(
-      field('name', $.identifier),
-      paren_list(
-        seq(
-          optional($.keyword_distinct),
-          field(
-            'parameter',
-            $._select_expression,
-          ),
-          optional($.order_by)
-        )),
+    invocation: $ => prec(1,
+      seq(
+        $.object_reference,
+        paren_list(
+          seq(
+            optional($.keyword_distinct),
+            field(
+              'parameter',
+              $.term,
+            ),
+            optional($.order_by)
+          )
+        ),
+      ),
     ),
 
     exists: $ => seq(
@@ -2062,17 +2078,9 @@ module.exports = grammar({
         ),
     ),
 
-    _alias_identifier : $ => choice(
-      $.identifier,
-      alias($._double_quote_string, $.identifier),
-    ),
-
-    _alias: $ => choice(
-      field('alias', $._alias_identifier),
-      seq(
-        $.keyword_as,
-        field('alias', $._alias_identifier),
-      ),
+    _alias: $ => seq(
+      optional($.keyword_as),
+      field('alias', $.identifier),
     ),
 
     from: $ => seq(
@@ -2092,26 +2100,28 @@ module.exports = grammar({
       ),
       optional($.where),
       optional($.group_by),
+      optional($.window_clause),
       optional($.order_by),
       optional($.limit),
     ),
 
-    relation: $ => seq(
-      choice(
-        $.subquery,
-        $.invocation,
-        $.table_reference,
-        seq(
-          '(',
-          $.values,
-          ')',
+    relation: $ => prec.right(
+      seq(
+        choice(
+          $.subquery,
+          $.invocation,
+          $.object_reference,
+          seq(
+            '(',
+            $.values,
+            ')',
+          ),
         ),
-      ),
-      optional(
-        seq(
-          optional($.keyword_as),
-          field('table_alias', $._alias_identifier),
-          optional(alias($._column_list, $.list)),
+        optional(
+          seq(
+            $._alias,
+            optional(alias($._column_list, $.list)),
+          ),
         ),
       ),
     ),
@@ -2298,7 +2308,10 @@ module.exports = grammar({
     _expression: $ => prec(1,
       choice(
         $.literal,
-        $.field,
+        alias(
+          $._qualified_field,
+          $.field,
+        ),
         $.parameter,
         $.list,
         $.case,
@@ -2443,6 +2456,7 @@ module.exports = grammar({
 
     identifier: $ => choice(
       $._identifier,
+      $._double_quote_string,
       seq('`', $._identifier, '`'),
     ),
     _identifier: _ => /([a-zA-Z_][0-9a-zA-Z_]*)/,
@@ -2462,7 +2476,7 @@ function unsigned_type($, type) {
 }
 
 function parametric_type($, type, params = ['size']) {
-  return prec.right(
+  return prec.right(1,
     choice(
       type,
       seq(


Test patch:
diff --git a/test/corpus/alter.txt b/test/corpus/alter.txt
index d2102bb9..0ea97e3f 100644
--- a/test/corpus/alter.txt
+++ b/test/corpus/alter.txt
@@ -12,7 +12,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (add_column
         (keyword_add)
@@ -39,7 +39,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (add_column
         (keyword_add)
@@ -65,7 +65,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (add_column
         (keyword_add)
@@ -93,7 +93,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (add_column
         (keyword_add)
@@ -122,7 +122,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (alter_column
         (keyword_alter)
@@ -146,7 +146,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (alter_column
         (keyword_alter)
@@ -169,7 +169,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (alter_column
         (keyword_alter)
@@ -194,7 +194,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (modify_column
         (keyword_modify)
@@ -226,7 +226,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (change_column
         (keyword_change)
@@ -256,7 +256,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (alter_column
         (keyword_alter)
@@ -280,7 +280,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (alter_column
         (keyword_alter)
@@ -304,7 +304,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (drop_column
         (keyword_drop)
@@ -325,7 +325,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (drop_column
         (keyword_drop)
@@ -345,7 +345,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (rename_column
         (keyword_rename)
@@ -368,12 +368,12 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (rename_object
         (keyword_rename)
         (keyword_to)
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -390,7 +390,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (set_schema
         (keyword_set)
@@ -411,7 +411,7 @@ ALTER TABLE my_table
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (change_ownership
         (keyword_owner)
@@ -437,7 +437,7 @@ ALTER TABLE IF EXISTS my_table
       (keyword_table)
       (keyword_if)
       (keyword_exists)
-      (table_reference
+      (object_reference
         name: (identifier))
       (add_column
         (keyword_add)
@@ -483,7 +483,7 @@ ALTER VIEW my_view
     (alter_view
       (keyword_alter)
       (keyword_view)
-      (table_reference
+      (object_reference
         name: (identifier))
       (change_ownership
         (keyword_owner)
@@ -506,12 +506,12 @@ ALTER VIEW IF EXISTS my_view
       (keyword_view)
       (keyword_if)
       (keyword_exists)
-      (table_reference
+      (object_reference
         name: (identifier))
       (rename_object
         (keyword_rename)
         (keyword_to)
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -527,13 +527,12 @@ ALTER TABLE "Role" ADD CONSTRAINT "pkRole" PRIMARY KEY ("roleId");
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (add_constraint
         (keyword_add)
         (keyword_constraint)
-        (field
-          name: (identifier))
+        (identifier)
         (constraint
           (keyword_primary)
           (keyword_key)
@@ -555,13 +554,13 @@ CREATE UNIQUE INDEX "akRoleName" ON "Role" ("name");
       (keyword_create)
       (keyword_unique)
       (keyword_index)
-      (literal)
+      column: (literal)
       (keyword_on)
-      (table_reference
-        (identifier))
+      (object_reference
+        name: (identifier))
       (ordered_columns
         (column
-          (literal))))))
+          name: (literal))))))
 
 ================================================================================
 Add foreign key constraint
@@ -577,13 +576,12 @@ FOREIGN KEY ("accountId") REFERENCES "Account" ("accountId") ON DELETE CASCADE;
     (alter_table
       (keyword_alter)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (add_constraint
         (keyword_add)
         (keyword_constraint)
-        (field
-          name: (identifier))
+        (identifier)
         (constraint
           (keyword_foreign)
           (keyword_key)
@@ -591,7 +589,7 @@ FOREIGN KEY ("accountId") REFERENCES "Account" ("accountId") ON DELETE CASCADE;
             (column
               name: (literal)))
           (keyword_references)
-          (table_reference
+          (object_reference
             name: (identifier))
           (ordered_columns
             (column
@@ -617,14 +615,14 @@ new_table TO old_table;
     (keyword_tables)
     (keyword_if)
     (keyword_exists)
-    (table_reference
+    (object_reference
       (identifier))
     (keyword_nowait)
     (keyword_to)
-    (table_reference
+    (object_reference
       (identifier))
-    (table_reference
+    (object_reference
       (identifier))
     (keyword_to)
-    (table_reference
+    (object_reference
       (identifier))))
diff --git a/test/corpus/comment.txt b/test/corpus/comment.txt
index 8b7fbf3d..3488c1f6 100644
--- a/test/corpus/comment.txt
+++ b/test/corpus/comment.txt
@@ -88,7 +88,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -107,7 +107,7 @@ FROM my_table;
     (marginalia)
     (from
       (keyword_from)
-      (table_reference
+      (object_reference
         name: (identifier)))))
 
 ================================================================================
@@ -139,7 +139,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -169,7 +169,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -199,7 +199,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -220,7 +220,7 @@ SELECT '-- foo' FROM bar;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier))))))
 
 ================================================================================
@@ -241,7 +241,7 @@ SELECT '/* foo */' FROM bar;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier))))))
 
 ================================================================================
diff --git a/test/corpus/compound_statements.txt b/test/corpus/compound_statements.txt
index 0be029c0..7898bae2 100644
--- a/test/corpus/compound_statements.txt
+++ b/test/corpus/compound_statements.txt
@@ -15,7 +15,7 @@ END;
       (create_table
         (keyword_create)
         (keyword_table)
-        (table_reference
+        (object_reference
           (identifier))
         (column_definitions
           (column_definition
diff --git a/test/corpus/create.txt b/test/corpus/create.txt
index 2d4a7f66..2a2ffab2 100644
--- a/test/corpus/create.txt
+++ b/test/corpus/create.txt
@@ -11,7 +11,7 @@ CREATE TABLE my_schema.my_table (id BIGINT NOT NULL PRIMARY KEY);
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         schema: (identifier)
         name: (identifier))
       (column_definitions
@@ -40,7 +40,7 @@ CREATE TABLE my_table (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -74,7 +74,7 @@ CREATE TEMP TABLE my_table (id BIGINT NOT NULL PRIMARY KEY);
       (keyword_create)
       (keyword_temp)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -103,7 +103,7 @@ CREATE TABLE my_table (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -156,7 +156,7 @@ CREATE TABLE my_table (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -177,7 +177,8 @@ CREATE TABLE my_table (
             (keyword_float))
           (keyword_default)
           (invocation
-            name: (identifier)))
+            (object_reference
+              name: (identifier))))
         (column_definition
           name: (identifier)
           type: (keyword_text)
@@ -232,7 +233,7 @@ CREATE TABLE IF NOT EXISTS `addresses` (
       (keyword_if)
       (keyword_not)
       (keyword_exists)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -264,7 +265,7 @@ CREATE TABLE `addresses` (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -327,7 +328,7 @@ CREATE TABLE IF NOT EXISTS `addresses` (
       (keyword_if)
       (keyword_not)
       (keyword_exists)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -377,7 +378,7 @@ CREATE TABLE IF NOT EXISTS `addresses` (
       (keyword_if)
       (keyword_not)
       (keyword_exists)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -458,7 +459,7 @@ CREATE TABLE IF NOT EXISTS `addresses` (
       (keyword_if)
       (keyword_not)
       (keyword_exists)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -502,7 +503,7 @@ CREATE TABLE my_table (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -546,18 +547,18 @@ SELECT * FROM my_table;
     (create_view
       (keyword_create)
       (keyword_view)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_as)
       (create_query
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term value: (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier))))))))
 
 ================================================================================
@@ -576,18 +577,18 @@ SELECT * FROM my_table;
       (keyword_or)
       (keyword_replace)
       (keyword_view)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_as)
       (create_query
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term value: (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier))))))))
 
 ================================================================================
@@ -605,7 +606,7 @@ CREATE TEMP VIEW foo AS SELECT 1;
       (keyword_create)
       (keyword_temporary)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -619,7 +620,7 @@ CREATE TEMP VIEW foo AS SELECT 1;
       (keyword_create)
       (keyword_temp)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -642,7 +643,7 @@ CREATE VIEW foo(a, b) AS SELECT 1 a, 2 b;
     (create_view
       (keyword_create)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (identifier)
       (identifier)
@@ -672,7 +673,7 @@ CREATE VIEW foo AS SELECT 1 WITH CASCADED CHECK OPTION;
     (create_view
       (keyword_create)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -688,7 +689,7 @@ CREATE VIEW foo AS SELECT 1 WITH CASCADED CHECK OPTION;
     (create_view
       (keyword_create)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -705,7 +706,7 @@ CREATE VIEW foo AS SELECT 1 WITH CASCADED CHECK OPTION;
     (create_view
       (keyword_create)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -735,18 +736,18 @@ WITH NO DATA;
       (keyword_create)
       (keyword_materialized)
       (keyword_view)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_as)
       (create_query
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term value: (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier)))))
       (keyword_with)
       (keyword_no)
@@ -768,18 +769,18 @@ WITH NO DATA
       (keyword_create)
       (keyword_materialized)
       (keyword_view)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_as)
       (create_query
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term value: (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier)))))
       (keyword_with)
       (keyword_no)
@@ -841,7 +842,7 @@ CREATE TABLE type_test (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -1026,7 +1027,7 @@ CREATE TABLE tableName (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         (identifier))
       (column_definitions
         (column_definition
@@ -1056,7 +1057,7 @@ CREATE UNLOGGED TABLE tableName (
       (keyword_create)
       (keyword_unlogged)
       (keyword_table)
-      (table_reference
+      (object_reference
         (identifier))
       (column_definitions
         (column_definition
@@ -1082,7 +1083,7 @@ CREATE TABLE some_table(
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -1141,18 +1142,18 @@ CREATE TABLE tableName AS SELECT * FROM otherTable;
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_as)
       (create_query
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term value: (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier))))))))
 
 ================================================================================
@@ -1171,7 +1172,7 @@ SELECT * FROM _cte
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -1189,16 +1190,16 @@ SELECT * FROM _cte
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   (identifier))))))
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               (identifier))))))))
 
 ================================================================================
@@ -1221,7 +1222,7 @@ UNION ALL
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -1258,7 +1259,7 @@ SELECT * FROM _cte
     (create_view
       (keyword_create)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -1276,16 +1277,16 @@ SELECT * FROM _cte
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   (identifier))))))
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               (identifier))))))))
 
 ================================================================================
@@ -1305,7 +1306,7 @@ SELECT * FROM _cte
       (keyword_create)
       (keyword_materialized)
       (keyword_view)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_as)
       (create_query
@@ -1323,16 +1324,16 @@ SELECT * FROM _cte
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   (identifier))))))
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term (all_fields))))
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               (identifier))))))))
 
 ================================================================================
@@ -1357,7 +1358,7 @@ CACHED IN 'pool1' WITH REPLICATION = 2
       (keyword_create)
       (keyword_external)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -1426,7 +1427,7 @@ CREATE TABLE "Role" (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -1452,7 +1453,7 @@ CREATE TABLE "Role" (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
@@ -1485,7 +1486,7 @@ CREATE TABLE "Session" (
     (create_table
       (keyword_create)
       (keyword_table)
-      (table_reference
+      (object_reference
         name: (identifier))
       (column_definitions
         (column_definition
diff --git a/test/corpus/cte.txt b/test/corpus/cte.txt
index 3af89cc6..a0b92805 100644
--- a/test/corpus/cte.txt
+++ b/test/corpus/cte.txt
@@ -30,16 +30,16 @@ FROM my_cte;
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier))))))
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -69,7 +69,7 @@ FROM second;
         (insert
           (keyword_insert)
           (keyword_into)
-          (table_reference
+          (object_reference
             name: (identifier))
           (list
             (column
@@ -83,7 +83,7 @@ FROM second;
         (returning
           (keyword_returning)
           (select_expression
-            (all_fields)))))
+            (term value: (all_fields))))))
     (cte
       (identifier)
       (keyword_as)
@@ -100,16 +100,16 @@ FROM second;
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier))))))
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -145,7 +145,7 @@ FROM second;
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               (identifier))))))
     (cte
       (identifier)
@@ -164,14 +164,52 @@ FROM second;
         (from
           (keyword_from)
           (relation
-            (table_reference
+            (object_reference
               (identifier))))))
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
+          (identifier))))))
+
+================================================================================
+Parenthesized CTE
+================================================================================
+
+(
+  WITH data AS (
+    SELECT 1 AS col
+  )
+  SELECT *
+  FROM data
+)
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (keyword_with)
+    (cte
+      (identifier)
+      (keyword_as)
+      (statement
+        (select
+          (keyword_select)
+          (select_expression
+            (term
+              (literal)
+              (keyword_as)
+              (identifier))))))
+    (select
+      (keyword_select)
+      (select_expression
+        (term (all_fields))))
+    (from
+      (keyword_from)
+      (relation
+        (object_reference
           (identifier))))))
diff --git a/test/corpus/delete.txt b/test/corpus/delete.txt
index aaf3f098..08f8984e 100644
--- a/test/corpus/delete.txt
+++ b/test/corpus/delete.txt
@@ -12,7 +12,7 @@ DELETE FROM my_table;
       (keyword_delete))
     (from
       (keyword_from)
-      (table_reference
+      (object_reference
         name: (identifier)))))
 
 ================================================================================
@@ -30,7 +30,7 @@ DELETE FROM ONLY my_table;
     (from
       (keyword_from)
       (keyword_only)
-      (table_reference
+      (object_reference
         name: (identifier)))))
 
 ================================================================================
@@ -48,7 +48,7 @@ LIMIT 4;
       (keyword_delete))
     (from
       (keyword_from)
-      (table_reference
+      (object_reference
         name: (identifier))
       (limit
         (keyword_limit)
@@ -70,7 +70,7 @@ LIMIT 4;
       (keyword_delete))
     (from
       (keyword_from)
-      (table_reference
+      (object_reference
         name: (identifier))
       (order_by
         (keyword_order)
@@ -99,7 +99,7 @@ WHERE id = 9;
       (keyword_delete))
     (from
       (keyword_from)
-      (table_reference
+      (object_reference
         name: (identifier))
       (where
         (keyword_where)
diff --git a/test/corpus/drop.txt b/test/corpus/drop.txt
index 876fb1a5..b938264a 100644
--- a/test/corpus/drop.txt
+++ b/test/corpus/drop.txt
@@ -11,7 +11,7 @@ DROP TABLE my_table;
   (drop_table
    (keyword_drop)
    (keyword_table)
-   (table_reference name: (identifier))
+   (object_reference name: (identifier))
   )))
 
 ==================
@@ -27,7 +27,7 @@ DROP TABLE my_table CASCADE;
   (drop_table
    (keyword_drop)
    (keyword_table)
-   (table_reference name: (identifier))
+   (object_reference name: (identifier))
    (keyword_cascade)
   )))
 
@@ -44,7 +44,7 @@ DROP VIEW my_view;
   (drop_view
    (keyword_drop)
    (keyword_view)
-   (table_reference name: (identifier))
+   (object_reference name: (identifier))
   )))
 
 ==================
@@ -77,7 +77,7 @@ DROP INDEX idx ON tbl;
    (keyword_index)
    name: (identifier)
    (keyword_on)
-   (table_reference
+   (object_reference
      name: (identifier)))))
 
 ==================
@@ -99,7 +99,7 @@ DROP INDEX CONCURRENTLY IF EXISTS idx CASCADE ON tbl;
    name: (identifier)
    (keyword_cascade)
    (keyword_on)
-   (table_reference
+   (object_reference
     name: (identifier)))))
 
 ==================
@@ -121,6 +121,6 @@ DROP INDEX CONCURRENTLY IF EXISTS idx RESTRICT ON tbl;
    name: (identifier)
    (keyword_restrict)
    (keyword_on)
-   (table_reference
+   (object_reference
     name: (identifier)))))
 
diff --git a/test/corpus/expressions.txt b/test/corpus/expressions.txt
index abe5d6e6..ce2e2ae2 100644
--- a/test/corpus/expressions.txt
+++ b/test/corpus/expressions.txt
@@ -13,17 +13,18 @@ WHERE m.is_not_deleted;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (field
-          table_alias: (identifier)
+          (object_reference
+            name: (identifier))
           name: (identifier))))))
 
 ================================================================================
@@ -41,22 +42,24 @@ WHERE m.is_not_deleted AND m.is_visible;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           operator: (keyword_and)
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -74,19 +77,20 @@ WHERE NOT m.is_not_deleted;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (unary_expression
           operator: (keyword_not)
           operand: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -105,26 +109,28 @@ WHERE NOT m.is_not_deleted
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (unary_expression
             operator: (keyword_not)
             operand: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier)))
           operator: (keyword_and)
           right: (unary_expression
             operator: (keyword_not)
             operand: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))))))))
 
 ================================================================================
@@ -145,13 +151,13 @@ WHERE m.status = "success"
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (binary_expression
@@ -159,24 +165,28 @@ WHERE m.status = "success"
             left: (binary_expression
               left: (binary_expression
                 left: (field
-                  table_alias: (identifier)
+                  (object_reference
+                    name: (identifier))
                   name: (identifier))
                 right: (literal))
               operator: (keyword_and)
               right: (binary_expression
                 left: (field
-                  table_alias: (identifier)
+                  (object_reference
+                    name: (identifier))
                   name: (identifier))
                 right: (literal)))
             operator: (keyword_and)
             right: (binary_expression
               left: (field
-                table_alias: (identifier)
+                (object_reference
+                  name: (identifier))
                 name: (identifier))
               right: (literal)))
           operator: (keyword_and)
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -197,38 +207,42 @@ WHERE m.status = "success"
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (binary_expression
             left: (binary_expression
               left: (field
-                table_alias: (identifier)
+                (object_reference
+                  name: (identifier))
                 name: (identifier))
               right: (literal))
             operator: (keyword_and)
             right: (binary_expression
               left: (field
-                table_alias: (identifier)
+                (object_reference
+                  name: (identifier))
                 name: (identifier))
               right: (literal)))
           operator: (keyword_or)
           right: (binary_expression
             left: (binary_expression
               left: (field
-                table_alias: (identifier)
+                (object_reference
+                  name: (identifier))
                 name: (identifier))
               right: (literal))
             operator: (keyword_and)
             right: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))))))))
 
 ================================================================================
@@ -246,19 +260,20 @@ WHERE NOT m.is_deleted;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (unary_expression
           operator: (keyword_not)
           operand: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -276,19 +291,20 @@ WHERE !m.is_deleted;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (unary_expression
           operator: (bang)
           operand: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -307,26 +323,28 @@ WHERE NOT m.is_deleted
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (unary_expression
             operator: (keyword_not)
             operand: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier)))
           operator: (keyword_and)
           right: (unary_expression
             operator: (keyword_not)
             operand: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))))))))
 
 ================================================================================
@@ -344,11 +362,11 @@ WHERE col IS DISTINCT FROM NULL;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -377,11 +395,11 @@ WHERE col IS NOT DISTINCT FROM NULL;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -412,11 +430,11 @@ WHERE id IS NOT NULL
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -458,15 +476,16 @@ WHERE m.id > 4 AND id < 3;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (binary_expression
             left: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))
             right: (literal))
           operator: (keyword_and)
@@ -497,11 +516,11 @@ WHERE
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -557,11 +576,11 @@ WHERE
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
diff --git a/test/corpus/functions.txt b/test/corpus/functions.txt
index a0e05d07..07eacda8 100644
--- a/test/corpus/functions.txt
+++ b/test/corpus/functions.txt
@@ -13,14 +13,15 @@ FROM my_table;
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
                 name: (identifier)))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -37,7 +38,8 @@ SELECT now();
       (select_expression
         (term
           value: (invocation
-            name: (identifier)))))))
+            (object_reference
+              name: (identifier))))))))
 
 ================================================================================
 More complex function arguments
@@ -61,7 +63,8 @@ FROM my_table AS t;
             name: (identifier)))
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
                 name: (identifier)))
@@ -69,7 +72,8 @@ FROM my_table AS t;
               value: (literal))
             parameter: (term
               value: (invocation
-                name: (identifier)
+                (object_reference
+                  name: (identifier))
                 parameter: (term
                   value: (field
                     name: (identifier)))
@@ -86,10 +90,12 @@ FROM my_table AS t;
           alias: (identifier))
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
-                table_alias: (identifier)
+                (object_reference
+                  name: (identifier))
                 name: (identifier)))
             parameter: (term
               value: (literal))
@@ -105,10 +111,10 @@ FROM my_table AS t;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
         (keyword_as)
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Casts and arrays
@@ -130,7 +136,8 @@ select col_has_check(
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (cast
                 (literal)
@@ -167,7 +174,8 @@ FROM table_a;
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             (keyword_distinct)
             parameter: (term
               value: (field
@@ -181,7 +189,7 @@ FROM table_a;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -200,22 +208,22 @@ GROUP BY some_field;
       (keyword_select)
       (select_expression
         (term
-          (group_concat
-            (keyword_group_concat)
-            (field
-              (identifier))
+          value: (group_concat
+            name: (keyword_group_concat)
+            parameter: (field
+              name: (identifier))
             (keyword_separator)
             (literal)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
-          (identifier)))
+        (object_reference
+          name: (identifier)))
       (group_by
         (keyword_group)
         (keyword_by)
         (field
-          (identifier))))))
+          name: (identifier))))))
 
 ================================================================================
 GROUP CONCAT with all optional fields
@@ -233,17 +241,17 @@ GROUP BY some_field;
       (keyword_select)
       (select_expression
         (term
-          (group_concat
-            (keyword_group_concat)
+          value: (group_concat
+            name: (keyword_group_concat)
             (keyword_distinct)
-            (field
-              (identifier))
+            parameter: (field
+              name: (identifier))
             (order_by
               (keyword_order)
               (keyword_by)
               (order_target
                 (field
-                  (identifier))
+                  name: (identifier))
                 (direction
                   (keyword_desc))))
             (keyword_separator)
@@ -251,13 +259,13 @@ GROUP BY some_field;
     (from
       (keyword_from)
       (relation
-        (table_reference
-          (identifier)))
+        (object_reference
+          name: (identifier)))
       (group_by
         (keyword_group)
         (keyword_by)
         (field
-          (identifier))))))
+          name: (identifier))))))
 
 ================================================================================
 Unary ANY, ALL, SOME
@@ -276,11 +284,11 @@ WHERE id = ANY (
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -314,11 +322,11 @@ WHERE id IN (
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -335,7 +343,7 @@ WHERE id IN (
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   name: (identifier))))))))))
 
 ================================================================================
@@ -363,11 +371,11 @@ WHERE (
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -385,7 +393,7 @@ WHERE (
                 (from
                   (keyword_from)
                   (relation
-                    (table_reference
+                    (object_reference
                       name: (identifier)))
                   (where
                     (keyword_where)
@@ -402,7 +410,7 @@ WHERE (
               (from
                 (keyword_from)
                 (relation
-                  (table_reference
+                  (object_reference
                     name: (identifier)))
                 (where
                   (keyword_where)
@@ -647,7 +655,7 @@ as 'create table x (id int) row_format=dynamic';
           (create_table
             (keyword_create)
             (keyword_table)
-            (table_reference
+            (object_reference
               (identifier))
             (column_definitions
               (column_definition
@@ -858,22 +866,25 @@ $function$
                 (select_expression
                   (term
                     (field
-                      (identifier)
+                      (object_reference
+                        (identifier))
                       (identifier)))
                   (comment)
                   (term
                     (invocation
-                      (identifier)
+                      (object_reference
+                        (identifier))
                       (term
                         (field
-                          (identifier)
+                          (object_reference
+                            (identifier))
                           (identifier))))
                     (keyword_as)
                     (identifier))))
               (from
                 (keyword_from)
                 (relation
-                  (table_reference
+                  (object_reference
                     (identifier))
                   (identifier))
                 (lateral_cross_join
@@ -899,7 +910,7 @@ $function$
                     (from
                       (keyword_from)
                       (relation
-                        (table_reference
+                        (object_reference
                           (identifier)))
                       (limit
                         (keyword_limit)
@@ -910,12 +921,13 @@ $function$
                   (keyword_group)
                   (keyword_by)
                   (field
-                    (identifier)
+                    (object_reference
+                      (identifier))
                     (identifier))))))
           (update
             (keyword_update)
             (relation
-              (table_reference
+              (object_reference
                 (identifier)))
             (keyword_set)
             (assignment
@@ -929,16 +941,18 @@ $function$
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   (identifier)))
               (where
                 (keyword_where)
                 (binary_expression
                   (field
-                    (identifier)
+                    (object_reference
+                      (identifier))
                     (identifier))
                   (field
-                    (identifier)
+                    (object_reference
+                      (identifier))
                     (identifier)))))))
         (keyword_return)
         (field
diff --git a/test/corpus/group_by.txt b/test/corpus/group_by.txt
index 663bf3d7..77503eaf 100644
--- a/test/corpus/group_by.txt
+++ b/test/corpus/group_by.txt
@@ -19,14 +19,15 @@ HAVING other_id > 10;
             name: (identifier)))
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
                 name: (identifier)))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (group_by
         (keyword_group)
@@ -59,14 +60,15 @@ HAVING other_id > 10;
             name: (identifier)))
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
                 name: (identifier)))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (group_by
         (keyword_group)
@@ -101,14 +103,15 @@ HAVING other_id > 10;
             name: (identifier)))
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
                 name: (identifier)))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (group_by
         (keyword_group)
@@ -143,14 +146,15 @@ HAVING COUNT(*) = 2;
             name: (identifier)))
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
                 name: (identifier)))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (group_by
         (keyword_group)
@@ -160,6 +164,7 @@ HAVING COUNT(*) = 2;
         (keyword_having)
         (binary_expression
           left: (invocation
-            name: (identifier)
-            parameter: (all_fields))
+            (object_reference
+              name: (identifier))
+            parameter: (term value: (all_fields)))
           right: (literal))))))
diff --git a/test/corpus/index.txt b/test/corpus/index.txt
index 121411cd..35d7df71 100644
--- a/test/corpus/index.txt
+++ b/test/corpus/index.txt
@@ -12,7 +12,7 @@ CREATE INDEX ON tab(col);
       (keyword_create)
       (keyword_index)
       (keyword_on)
-      (table_reference
+      (object_reference
         (identifier))
       (ordered_columns
         (column
@@ -41,7 +41,7 @@ WHERE tab.col > 10;
       (keyword_exists)
       (identifier)
       (keyword_on)
-      (table_reference
+      (object_reference
         (identifier))
       (keyword_using)
       (keyword_hash)
@@ -54,6 +54,7 @@ WHERE tab.col > 10;
         (keyword_where)
         (binary_expression
           (field
-            (identifier)
+            (object_reference
+              (identifier))
             (identifier))
           (literal))))))
diff --git a/test/corpus/insert.txt b/test/corpus/insert.txt
index 532245d1..36a9bdb2 100644
--- a/test/corpus/insert.txt
+++ b/test/corpus/insert.txt
@@ -12,7 +12,7 @@ VALUES('foo','bar', 3);
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -34,10 +34,10 @@ VALUES('foo','bar', 3);
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_as)
-      table_alias: (identifier)
+      alias: (identifier)
       (keyword_values)
       (list
         (literal)
@@ -58,7 +58,7 @@ VALUES ('foo', 123, '2020');
     (insert
       (keyword_replace)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (list
         (column
@@ -88,7 +88,7 @@ FROM my_other_table;
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (list
         (column
@@ -112,7 +112,7 @@ FROM my_other_table;
       (from
         (keyword_from)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier)))))))
 
 ================================================================================
@@ -130,7 +130,7 @@ RETURNING *;
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -140,7 +140,7 @@ RETURNING *;
     (returning
       (keyword_returning)
       (select_expression
-        (all_fields)))))
+        (term value: (all_fields))))))
 
 ================================================================================
 Insert returning single column
@@ -157,7 +157,7 @@ RETURNING id;
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -186,7 +186,7 @@ RETURNING id, val1, val2;
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -223,7 +223,7 @@ VALUES
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         (identifier))
       (list
         (column
@@ -248,7 +248,7 @@ INSERT INTO some_table
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_set)
       (assignment
@@ -271,7 +271,7 @@ ON CONFLICT DO NOTHING;
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -298,7 +298,7 @@ ON CONFLICT DO UPDATE SET dname = EXCLUDED.dname;
     (insert
       (keyword_insert)
       (keyword_into)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -314,7 +314,8 @@ ON CONFLICT DO UPDATE SET dname = EXCLUDED.dname;
         left: (field
           name: (identifier))
         right: (field
-          table_alias: (identifier)
+          (object_reference
+            name: (identifier))
           name: (identifier))))))
 
 ================================================================================
@@ -331,7 +332,7 @@ VALUES('foo','bar', 3);
     (insert
       (keyword_insert)
       (keyword_low_priority)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -353,7 +354,7 @@ VALUES('foo','bar', 3);
     (insert
       (keyword_insert)
       (keyword_delayed)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -375,7 +376,7 @@ VALUES('foo','bar', 3);
     (insert
       (keyword_insert)
       (keyword_high_priority)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -397,7 +398,7 @@ VALUES('foo','bar', 3);
     (insert
       (keyword_insert)
       (keyword_ignore)
-      (table_reference
+      (object_reference
         name: (identifier))
       (keyword_values)
       (list
@@ -430,7 +431,7 @@ FROM
     (insert
       (keyword_insert)
       (keyword_overwrite)
-      (table_reference
+      (object_reference
         (identifier))
       (select
         (keyword_select)
@@ -448,11 +449,11 @@ FROM
             (select
               (keyword_select)
               (select_expression
-                (all_fields)))
+                (term (all_fields))))
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   (identifier)))
               (where
                 (keyword_where)
@@ -488,7 +489,7 @@ FROM
     (insert
       (keyword_insert)
       (keyword_overwrite)
-      (table_reference
+      (object_reference
         (identifier))
       (table_partition
         (keyword_partition)
@@ -512,11 +513,11 @@ FROM
             (select
               (keyword_select)
               (select_expression
-                (all_fields)))
+                (term (all_fields))))
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   (identifier)))
               (where
                 (keyword_where)
diff --git a/test/corpus/optimize.txt b/test/corpus/optimize.txt
index 939500b5..da5e5027 100644
--- a/test/corpus/optimize.txt
+++ b/test/corpus/optimize.txt
@@ -10,7 +10,7 @@ COMPUTE STATS my_table (col1);
   (statement
     (keyword_compute)
     (keyword_stats)
-    (table_reference
+    (object_reference
       (identifier))
     (field
       (identifier))))
@@ -28,7 +28,7 @@ COMPUTE INCREMENTAL STATS my_table PARTITION (partition_col=col1);
     (keyword_compute)
     (keyword_incremental)
     (keyword_stats)
-    (table_reference
+    (object_reference
       (identifier))
     (keyword_partition)
     (table_option
@@ -52,7 +52,7 @@ NOSCAN
   (statement
     (keyword_analyze)
     (keyword_table)
-    (table_reference
+    (object_reference
       (identifier))
     (keyword_partition)
     (table_option
@@ -80,7 +80,7 @@ OPTIMIZE mytable REWRITE DATA USING BIN_PACK
 (program
   (statement
     (keyword_optimize)
-    (table_reference
+    (object_reference
       (identifier))
     (keyword_rewrite)
     (keyword_data)
@@ -108,7 +108,7 @@ VACUUM my_table;
 (program
   (statement
     (keyword_vacuum)
-    (table_reference
+    (object_reference
       (identifier))))
 
 ================================================================================
@@ -124,7 +124,7 @@ VACUUM FULL true my_table (col1, col2);
     (keyword_vacuum)
     (keyword_full)
     (keyword_true)
-    (table_reference
+    (object_reference
       (identifier))
     (field
       (identifier))
@@ -144,7 +144,7 @@ OPTIMIZE LOCAL TABLE my_table1, my_table2
     (keyword_optimize)
     (keyword_local)
     (keyword_table)
-    (table_reference
+    (object_reference
       (identifier))
-    (table_reference
+    (object_reference
       (identifier))))
diff --git a/test/corpus/select.txt b/test/corpus/select.txt
index 843aae81..aca5b2c7 100644
--- a/test/corpus/select.txt
+++ b/test/corpus/select.txt
@@ -57,11 +57,11 @@ SELECT * FROM my_table;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -77,12 +77,12 @@ SELECT * FROM ONLY my_table;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (keyword_only)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -98,12 +98,14 @@ SELECT my_table.* FROM my_table;
     (select
       (keyword_select)
       (select_expression
-        (all_fields
-          table_alias: (identifier))))
+        (term
+          value: (all_fields
+            (object_reference
+              name: (identifier))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -119,15 +121,17 @@ SELECT t.* FROM my_table AS t;
     (select
       (keyword_select)
       (select_expression
-        (all_fields
-          table_alias: (identifier))))
+        (term
+          value: (all_fields
+            (object_reference
+              name: (identifier))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
         (keyword_as)
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Simple select with fields
@@ -151,7 +155,7 @@ SELECT id, name FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -170,23 +174,26 @@ FROM join_something_on AS where_this_like_that;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
         (keyword_as)
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Simple select with fields field table alias
@@ -204,18 +211,20 @@ FROM my_table m;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Simple select with aliased table and column name using double quotes
@@ -233,16 +242,17 @@ FROM my_table "My Table";
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           (keyword_as)
           alias: (identifier))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Select with quoted column
@@ -259,12 +269,13 @@ SELECT tab."COL" FROM tab;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -288,7 +299,7 @@ WHERE id = 4;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -318,7 +329,7 @@ WHERE id = "abc";
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -348,7 +359,7 @@ WHERE id IN(1,2);
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -376,10 +387,12 @@ FROM my_table m;
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (field
-                table_alias: (identifier)
+                (object_reference
+                  name: (identifier))
                 name: (identifier)))
             parameter: (term
               value: (literal))
@@ -390,9 +403,9 @@ FROM my_table m;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Select with complex IF
@@ -410,15 +423,18 @@ FROM my_table m;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             parameter: (term
               value: (binary_expression
                 left: (field
-                  table_alias: (identifier)
+                  (object_reference
+                    name: (identifier))
                   name: (identifier))
                 right: (literal)))
             parameter: (term
@@ -429,9 +445,9 @@ FROM my_table m;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Select with distinct without parenthesis
@@ -454,7 +470,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -473,7 +489,8 @@ FROM my_table;
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             (keyword_distinct)
             parameter: (term
               value: (field
@@ -483,7 +500,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -502,22 +519,24 @@ FROM my_table AS m;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           (keyword_as)
           alias: (identifier))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           alias: (identifier))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
         (keyword_as)
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Simple select with order by
@@ -541,7 +560,7 @@ ORDER BY id DESC;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -579,7 +598,7 @@ LIMIT 5;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (limit
         (keyword_limit)
@@ -607,7 +626,7 @@ OFFSET 40;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (limit
         (keyword_limit)
@@ -629,11 +648,39 @@ SELECT * FROM my_schema.my_table;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
+          schema: (identifier)
+          name: (identifier))))))
+
+================================================================================
+Simple select with schema and fully-qualified *
+================================================================================
+
+SELECT
+  my_schema.my_table.*
+FROM
+  my_schema.my_table;
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (select
+      (keyword_select)
+      (select_expression
+        (term
+          value: (all_fields
+            (object_reference
+              schema: (identifier)
+              name: (identifier))))))
+    (from
+      (keyword_from)
+      (relation
+        (object_reference
           schema: (identifier)
           name: (identifier))))))
 
@@ -655,13 +702,14 @@ FROM
       (select_expression
         (term
           value: (field
-            schema: (identifier)
-            table_alias: (identifier)
+            (object_reference
+              schema: (identifier)
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           schema: (identifier)
           name: (identifier))))))
 
@@ -685,7 +733,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -708,7 +756,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -726,15 +774,16 @@ FROM my_table;
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             (keyword_distinct)
             parameter: (term
-              value: (field
-                name: (identifier)))))))
+                  value: (field
+                    name: (identifier)))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -752,12 +801,13 @@ FROM my_table;
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
-            parameter: (all_fields)))))
+            (object_reference
+              name: (identifier))
+            parameter: (term value: (all_fields))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -775,7 +825,8 @@ FROM my_table;
       (select_expression
         (term
           value: (invocation
-            name: (identifier)
+            (object_reference
+              name: (identifier))
             (keyword_distinct)
             parameter: (term
               value: (field
@@ -783,7 +834,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -805,37 +856,42 @@ WHERE b.c_id = 4;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (literal))))))
 
@@ -854,16 +910,16 @@ JOIN my_other_table ON TRUE;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier)))
         (keyword_on)
         predicate: (literal
@@ -887,24 +943,26 @@ ON a.id = b.a_id;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (index_hint
           (keyword_use)
           (keyword_index)
@@ -914,10 +972,12 @@ ON a.id = b.a_id;
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -941,15 +1001,15 @@ ON a.id = b.a_id;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (index_hint
           (keyword_ignore)
           (keyword_index)
@@ -959,10 +1019,12 @@ ON a.id = b.a_id;
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -982,24 +1044,26 @@ JOIN my_other_table b USING (q, w);
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_using)
         (list
           (column
@@ -1022,11 +1086,11 @@ JOIN (VALUES (1, 2), (3, 4)) AS v (col1, col2) ON TRUE;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (join
         (keyword_join)
@@ -1040,7 +1104,7 @@ JOIN (VALUES (1, 2), (3, 4)) AS v (col1, col2) ON TRUE;
               (literal)
               (literal)))
           (keyword_as)
-          table_alias: (identifier)
+          alias: (identifier)
           (list
             (column
               (identifier))
@@ -1080,121 +1144,136 @@ ON a.id = g.g_id;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (join
         (keyword_left)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_left)
         (keyword_outer)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_right)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_right)
         (keyword_outer)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_inner)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_full)
         (keyword_outer)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_full)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -1214,24 +1293,29 @@ JOIN LATERAL unnest(a.arr) AS arr ON TRUE;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
-        (all_fields
-          table_alias: (identifier))))
+        (term
+          value: (all_fields
+            (object_reference
+              name: (identifier))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (lateral_join
         (keyword_join)
         (keyword_lateral)
         (invocation
-          name: (identifier)
+          (object_reference
+            name: (identifier))
           parameter: (term
             value: (field
-              table_alias: (identifier)
+            (object_reference
+              name: (identifier))
               name: (identifier))))
         (keyword_as)
         alias: (identifier)
@@ -1256,16 +1340,19 @@ CROSS JOIN LATERAL (SELECT 1) AS b;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
-        (all_fields
-          table_alias: (identifier))))
+        (term
+          value: (all_fields
+            (object_reference
+              name: (identifier))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (lateral_cross_join
         (keyword_cross)
         (keyword_join)
@@ -1303,78 +1390,89 @@ ON c.id = d.c_id;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (join
         (keyword_left)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (join
           (keyword_join)
           (relation
-            (table_reference
+            (object_reference
               name: (identifier))
-            table_alias: (identifier))
+            alias: (identifier))
           (keyword_on)
           predicate: (binary_expression
             left: (field
-              table_alias: (identifier)
+            (object_reference
+              name: (identifier))
               name: (identifier))
             right: (field
-              table_alias: (identifier)
+            (object_reference
+              name: (identifier))
               name: (identifier))))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -1402,15 +1500,16 @@ ORDER BY m.title, id ASC;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (binary_expression
             left: (field
-              table_alias: (identifier)
+            (object_reference
+              name: (identifier))
               name: (identifier))
             right: (literal))
           operator: (keyword_and)
@@ -1423,7 +1522,8 @@ ORDER BY m.title, id ASC;
         (keyword_by)
         (order_target
           (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (order_target
           (field
@@ -1453,7 +1553,7 @@ ORDER BY id DESC NULLS LAST, val USING < NULLS FIRST;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -1499,7 +1599,7 @@ LIMIT 1;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (index_hint
         (keyword_force)
@@ -1530,7 +1630,7 @@ LIMIT 1;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (index_hint
         (keyword_use)
@@ -1584,7 +1684,7 @@ SELECT b FROM two;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier))))
     (keyword_intersect)
     (select
@@ -1596,7 +1696,7 @@ SELECT b FROM two;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier))))))
 
 ================================================================================
@@ -1633,7 +1733,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier))))))
 
 ================================================================================
@@ -1709,7 +1809,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier))))))
 
 ================================================================================
@@ -1777,7 +1877,7 @@ FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier))))))
 
 ================================================================================
@@ -1804,7 +1904,7 @@ SELECT id || '-' || name FROM my_table;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -1835,18 +1935,20 @@ ORDER BY my_table.title, my_table.id;
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (index_hint
         (keyword_force)
         (keyword_index)
@@ -1854,30 +1956,34 @@ ORDER BY my_table.title, my_table.id;
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (binary_expression
             left: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))
             right: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier)))
           operator: (keyword_and)
           right: (binary_expression
             left: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))
             right: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier)))))
       (join
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier)))
         (index_hint
           (keyword_use)
@@ -1889,18 +1995,22 @@ ORDER BY my_table.title, my_table.id;
         predicate: (binary_expression
           left: (binary_expression
             left: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))
             right: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier)))
           operator: (keyword_and)
           right: (binary_expression
             left: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))
             right: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier)))))
       (where
         (keyword_where)
@@ -1909,13 +2019,15 @@ ORDER BY my_table.title, my_table.id;
             left: (binary_expression
               left: (binary_expression
                 left: (field
-                  table_alias: (identifier)
+                  (object_reference
+                    name: (identifier))
                   name: (identifier))
                 right: (literal))
               operator: (keyword_and)
               right: (binary_expression
                 left: (field
-                  table_alias: (identifier)
+                  (object_reference
+                    name: (identifier))
                   name: (identifier))
                 operator: (keyword_in)
                 right: (list
@@ -1923,13 +2035,15 @@ ORDER BY my_table.title, my_table.id;
             operator: (keyword_and)
             right: (binary_expression
               left: (field
-                table_alias: (identifier)
+                (object_reference
+                  name: (identifier))
                 name: (identifier))
               right: (literal)))
           operator: (keyword_and)
           right: (binary_expression
             left: (field
-              table_alias: (identifier)
+              (object_reference
+                name: (identifier))
               name: (identifier))
             right: (literal
               (keyword_true)))))
@@ -1938,11 +2052,13 @@ ORDER BY my_table.title, my_table.id;
         (keyword_by)
         (order_target
           (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (order_target
           (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -1963,25 +2079,25 @@ FROM
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Parameterized Queries
@@ -1998,11 +2114,11 @@ WHERE id = ?;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -2026,11 +2142,11 @@ WHERE id = $12;
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -2064,14 +2180,14 @@ FROM
           (select
             (keyword_select)
             (select_expression
-              (all_fields)))
+              (term value: (all_fields))))
           (from
             (keyword_from)
             (relation
-              (table_reference
+              (object_reference
                 name: (identifier)))))
         (keyword_as)
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Select from inplace values insert
@@ -2089,7 +2205,7 @@ FROM
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
@@ -2102,7 +2218,7 @@ FROM
             (literal)
             (literal)))
         (keyword_as)
-        (identifier)
+        alias: (identifier)
         (list
           (column
             (identifier))
@@ -2137,7 +2253,7 @@ FROM test_data;
         (select
           (keyword_select)
           (select_expression
-            (all_fields)))
+            (term value: (all_fields))))
         (from
           (keyword_from)
           (relation
@@ -2147,7 +2263,7 @@ FROM test_data;
                 (literal
                   (keyword_true))))
             (keyword_as)
-            (identifier)
+            alias: (identifier)
             (list
               (column
                 (identifier)))))))
@@ -2155,21 +2271,21 @@ FROM test_data;
       (keyword_select)
       (select_expression
         (term
-          (case
+          value: (case
             (keyword_case)
             (keyword_when)
             (field
-              (identifier))
+              name: (identifier))
             (keyword_then)
             (literal)
             (keyword_end))
           (keyword_as)
-          (identifier))))
+          alias: (identifier))))
     (from
       (keyword_from)
       (relation
-        (table_reference
-          (identifier))))))
+        (object_reference
+          name: (identifier))))))
 
 ================================================================================
 No semi-colon
@@ -2185,13 +2301,13 @@ FROM some_table s
     (select
       (keyword_select)
       (select_expression
-        (all_fields)))
+        (term value: (all_fields))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier)))))
+        alias: (identifier)))))
 
 ================================================================================
 Aliases everywhere
@@ -2217,45 +2333,51 @@ WHERE
       (select_expression
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           (keyword_as)
           alias: (identifier))
         (comment)
         (term
           value: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))
-        table_alias: (identifier))
+        alias: (identifier))
       (join
         (keyword_left)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             name: (identifier))
-          table_alias: (identifier))
+          alias: (identifier))
         (keyword_on)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (literal))))))
 
@@ -2273,19 +2395,20 @@ SELECT array[1, 2, 3 + 4, '5'::int, int_please()];
       (keyword_select)
       (select_expression
         (term
-          (array
+          value: (array
             (keyword_array)
             (literal)
             (literal)
             (binary_expression
-              (literal)
-              (literal))
+              left: (literal)
+              right: (literal))
             (cast
               (literal)
               (int
                 (keyword_int)))
             (invocation
-              (identifier))))))))
+              (object_reference
+                name: (identifier)))))))))
 
 ================================================================================
 Select with positive and negative integers
@@ -2308,7 +2431,7 @@ SELECT a + 3 from b where a >= -14
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -2338,7 +2461,7 @@ SELECT a + 3.1415 from b where a >= -3.14
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -2435,7 +2558,7 @@ where a between '2022-01-01' and '2023-01-01'
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier)))
       (where
         (keyword_where)
@@ -2469,7 +2592,7 @@ where a not between 1 and 3
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier)))
       (where
         (keyword_where)
@@ -2502,7 +2625,7 @@ WHERE (foo OR bar) AND baz
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (where
         (keyword_where)
@@ -2516,3 +2639,19 @@ WHERE (foo OR bar) AND baz
           operator: (keyword_and)
           right: (field
             name: (identifier)))))))
+
+================================================================================
+parenthesized select
+================================================================================
+
+(SELECT 1)
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (select
+      (keyword_select)
+      (select_expression
+        (term
+          (literal))))))
diff --git a/test/corpus/subquery.txt b/test/corpus/subquery.txt
index 6f136246..fd002e1e 100644
--- a/test/corpus/subquery.txt
+++ b/test/corpus/subquery.txt
@@ -22,7 +22,7 @@ WHERE id < (
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           (identifier)))
       (where
         (keyword_where)
@@ -39,7 +39,7 @@ WHERE id < (
             (from
               (keyword_from)
               (relation
-                (table_reference
+                (object_reference
                   (identifier)))
               (limit
                 (keyword_limit)
diff --git a/test/corpus/transaction.txt b/test/corpus/transaction.txt
index ad2e78de..2d12f6d5 100644
--- a/test/corpus/transaction.txt
+++ b/test/corpus/transaction.txt
@@ -1,20 +1,20 @@
-==================
+================================================================================
 Empty transaction
-==================
+================================================================================
 
 BEGIN;
 COMMIT;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (transaction
-  (keyword_begin)
-  (keyword_commit)))
+  (transaction
+    (keyword_begin)
+    (keyword_commit)))
 
-==================
+================================================================================
 Transaction begin and commit
-==================
+================================================================================
 
 BEGIN;
 ALTER TABLE my_table
@@ -22,93 +22,102 @@ ALTER TABLE my_table
 UPDATE my_table SET val3 = 'new';
 COMMIT;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (transaction
-  (keyword_begin)
-  (statement
-   (alter_table
-    (keyword_alter)
-    (keyword_table)
-    (table_reference name: (identifier))
-    (add_column (keyword_add) (keyword_column)
-     (column_definition
-      name: (identifier)
-      type: (varchar
-        (keyword_varchar)
-        size: (literal))
-      (keyword_not)
-      (keyword_null)))))
-  (statement
-   (update
-    (keyword_update)
-    (relation
-     (table_reference
-      name: (identifier)))
-    (keyword_set)
-    (assignment
-      left: (field
-        name: (identifier))
-      right: (literal))))
- (keyword_commit)))
+  (transaction
+    (keyword_begin)
+    (statement
+      (alter_table
+        (keyword_alter)
+        (keyword_table)
+        (object_reference
+          name: (identifier))
+        (add_column
+          (keyword_add)
+          (keyword_column)
+          (column_definition
+            name: (identifier)
+            type: (varchar
+              (keyword_varchar)
+              size: (literal))
+            (keyword_not)
+            (keyword_null)))))
+    (statement
+      (update
+        (keyword_update)
+        (relation
+          (object_reference
+            name: (identifier)))
+        (keyword_set)
+        (assignment
+          left: (field
+            name: (identifier))
+          right: (literal))))
+    (keyword_commit)))
 
-==================
+================================================================================
 Transaction begin and rollback
-==================
+================================================================================
 
 BEGIN;
 ALTER TABLE my_table
   ADD COLUMN val3 VARCHAR(100) NOT NULL;
 ROLLBACK;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (transaction
-  (keyword_begin)
-  (statement
-   (alter_table
-    (keyword_alter)
-    (keyword_table)
-    (table_reference name: (identifier))
-    (add_column (keyword_add) (keyword_column)
-     (column_definition
-      name: (identifier)
-      type: (varchar
-        (keyword_varchar)
-        size: (literal))
-      (keyword_not)
-      (keyword_null)))))
-  (keyword_rollback)))
+  (transaction
+    (keyword_begin)
+    (statement
+      (alter_table
+        (keyword_alter)
+        (keyword_table)
+        (object_reference
+          name: (identifier))
+        (add_column
+          (keyword_add)
+          (keyword_column)
+          (column_definition
+            name: (identifier)
+            type: (varchar
+              (keyword_varchar)
+              size: (literal))
+            (keyword_not)
+            (keyword_null)))))
+    (keyword_rollback)))
 
-==================
+================================================================================
 Use explicit transaction keywords
-==================
+================================================================================
 
 BEGIN TRANSACTION;
 ALTER TABLE my_table
   ADD COLUMN val3 VARCHAR(100) NOT NULL;
 ROLLBACK TRANSACTION;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (transaction
-  (keyword_begin)
-  (keyword_transaction)
-  (statement
-   (alter_table
-    (keyword_alter)
-    (keyword_table)
-    (table_reference name: (identifier))
-    (add_column (keyword_add) (keyword_column)
-     (column_definition
-      name: (identifier)
-      type: (varchar
-        (keyword_varchar)
-        size: (literal))
-      (keyword_not)
-      (keyword_null)))))
-  (keyword_rollback)
-  (keyword_transaction)))
+  (transaction
+    (keyword_begin)
+    (keyword_transaction)
+    (statement
+      (alter_table
+        (keyword_alter)
+        (keyword_table)
+        (object_reference
+          name: (identifier))
+        (add_column
+          (keyword_add)
+          (keyword_column)
+          (column_definition
+            name: (identifier)
+            type: (varchar
+              (keyword_varchar)
+              size: (literal))
+            (keyword_not)
+            (keyword_null)))))
+    (keyword_rollback)
+    (keyword_transaction)))
diff --git a/test/corpus/update.txt b/test/corpus/update.txt
index 897c41b8..27a69da6 100644
--- a/test/corpus/update.txt
+++ b/test/corpus/update.txt
@@ -12,7 +12,7 @@ SET for = foo + 1;
     (update
       (keyword_update)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (keyword_set)
       (assignment
@@ -38,7 +38,7 @@ SET for = foo + 1;
       (keyword_update)
       (keyword_only)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (keyword_set)
       (assignment
@@ -63,7 +63,7 @@ SET for = foo + 1, col2 = col1;
     (update
       (keyword_update)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (keyword_set)
       (assignment
@@ -94,27 +94,31 @@ WHERE items.id=month.item_id;
     (update
       (keyword_update)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (keyword_set)
       (assignment
         left: (field
-          table_alias: (identifier)
+          (object_reference
+            name: (identifier))
           name: (identifier))
         right: (field
-          table_alias: (identifier)
+          (object_reference
+            name: (identifier))
           name: (identifier)))
       (where
         (keyword_where)
         predicate: (binary_expression
           left: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier))
           right: (field
-            table_alias: (identifier)
+            (object_reference
+              name: (identifier))
             name: (identifier)))))))
 
 ================================================================================
@@ -131,14 +135,15 @@ SET ts = now();
     (update
       (keyword_update)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier)))
       (keyword_set)
       (assignment
         left: (field
           name: (identifier))
         right: (invocation
-          name: (identifier))))))
+          (object_reference
+            name: (identifier)))))))
 
 ================================================================================
 Update with a JOIN
@@ -157,43 +162,48 @@ a.d = 5;
     (update
       (keyword_update)
       (relation
-        (table_reference
+        (object_reference
           (identifier))
         (identifier))
       (join
         (keyword_inner)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             (identifier))
           (identifier))
         (keyword_on)
         (binary_expression
           (field
-            (identifier)
+            (object_reference
+              (identifier))
             (identifier))
           (field
-            (identifier)
+            (object_reference
+              (identifier))
             (identifier))))
       (join
         (keyword_inner)
         (keyword_join)
         (relation
-          (table_reference
+          (object_reference
             (identifier))
           (identifier))
         (keyword_on)
         (binary_expression
           (field
-            (identifier)
+            (object_reference
+              (identifier))
             (identifier))
           (field
-            (identifier)
+            (object_reference
+              (identifier))
             (identifier))))
       (keyword_set)
       (assignment
         (field
-          (identifier)
+          (object_reference
+            (identifier))
           (identifier))
         (literal)))))
 
@@ -212,7 +222,7 @@ WHERE b.a = a.uid;
     (update
       (keyword_update)
       (relation
-        (table_reference
+        (object_reference
           (identifier))
         (keyword_as)
         (identifier))
@@ -225,10 +235,12 @@ WHERE b.a = a.uid;
         (keyword_where)
         (binary_expression
           (field
-            (identifier)
+            (object_reference
+              (identifier))
             (identifier))
           (field
-            (identifier)
+            (object_reference
+              (identifier))
             (identifier)))))))
 
 ================================================================================
@@ -248,7 +260,7 @@ WHERE b.a = a.uid;
     (update
       (keyword_update)
       (relation
-        (table_reference
+        (object_reference
           (identifier))
         (keyword_as)
         (identifier))
@@ -260,30 +272,34 @@ WHERE b.a = a.uid;
       (from
         (keyword_from)
         (relation
-          (table_reference
+          (object_reference
             (identifier))
           (identifier))
         (join
           (keyword_inner)
           (keyword_join)
           (relation
-            (table_reference
+            (object_reference
               (identifier))
             (identifier))
           (keyword_on)
           (binary_expression
             (field
-              (identifier)
+              (object_reference
+                (identifier))
               (identifier))
             (field
-              (identifier)
+              (object_reference
+                (identifier))
               (identifier))))
         (where
           (keyword_where)
           (binary_expression
             (field
-              (identifier)
+              (object_reference
+                (identifier))
               (identifier))
             (field
-              (identifier)
+              (object_reference
+                (identifier))
               (identifier))))))))
diff --git a/test/corpus/window_functions.txt b/test/corpus/window_functions.txt
index 87f61655..2efd8d7a 100644
--- a/test/corpus/window_functions.txt
+++ b/test/corpus/window_functions.txt
@@ -28,7 +28,8 @@ FROM tab1;
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -42,7 +43,7 @@ FROM tab1;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -75,7 +76,8 @@ FROM tab1;
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -94,7 +96,7 @@ FROM tab1;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -127,7 +129,8 @@ FROM tab1;
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -151,7 +154,7 @@ FROM tab1;
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -171,24 +174,25 @@ FROM tab1;
       (keyword_select)
       (select_expression
         (term
-          (field
-            (identifier)))
+          value: (field
+            name: (identifier)))
         (term
-          (window_function
+          value: (window_function
             (invocation
-              (identifier)
-              (term
-                (field
-                  (identifier))))
+              (object_reference
+                name: (identifier))
+              parameter: (term
+                value: (field
+                  name: (identifier))))
             (keyword_over)
             (window_specification))
           (keyword_as)
-          (identifier))))
+          alias: (identifier))))
     (from
       (keyword_from)
       (relation
-        (table_reference
-          (identifier))))))
+        (object_reference
+          name: (identifier))))))
 
 ================================================================================
 Window Functions two inline functions
@@ -213,7 +217,8 @@ FROM tab1;
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -229,7 +234,8 @@ FROM tab1;
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -275,7 +281,8 @@ WINDOW window_def AS (PARTITION BY y);
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -284,18 +291,18 @@ WINDOW window_def AS (PARTITION BY y);
     (from
       (keyword_from)
       (relation
-        (table_reference
-          name: (identifier))))
-    (window_clause
-      (keyword_window)
-      (identifier)
-      (keyword_as)
-      (window_specification
-        (partition_by
-          (keyword_partition)
-          (keyword_by)
-          (field
-            name: (identifier)))))))
+        (object_reference
+          name: (identifier)))
+      (window_clause
+        (keyword_window)
+        (identifier)
+        (keyword_as)
+        (window_specification
+          (partition_by
+            (keyword_partition)
+            (keyword_by)
+            (field
+              name: (identifier))))))))
 
 ================================================================================
 Window Functions one inlined one named
@@ -304,7 +311,7 @@ Window Functions one inlined one named
 SELECT
   a,
   SUM(b) OVER (PARTITION BY c) AS w1,
-  AVG(b) OVER win AS w2,
+  AVG(b) OVER win AS w2
 FROM tab1
 WINDOW win AS (ORDER BY d)
 ;
@@ -322,7 +329,8 @@ WINDOW win AS (ORDER BY d)
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -338,29 +346,31 @@ WINDOW win AS (ORDER BY d)
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
             (keyword_over)
             (identifier))
           (keyword_as)
-          alias: (identifier))
-        (term
-          value: (field
-            name: (identifier))
           alias: (identifier))))
-    (window_clause
-      (keyword_window)
-      (identifier)
-      (keyword_as)
-      (window_specification
-        (order_by
-          (keyword_order)
-          (keyword_by)
-          (order_target
-            (field
-              name: (identifier))))))))
+    (from
+      (keyword_from)
+      (relation
+        (object_reference
+          name: (identifier)))
+      (window_clause
+        (keyword_window)
+        (identifier)
+        (keyword_as)
+        (window_specification
+          (order_by
+            (keyword_order)
+            (keyword_by)
+            (order_target
+              (field
+                name: (identifier)))))))))
 
 ================================================================================
 Window Functions partition order frame
@@ -398,7 +408,8 @@ FROM
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -428,7 +439,8 @@ FROM
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -450,7 +462,7 @@ FROM
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -485,7 +497,8 @@ FROM
         (term
           value: (window_function
             (invocation
-              name: (identifier)
+              (object_reference
+                name: (identifier))
               parameter: (term
                 value: (field
                   name: (identifier))))
@@ -524,7 +537,7 @@ FROM
     (from
       (keyword_from)
       (relation
-        (table_reference
+        (object_reference
           name: (identifier))))))
 
 ================================================================================
@@ -567,18 +580,19 @@ FROM
       (keyword_select)
       (select_expression
         (term
-          (field
-            (identifier)))
+          value: (field
+            name: (identifier)))
         (term
-          (field
-            (identifier)))
+          value: (field
+            name: (identifier)))
         (term
-          (window_function
+          value: (window_function
             (invocation
-              (identifier)
-              (term
-                (field
-                  (identifier))))
+              (object_reference
+                name: (identifier))
+              parameter: (term
+                value: (field
+                  name: (identifier))))
             (keyword_over)
             (window_specification
               (partition_by
@@ -586,15 +600,15 @@ FROM
                 (keyword_by)
                 (literal)
                 (field
-                  (identifier))
+                  name: (identifier))
                 (parameter)
                 (case
                   (keyword_case)
                   (keyword_when)
                   (binary_expression
-                    (field
-                      (identifier))
-                    (literal))
+                    left: (field
+                      name: (identifier))
+                    right: (literal))
                   (keyword_then)
                   (literal
                     (keyword_true))
@@ -603,37 +617,38 @@ FROM
                     (keyword_false))
                   (keyword_end))
                 (cast
-                  (keyword_cast)
-                  (field
-                    (identifier))
+                  name: (keyword_cast)
+                  parameter: (field
+                    name: (identifier))
                   (keyword_as)
                   (keyword_date))
                 (cast
                   (field
-                    (identifier))
+                    name: (identifier))
                   (keyword_date))
                 (subquery
                   (select
                     (keyword_select)
                     (select_expression
                       (term
-                        (field
-                          (identifier)))))
+                        value: (field
+                          name: (identifier)))))
                   (from
                     (keyword_from)
                     (relation
-                      (table_reference
-                        (identifier)))))
+                      (object_reference
+                        name: (identifier)))))
                 (invocation
-                  (identifier)
-                  (term
-                    (field
-                      (identifier))))
+                  (object_reference
+                    name: (identifier))
+                  parameter: (term
+                    value: (field
+                      name: (identifier))))
                 (binary_expression
-                  (field
-                    (identifier))
-                  (field
-                    (identifier))))
+                  left: (field
+                    name: (identifier))
+                  right: (field
+                    name: (identifier))))
               (order_by
                 (keyword_order)
                 (keyword_by)
@@ -641,7 +656,7 @@ FROM
                   (literal))
                 (order_target
                   (field
-                    (identifier)))
+                    name: (identifier)))
                 (order_target
                   (parameter))
                 (order_target
@@ -649,9 +664,9 @@ FROM
                     (keyword_case)
                     (keyword_when)
                     (binary_expression
-                      (field
-                        (identifier))
-                      (parameter))
+                      left: (field
+                        name: (identifier))
+                      right: (parameter))
                     (keyword_then)
                     (literal
                       (keyword_true))
@@ -661,15 +676,15 @@ FROM
                     (keyword_end)))
                 (order_target
                   (cast
-                    (keyword_cast)
-                    (field
-                      (identifier))
+                    name: (keyword_cast)
+                    parameter: (field
+                      name: (identifier))
                     (keyword_as)
                     (keyword_date)))
                 (order_target
                   (cast
                     (field
-                      (identifier))
+                      name: (identifier))
                     (keyword_date)))
                 (order_target
                   (subquery
@@ -677,30 +692,31 @@ FROM
                       (keyword_select)
                       (select_expression
                         (term
-                          (field
-                            (identifier)))))
+                          value: (field
+                            name: (identifier)))))
                     (from
                       (keyword_from)
                       (relation
-                        (table_reference
-                          (identifier))))))
+                        (object_reference
+                          name: (identifier))))))
                 (order_target
                   (invocation
-                    (identifier)
-                    (term
-                      (field
-                        (identifier)))))
+                    (object_reference
+                      name: (identifier))
+                    parameter: (term
+                      value: (field
+                        name: (identifier)))))
                 (order_target
                   (binary_expression
-                    (field
-                      (identifier))
-                    (field
-                      (identifier))))))))))
+                    left: (field
+                      name: (identifier))
+                    right: (field
+                      name: (identifier))))))))))
     (from
       (keyword_from)
       (relation
-        (table_reference
-          (identifier))))))
+        (object_reference
+          name: (identifier))))))
 
 ================================================================================
 Window function with empty count as aggregation
@@ -719,21 +735,22 @@ FROM tab1
       (keyword_select)
       (select_expression
         (term
-          (window_function
+          value: (window_function
             (invocation
-              (identifier)
-              (all_fields))
+              (object_reference
+                name: (identifier))
+              parameter: (term value: (all_fields)))
             (keyword_over)
             (window_specification
               (partition_by
                 (keyword_partition)
                 (keyword_by)
                 (field
-                  (identifier)))))
+                  name: (identifier)))))
           (keyword_as)
-          (identifier))))
+          alias: (identifier))))
     (from
       (keyword_from)
       (relation
-        (table_reference
-          (identifier))))))
+        (object_reference
+          name: (identifier))))))