Browse Source

HUE-6990 [autocomplete] Add table and subquery alias locations

Johan Ahlen 8 years ago
parent
commit
68249ed

+ 9 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -2816,6 +2816,7 @@ TablePrimary
      if ($1.identifierChain) {
      if ($1.identifierChain) {
        if ($3) {
        if ($3) {
          $1.alias = $3
          $1.alias = $3
+         parser.addTableAliasLocation(@3, $3, $1.identifierChain);
        }
        }
        parser.addTablePrimary($1);
        parser.addTablePrimary($1);
      }
      }
@@ -2827,6 +2828,7 @@ TablePrimary
      if ($2) {
      if ($2) {
        $1.alias = $2;
        $1.alias = $2;
        parser.addTablePrimary({ subQueryAlias: $2 });
        parser.addTablePrimary({ subQueryAlias: $2 });
+       parser.addSubqueryAliasLocation(@2, $2, $1.identifierChain);
      } else {
      } else {
        $$.suggestKeywords = [{ value: 'AS', weight: 1 }];
        $$.suggestKeywords = [{ value: 'AS', weight: 1 }];
      }
      }
@@ -2835,10 +2837,16 @@ TablePrimary
 
 
 TablePrimary_EDIT
 TablePrimary_EDIT
  : TableOrQueryName_EDIT OptionalTableSample OptionalCorrelationName
  : TableOrQueryName_EDIT OptionalTableSample OptionalCorrelationName
+   {
+     if ($3) {
+       parser.addTableAliasLocation(@3, $3, $1.identifierChain);
+     }
+   }
  | TableOrQueryName OptionalTableSample_EDIT OptionalCorrelationName
  | TableOrQueryName OptionalTableSample_EDIT OptionalCorrelationName
    {
    {
      if ($3) {
      if ($3) {
        $1.alias = $3;
        $1.alias = $3;
+       parser.addTableAliasLocation(@3, $3, $1.identifierChain);
      }
      }
      parser.addTablePrimary($1);
      parser.addTablePrimary($1);
    }
    }
@@ -2846,6 +2854,7 @@ TablePrimary_EDIT
    {
    {
      if ($2) {
      if ($2) {
        parser.addTablePrimary({ subQueryAlias: $2 });
        parser.addTablePrimary({ subQueryAlias: $2 });
+       parser.addSubqueryAliasLocation(@2, $2);
      }
      }
    }
    }
  | DerivedTable OptionalCorrelationName_EDIT
  | DerivedTable OptionalCorrelationName_EDIT

+ 17 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecLocations.js

@@ -142,6 +142,7 @@
           { type: 'database', location: { first_line: 1, last_line: 1, first_column: 35, last_column: 37 }, identifierChain: [{ name: 'db' }]},
           { type: 'database', location: { first_line: 1, last_line: 1, first_column: 35, last_column: 37 }, identifierChain: [{ name: 'db' }]},
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 38, last_column: 48 }, identifierChain: [{ name: 'db' },{ name: 'testTable2'}] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 38, last_column: 48 }, identifierChain: [{ name: 'db' },{ name: 'testTable2'}] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 50, last_column: 60 }, identifierChain: [{ name: 'testTable3' }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 50, last_column: 60 }, identifierChain: [{ name: 'testTable3' }] },
+          { type: 'alias', source: 'table', alias: 't3', location: { first_line: 1, last_line: 1, first_column: 61, last_column: 63 }, identifierChain: [{ name: 'testTable3' }] },
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 63, last_column: 63 }},
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 63, last_column: 63 }},
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 63, last_column: 63 }}
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 63, last_column: 63 }}
         ]
         ]
@@ -210,7 +211,9 @@
           { type: 'table', location: { first_line: 2, last_line: 2, first_column: 16, last_column: 19 }, identifierChain: [{ name: 'sample_07' }] },
           { type: 'table', location: { first_line: 2, last_line: 2, first_column: 16, last_column: 19 }, identifierChain: [{ name: 'sample_07' }] },
           { type: 'column', location: { first_line: 2, last_line: 2, first_column: 20, last_column: 26 }, identifierChain: [{ name: 'salary' }], tables: [{ identifierChain: [{ name: 'sample_07' }], alias: 's07' }] },
           { type: 'column', location: { first_line: 2, last_line: 2, first_column: 20, last_column: 26 }, identifierChain: [{ name: 'salary' }], tables: [{ identifierChain: [{ name: 'sample_07' }], alias: 's07' }] },
           { type: 'table', location: { first_line: 4, last_line: 4, first_column: 3, last_column: 12 }, identifierChain: [{ name: 'sample_07' }] },
           { type: 'table', location: { first_line: 4, last_line: 4, first_column: 3, last_column: 12 }, identifierChain: [{ name: 'sample_07' }] },
+          { type: 'alias', source: 'table', alias: 's07', location: { first_line: 4, last_line: 4, first_column: 13, last_column: 16 }, identifierChain: [{ name: 'sample_07' }]},
           { type: 'table', location: { first_line: 4, last_line: 4, first_column: 22, last_column: 31 }, identifierChain: [{ name: 'sample_08' }] },
           { type: 'table', location: { first_line: 4, last_line: 4, first_column: 22, last_column: 31 }, identifierChain: [{ name: 'sample_08' }] },
+          { type: 'alias', source: 'table', alias: 's08', location: { first_line: 4, last_line: 4, first_column: 32, last_column: 35 }, identifierChain: [{ name: 'sample_08' }] },
           { type: 'table', location: { first_line: 5, last_line: 5, first_column: 6, last_column: 9 }, identifierChain: [{ name: 'sample_07' }] },
           { type: 'table', location: { first_line: 5, last_line: 5, first_column: 6, last_column: 9 }, identifierChain: [{ name: 'sample_07' }] },
           { type: 'column', location: { first_line: 5, last_line: 5, first_column: 10, last_column: 14 }, identifierChain: [{ name: 'code' }], tables: [{ identifierChain: [{ name: 'sample_07' }], alias: 's07' }] },
           { type: 'column', location: { first_line: 5, last_line: 5, first_column: 10, last_column: 14 }, identifierChain: [{ name: 'code' }], tables: [{ identifierChain: [{ name: 'sample_07' }], alias: 's07' }] },
           { type: 'table', location: { first_line: 5, last_line: 5, first_column: 17, last_column: 20 }, identifierChain: [{ name: 'sample_08' }] },
           { type: 'table', location: { first_line: 5, last_line: 5, first_column: 17, last_column: 20 }, identifierChain: [{ name: 'sample_08' }] },
@@ -241,6 +244,7 @@
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 46, last_column: 55 }, identifierChain: [{ name: 'blablabla' }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 46, last_column: 55 }, identifierChain: [{ name: 'blablabla' }] },
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 55, last_column: 55 }}, // Subquery
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 55, last_column: 55 }}, // Subquery
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 55, last_column: 55 }}, // Subquery
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 55, last_column: 55 }}, // Subquery
+          { type: 'alias', source: 'subquery', alias: 's1', location: { first_line: 1, last_line: 1, first_column: 57, last_column: 59 } },
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 59, last_column: 59 }},
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 59, last_column: 59 }},
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 59, last_column: 59 }}]
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 59, last_column: 59 }}]
       });
       });
@@ -273,7 +277,9 @@
           { type: 'column', location: { first_line: 5, last_line: 5, first_column: 11, last_column: 12 }, identifierChain: [{ name: 'e' }], tables: [{ identifierChain: [{ name: 'bar' }], alias: 'baa' }] },
           { type: 'column', location: { first_line: 5, last_line: 5, first_column: 11, last_column: 12 }, identifierChain: [{ name: 'e' }], tables: [{ identifierChain: [{ name: 'bar' }], alias: 'baa' }] },
           { type: 'database', location: { first_line: 6, last_line: 6, first_column: 8, last_column: 11 }, identifierChain: [{ name: 'db1' }]},
           { type: 'database', location: { first_line: 6, last_line: 6, first_column: 8, last_column: 11 }, identifierChain: [{ name: 'db1' }]},
           { type: 'table', location: { first_line: 6, last_line: 6, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'db1' }, { name: 'foo' }]},
           { type: 'table', location: { first_line: 6, last_line: 6, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'db1' }, { name: 'foo' }]},
+          { type: 'alias', source: 'table', alias: 'boo', location: { first_line: 6, last_line: 6, first_column: 16, last_column: 19 }, identifierChain: [{ name: 'db1' }, { name: 'foo' }] },
           { type: 'table', location: { first_line: 6, last_line: 6, first_column: 21, last_column: 24 }, identifierChain: [{ name: 'bar' }]},
           { type: 'table', location: { first_line: 6, last_line: 6, first_column: 21, last_column: 24 }, identifierChain: [{ name: 'bar' }]},
+          { type: 'alias', source: 'table', alias: 'baa', location: { first_line: 6, last_line: 6, first_column: 25, last_column: 28 }, identifierChain: [{ name: 'bar' }] },
           { type: 'whereClause', missing: false, location: { first_line: 6, last_line: 6, first_column: 29, last_column: 67 } },
           { type: 'whereClause', missing: false, location: { first_line: 6, last_line: 6, first_column: 29, last_column: 67 } },
           { type: 'table', location: { first_line: 6, last_line: 6, first_column: 35, last_column: 38 }, identifierChain: [{ name: 'bar' }]},
           { type: 'table', location: { first_line: 6, last_line: 6, first_column: 35, last_column: 38 }, identifierChain: [{ name: 'bar' }]},
           { type: 'column', location: { first_line: 6, last_line: 6, first_column: 39, last_column: 42 }, identifierChain: [{ name: 'bla' }], tables: [{ identifierChain: [{ name: 'bar' }], alias: 'baa' }] },
           { type: 'column', location: { first_line: 6, last_line: 6, first_column: 39, last_column: 42 }, identifierChain: [{ name: 'bla' }], tables: [{ identifierChain: [{ name: 'bar' }], alias: 'baa' }] },
@@ -294,6 +300,7 @@
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'testTableA' }]},
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'testTableA' }]},
           { type: 'asterisk', location:{ first_line: 1, last_line: 1, first_column: 12, last_column: 13 }, tables: [{ alias: 'tta', identifierChain: [{ name: 'testTableA' }] }] },
           { type: 'asterisk', location:{ first_line: 1, last_line: 1, first_column: 12, last_column: 13 }, tables: [{ alias: 'tta', identifierChain: [{ name: 'testTableA' }] }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 29}, identifierChain: [{ name: 'testTableA' }]},
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 29}, identifierChain: [{ name: 'testTableA' }]},
+          { type: 'alias', source: 'table', alias: 'tta', location: { first_line: 1, last_line: 1, first_column: 30, last_column: 33 }, identifierChain: [{ name: 'testTableA' }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 35, last_column: 45}, identifierChain: [{ name: 'testTableB' }]},
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 35, last_column: 45}, identifierChain: [{ name: 'testTableB' }]},
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 45, last_column: 45 }},
           { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 45, last_column: 45 }},
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 45, last_column: 45 }}
           { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 45, last_column: 45 }}
@@ -348,6 +355,7 @@
             { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 68 } },
             { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 68 } },
             { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ alias: 't1', identifierChain: [{ name: 'testTable' }] }] },
             { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ alias: 't1', identifierChain: [{ name: 'testTable' }] }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 24 }, identifierChain: [{ name: 'testTable' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 24 }, identifierChain: [{ name: 'testTable' }]},
+            { type: 'alias', source: 'table', alias: 't1', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 27 }, identifierChain: [{ name: 'testTable' }] },
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 27, last_column: 27 }},
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 27, last_column: 27 }},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 37, last_column: 39 }, identifierChain: [{ name: 'testTable' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 37, last_column: 39 }, identifierChain: [{ name: 'testTable' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 40, last_column: 41 }, identifierChain: [{ name: 'a' }], tables: [{ identifierChain: [{ name: 'testTable' }], alias: 't1' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 40, last_column: 41 }, identifierChain: [{ name: 'a' }], tables: [{ identifierChain: [{ name: 'testTable' }], alias: 't1' }]},
@@ -362,12 +370,15 @@
             { type: 'table', location: { first_line: 2, last_line: 2, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'testTable2' }]},
             { type: 'table', location: { first_line: 2, last_line: 2, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'testTable2' }]},
             { type: 'column', location: { first_line: 2, last_line: 2, first_column: 11, last_column: 14 }, identifierChain: [{ name: 'bla' }], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 't1' }]},
             { type: 'column', location: { first_line: 2, last_line: 2, first_column: 11, last_column: 14 }, identifierChain: [{ name: 'bla' }], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 't1' }]},
             { type: 'table', location: { first_line: 2, last_line: 2, first_column: 20, last_column: 30 }, identifierChain: [{ name: 'testTable2' }]},
             { type: 'table', location: { first_line: 2, last_line: 2, first_column: 20, last_column: 30 }, identifierChain: [{ name: 'testTable2' }]},
+            { type: 'alias', source: 'table', alias: 't1', location: { first_line: 2, last_line: 2, first_column: 31, last_column: 33 }, identifierChain: [{ name: 'testTable2' }] },
             { type: 'whereClause', missing: true, location: { first_line: 2, last_line: 2, first_column: 33, last_column: 33 }},
             { type: 'whereClause', missing: true, location: { first_line: 2, last_line: 2, first_column: 33, last_column: 33 }},
             { type: 'limitClause', missing: true, location: { first_line: 2, last_line: 2, first_column: 33, last_column: 33 }},
             { type: 'limitClause', missing: true, location: { first_line: 2, last_line: 2, first_column: 33, last_column: 33 }},
             { type: 'statement', location: { first_line: 2, last_line: 3, first_column: 34, last_column: 43 } },
             { type: 'statement', location: { first_line: 2, last_line: 3, first_column: 34, last_column: 43 } },
             { type: 'asterisk', location: { first_line: 3, last_line: 3, first_column: 8, last_column: 9 }, tables: [{ alias: 't3', identifierChain: [{ name: 'testTable3' }]}, { alias: 't4', identifierChain: [{ name: 'testTable4' }] }] },
             { type: 'asterisk', location: { first_line: 3, last_line: 3, first_column: 8, last_column: 9 }, tables: [{ alias: 't3', identifierChain: [{ name: 'testTable3' }]}, { alias: 't4', identifierChain: [{ name: 'testTable4' }] }] },
             { type: 'table', location: { first_line: 3, last_line: 3, first_column: 15, last_column: 25 }, identifierChain: [{ name: 'testTable3' }]},
             { type: 'table', location: { first_line: 3, last_line: 3, first_column: 15, last_column: 25 }, identifierChain: [{ name: 'testTable3' }]},
+            { type: 'alias', source: 'table', alias: 't3', location: { first_line: 3, last_line: 3, first_column: 26, last_column: 28 }, identifierChain: [{ name: 'testTable3' }] },
             { type: 'table', location: { first_line: 3, last_line: 3, first_column: 30, last_column: 40 }, identifierChain: [{ name: 'testTable4' }]},
             { type: 'table', location: { first_line: 3, last_line: 3, first_column: 30, last_column: 40 }, identifierChain: [{ name: 'testTable4' }]},
+            { type: 'alias', source: 'table', alias: 't4', location: { first_line: 3, last_line: 3, first_column: 41, last_column: 43 }, identifierChain: [{ name: 'testTable4' }] },
             { type: 'whereClause', missing: true, location: { first_line: 3, last_line: 3, first_column: 43, last_column: 43 }},
             { type: 'whereClause', missing: true, location: { first_line: 3, last_line: 3, first_column: 43, last_column: 43 }},
             { type: 'limitClause', missing: true, location: { first_line: 3, last_line: 3, first_column: 43, last_column: 43 }}
             { type: 'limitClause', missing: true, location: { first_line: 3, last_line: 3, first_column: 43, last_column: 43 }}
           ]
           ]
@@ -383,9 +394,11 @@
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'table1' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'table1' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 11, last_column: 14 }, identifierChain: [{ name: 'foo' }], tables: [{ identifierChain: [{ name: 'table1' }], alias: 't1' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 11, last_column: 14 }, identifierChain: [{ name: 'foo' }], tables: [{ identifierChain: [{ name: 'table1' }], alias: 't1' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 26 }, identifierChain: [{ name: 'table1' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 26 }, identifierChain: [{ name: 'table1' }]},
+            { type: 'alias', source: 'table', alias: 't1', location: { first_line: 1, last_line: 1, first_column: 27, last_column: 29 }, identifierChain: [{ name: 'table1' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 41, last_column: 47 }, identifierChain: [{ name: 'table2' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 41, last_column: 47 }, identifierChain: [{ name: 'table2' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 64, last_column: 70 }, identifierChain: [{ name: 'table3' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 64, last_column: 70 }, identifierChain: [{ name: 'table3' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 76, last_column: 82 }, identifierChain: [{ name: 'table4' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 76, last_column: 82 }, identifierChain: [{ name: 'table4' }]},
+            { type: 'alias', source: 'table', alias: 't4', location: { first_line: 1, last_line: 1, first_column: 83, last_column: 85 }, identifierChain: [{ name: 'table4' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 90, last_column: 92 }, identifierChain: [{ name: 'table1' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 90, last_column: 92 }, identifierChain: [{ name: 'table1' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 93, last_column: 95 }, identifierChain: [{ name: 'c1' }], tables: [{ identifierChain: [{ name: 'table1' }], alias: 't1' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 93, last_column: 95 }, identifierChain: [{ name: 'c1' }], tables: [{ identifierChain: [{ name: 'table1' }], alias: 't1' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 98, last_column: 104 }, identifierChain: [{ name: 'table2' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 98, last_column: 104 }, identifierChain: [{ name: 'table2' }]},
@@ -556,6 +569,7 @@
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 }, identifierChain: [{ name: 'some_tbl' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 }, identifierChain: [{ name: 'some_tbl' }] },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'col' }], tables: [{ identifierChain: [{ name: 'some_tbl' }], alias: 'tbl' }] },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'col' }], tables: [{ identifierChain: [{ name: 'some_tbl' }], alias: 'tbl' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 21, last_column: 29 }, identifierChain: [{ name: 'some_tbl' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 21, last_column: 29 }, identifierChain: [{ name: 'some_tbl' }] },
+            { type: 'alias', source: 'table', alias: 'tbl', location: { first_line: 1, last_line: 1, first_column: 30, last_column: 33 }, identifierChain: [{ name: 'some_tbl' }] },
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 33, last_column: 33 }},
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 33, last_column: 33 }},
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 33, last_column: 33 }}
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 33, last_column: 33 }}
           ]
           ]
@@ -573,6 +587,7 @@
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'col' }], tables: [{ identifierChain: [{ name: 'some_tbl' }], alias: 'tbl' }] },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'col' }], tables: [{ identifierChain: [{ name: 'some_tbl' }], alias: 'tbl' }] },
             { type: 'complex', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 20 }, identifierChain: [{ name: 'col' }, { name: 'cplx' }], tables: [{ identifierChain: [{ name: 'some_tbl' }], alias: 'tbl' }] },
             { type: 'complex', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 20 }, identifierChain: [{ name: 'col' }, { name: 'cplx' }], tables: [{ identifierChain: [{ name: 'some_tbl' }], alias: 'tbl' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 26, last_column: 34 }, identifierChain: [{ name: 'some_tbl' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 26, last_column: 34 }, identifierChain: [{ name: 'some_tbl' }] },
+            { type: 'alias', source: 'table', alias: 'tbl', location: { first_line: 1, last_line: 1, first_column: 35, last_column: 38 }, identifierChain: [{ name: 'some_tbl' }] },
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 38, last_column: 38 }},
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 38, last_column: 38 }},
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 38, last_column: 38 }}
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 38, last_column: 38 }}
           ]
           ]
@@ -612,6 +627,7 @@
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 51, last_column: 54 }, identifierChain: [{ name: 'bla' }], tables: [{ identifierChain: [{ name: 'testTableA' }], alias: 'tta' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 51, last_column: 54 }, identifierChain: [{ name: 'bla' }], tables: [{ identifierChain: [{ name: 'testTableA' }], alias: 'tta' }]},
             { type: 'function', location: { first_line: 1, last_line: 1, first_column: 56, last_column: 58 }, function: 'cos' },
             { type: 'function', location: { first_line: 1, last_line: 1, first_column: 56, last_column: 58 }, function: 'cos' },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 68, last_column: 78 }, identifierChain: [{ name: 'testTableA' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 68, last_column: 78 }, identifierChain: [{ name: 'testTableA' }]},
+            { type: 'alias', source: 'table', alias: 'tta', location: { first_line: 1, last_line: 1, first_column: 79, last_column: 82 }, identifierChain: [{ name: 'testTableA' }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 84, last_column: 94 }, identifierChain: [{ name: 'testTableB' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 84, last_column: 94 }, identifierChain: [{ name: 'testTableB' }]},
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 94, last_column: 94 }},
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 94, last_column: 94 }},
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 94, last_column: 94 }}
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 94, last_column: 94 }}
@@ -658,6 +674,7 @@
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 235, last_column: 237 }, identifierChain: [{ name:'tstDb1' },{ name: 'b1' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 235, last_column: 237 }, identifierChain: [{ name:'tstDb1' },{ name: 'b1' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 238, last_column: 241 }, identifierChain: [{ name: 'cat' }], tables: [{ identifierChain: [{ name:'tstDb1' }, {name: 'b1' }] }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 238, last_column: 241 }, identifierChain: [{ name: 'cat' }], tables: [{ identifierChain: [{ name:'tstDb1' }, {name: 'b1' }] }]},
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 241, last_column: 241 }},
             { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 241, last_column: 241 }},
+            { type: 'alias', source: 'subquery', alias: 'tmp', location: { first_line: 1, last_line: 1, first_column: 243, last_column: 246 } },
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 246, last_column: 246 }},
             { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 246, last_column: 246 }},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 256, last_column: 257 }, identifierChain: [{ name: 'r' }], tables: [{ subQuery: 'tmp' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 256, last_column: 257 }, identifierChain: [{ name: 'r' }], tables: [{ subQuery: 'tmp' }]},
             { type: 'limitClause', missing: false, location: { first_line: 1, last_line: 1, first_column: 263, last_column: 271 }}
             { type: 'limitClause', missing: false, location: { first_line: 1, last_line: 1, first_column: 263, last_column: 271 }}

+ 7 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecSelect.js

@@ -344,6 +344,7 @@
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 }, identifierChain: [{ name: 'id' }], tables: [{ identifierChain: [{ name: 'autocomp_test' }], alias: 'tst' }] },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 }, identifierChain: [{ name: 'id' }], tables: [{ identifierChain: [{ name: 'autocomp_test' }], alias: 'tst' }] },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 39, last_column: 42 }, identifierChain: [{ name: 'avg' }], tables: [{ identifierChain: [{ name: 'autocomp_test' }], alias: 'tst' }] },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 39, last_column: 42 }, identifierChain: [{ name: 'avg' }], tables: [{ identifierChain: [{ name: 'autocomp_test' }], alias: 'tst' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 48, last_column: 61 }, identifierChain: [{ name: 'autocomp_test' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 48, last_column: 61 }, identifierChain: [{ name: 'autocomp_test' }] },
+              { type: 'alias', source: 'table', alias: 'tst', location: { first_line: 1, last_line: 1, first_column: 62, last_column: 65 }, identifierChain: [{ name: 'autocomp_test' }] },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 65, last_column: 65 } },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 65, last_column: 65 } },
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 65, last_column: 65 } }
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 65, last_column: 65 } }
             ],
             ],
@@ -3058,6 +3059,7 @@
                 { type: 'complex', location: { first_line: 2, last_line: 2, first_column: 2, last_column: 11 }, identifierChain: [{ name: 'testArrayA'}, {name: 'item'}], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 'tt2' }]},
                 { type: 'complex', location: { first_line: 2, last_line: 2, first_column: 2, last_column: 11 }, identifierChain: [{ name: 'testArrayA'}, {name: 'item'}], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 'tt2' }]},
                 { type: 'complex', location: { first_line: 3, last_line: 3, first_column: 2, last_column: 11 }, identifierChain: [{ name: 'testArrayB' },{ name: 'item'}], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 'tt2' }]},
                 { type: 'complex', location: { first_line: 3, last_line: 3, first_column: 2, last_column: 11 }, identifierChain: [{ name: 'testArrayB' },{ name: 'item'}], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 'tt2' }]},
                 { type: 'table', location: { first_line: 5, last_line: 5, first_column: 3, last_column: 13 }, identifierChain: [{ name: 'testTable2' }]},
                 { type: 'table', location: { first_line: 5, last_line: 5, first_column: 3, last_column: 13 }, identifierChain: [{ name: 'testTable2' }]},
+                { type: 'alias', source: 'table', alias: 'tt2', location: { first_line: 5, last_line: 5, first_column: 14, last_column: 17 }, identifierChain: [{ name: 'testTable2' }] },
                 { type: 'function', location: { first_line: 6, last_line: 6, first_column: 16, last_column: 22 }, function: 'explode'},
                 { type: 'function', location: { first_line: 6, last_line: 6, first_column: 16, last_column: 22 }, function: 'explode'},
                 { type: 'table', location: { first_line: 6, last_line: 6, first_column: 24, last_column: 27 }, identifierChain: [{ name: 'testTable2' }]},
                 { type: 'table', location: { first_line: 6, last_line: 6, first_column: 24, last_column: 27 }, identifierChain: [{ name: 'testTable2' }]},
                 { type: 'column', location: { first_line: 6, last_line: 6, first_column: 28, last_column: 38 }, identifierChain: [{ name: 'testArrayA'}], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 'tt2' }] },
                 { type: 'column', location: { first_line: 6, last_line: 6, first_column: 28, last_column: 38 }, identifierChain: [{ name: 'testArrayA'}], tables: [{ identifierChain: [{ name: 'testTable2' }], alias: 'tt2' }] },
@@ -3275,8 +3277,10 @@
               { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 42 } },
               { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 42 } },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10}, identifierChain: [{ name: 'testMap' }], tables: [{ identifierChain: [{ name: 'testTable' }], alias: 't' }]},
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10}, identifierChain: [{ name: 'testMap' }], tables: [{ identifierChain: [{ name: 'testTable' }], alias: 't' }]},
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 17, last_column :26}, identifierChain: [{ name: 'testTable' }]},
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 17, last_column :26}, identifierChain: [{ name: 'testTable' }]},
+              { type: 'alias', source: 'table', alias: 't', location: { first_line: 1, last_line: 1, first_column: 27, last_column: 28 }, identifierChain: [{ name: 'testTable' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 30, last_column: 31}, identifierChain: [{ name: 'testTable' }]},
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 30, last_column: 31}, identifierChain: [{ name: 'testTable' }]},
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 32, last_column :39}, identifierChain: [{ name: 'testMap'}], tables: [{ identifierChain: [{ name: 'testTable' }], alias: 't'  }]},
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 32, last_column :39}, identifierChain: [{ name: 'testMap'}], tables: [{ identifierChain: [{ name: 'testTable' }], alias: 't'  }]},
+              { type: 'alias', source: 'table', alias: 'tm', location: { first_line: 1, last_line: 1, first_column: 40, last_column: 42 }, identifierChain: [{ name: 't' }, { name: 'testMap' }] },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 42, last_column: 42 } },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 42, last_column: 42 } },
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 42, last_column: 42 } }
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 42, last_column: 42 } }
             ],
             ],
@@ -6934,6 +6938,7 @@
               { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 103 } },
               { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 103 } },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 39, last_column: 41}, identifierChain: [{ name: 't1' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 39, last_column: 41}, identifierChain: [{ name: 't1' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 43, last_column: 45}, identifierChain: [{ name: 't2' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 43, last_column: 45}, identifierChain: [{ name: 't2' }] },
+              { type: 'alias', source: 'table', alias: 'ta2', location: { first_line: 1, last_line: 1, first_column: 46, last_column: 52 }, identifierChain: [{ name: 't2' }] },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 52, last_column: 52 } },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 52, last_column: 52 } },
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 52, last_column: 52 } },
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 52, last_column: 52 } },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 74, last_column: 76}, identifierChain: [{ name: 't3' }]},
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 74, last_column: 76}, identifierChain: [{ name: 't3' }]},
@@ -6955,11 +6960,13 @@
             locations: [
             locations: [
               { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 67 } },
               { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 67 } },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23}, identifierChain: [{ name: 'testTable' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23}, identifierChain: [{ name: 'testTable' }] },
+              { type: 'alias', source: 'table', alias: 'tt', location: { first_line: 1, last_line: 1, first_column: 24, last_column: 26 }, identifierChain: [{ name: 'testTable' }] },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 36, last_column: 39}, identifierChain: [{ name: 'bla'}], tables: [{ identifierChain: [{ name: 'abc' }] }] },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 36, last_column: 39}, identifierChain: [{ name: 'bla'}], tables: [{ identifierChain: [{ name: 'abc' }] }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 45, last_column: 48}, identifierChain: [{ name: 'abc' }] },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 45, last_column: 48}, identifierChain: [{ name: 'abc' }] },
               { type: 'whereClause', missing: false, location: { first_line: 1, last_line: 1, first_column: 49, last_column: 62 } },
               { type: 'whereClause', missing: false, location: { first_line: 1, last_line: 1, first_column: 49, last_column: 62 } },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 55, last_column: 58}, identifierChain: [{ name: 'foo'}], tables: [{ identifierChain: [{ name: 'abc' }] }] },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 55, last_column: 58}, identifierChain: [{ name: 'foo'}], tables: [{ identifierChain: [{ name: 'abc' }] }] },
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 62, last_column: 62 } },
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 62, last_column: 62 } },
+              { type: 'alias', source: 'subquery', alias: 'bar', location: { first_line: 1, last_line: 1, first_column: 64, last_column: 67 } },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 67, last_column: 67 } },
               { type: 'whereClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 67, last_column: 67 } },
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 67, last_column: 67 } }
               { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 67, last_column: 67 } }
             ],
             ],

+ 11 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js

@@ -1980,6 +1980,7 @@ case 1293:
      if ($$[$0-2].identifierChain) {
      if ($$[$0-2].identifierChain) {
        if ($$[$0]) {
        if ($$[$0]) {
          $$[$0-2].alias = $$[$0]
          $$[$0-2].alias = $$[$0]
+         parser.addTableAliasLocation(_$[$0], $$[$0], $$[$0-2].identifierChain);
        }
        }
        parser.addTablePrimary($$[$0-2]);
        parser.addTablePrimary($$[$0-2]);
      }
      }
@@ -1992,15 +1993,24 @@ case 1294:
      if ($$[$0]) {
      if ($$[$0]) {
        $$[$0-1].alias = $$[$0];
        $$[$0-1].alias = $$[$0];
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
+       parser.addSubqueryAliasLocation(_$[$0], $$[$0], $$[$0-1].identifierChain);
      } else {
      } else {
        this.$.suggestKeywords = [{ value: 'AS', weight: 1 }];
        this.$.suggestKeywords = [{ value: 'AS', weight: 1 }];
      }
      }
    
    
+break;
+case 1295:
+
+     if ($$[$0]) {
+       parser.addTableAliasLocation(_$[$0], $$[$0], $$[$0-2].identifierChain);
+     }
+   
 break;
 break;
 case 1296:
 case 1296:
 
 
      if ($$[$0]) {
      if ($$[$0]) {
        $$[$0-2].alias = $$[$0];
        $$[$0-2].alias = $$[$0];
+       parser.addTableAliasLocation(_$[$0], $$[$0], $$[$0-2].identifierChain);
      }
      }
      parser.addTablePrimary($$[$0-2]);
      parser.addTablePrimary($$[$0-2]);
    
    
@@ -2009,6 +2019,7 @@ case 1297:
 
 
      if ($$[$0]) {
      if ($$[$0]) {
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
+       parser.addSubqueryAliasLocation(_$[$0], $$[$0]);
      }
      }
    
    
 break;
 break;

+ 21 - 2
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlParseSupport.js

@@ -1311,6 +1311,25 @@ var SqlParseSupport = (function () {
       });
       });
     };
     };
 
 
+    parser.addTableAliasLocation = function (location, alias, identifierChain) {
+      parser.yy.locations.push({
+        type: 'alias',
+        source: 'table',
+        alias: alias,
+        location: adjustLocationForCursor(location),
+        identifierChain: identifierChain
+      });
+    };
+
+    parser.addSubqueryAliasLocation = function (location, alias) {
+      parser.yy.locations.push({
+        type: 'alias',
+        source: 'subquery',
+        alias: alias,
+        location: adjustLocationForCursor(location)
+      });
+    };
+
     parser.addAsteriskLocation = function (location, identifierChain) {
     parser.addAsteriskLocation = function (location, identifierChain) {
       parser.yy.locations.push({
       parser.yy.locations.push({
         type: 'asterisk',
         type: 'asterisk',
@@ -1567,8 +1586,8 @@ var SqlParseSupport = (function () {
     'suggestDdlAndDmlKeywords', 'checkForSelectListKeywords', 'checkForKeywords', 'createWeightedKeywords', 'suggestKeywords', 'suggestColRefKeywords',
     'suggestDdlAndDmlKeywords', 'checkForSelectListKeywords', 'checkForKeywords', 'createWeightedKeywords', 'suggestKeywords', 'suggestColRefKeywords',
     'suggestTablesOrColumns', 'suggestFunctions', 'suggestAggregateFunctions', 'suggestAnalyticFunctions', 'suggestColumns', 'suggestGroupBys',
     'suggestTablesOrColumns', 'suggestFunctions', 'suggestAggregateFunctions', 'suggestAnalyticFunctions', 'suggestColumns', 'suggestGroupBys',
     'suggestOrderBys', 'suggestFilters', 'suggestKeyValues', 'suggestTables', 'addFunctionLocation', 'addStatementLocation', 'firstDefined',
     'suggestOrderBys', 'suggestFilters', 'suggestKeyValues', 'suggestTables', 'addFunctionLocation', 'addStatementLocation', 'firstDefined',
-    'addClauseLocation', 'addHdfsLocation', 'addDatabaseLocation', 'addTableLocation', 'addAsteriskLocation', 'addColumnLocation', 'addUnknownLocation',
-    'suggestDatabases', 'suggestHdfs', 'suggestValues', 'handleQuotedValueWithCursor'];
+    'addClauseLocation', 'addHdfsLocation', 'addDatabaseLocation', 'addTableAliasLocation', 'addSubqueryAliasLocation', 'addTableLocation',
+    'addAsteriskLocation', 'addColumnLocation', 'addUnknownLocation', 'suggestDatabases', 'suggestHdfs', 'suggestValues', 'handleQuotedValueWithCursor'];
 
 
   var SYNTAX_PARSER_NOOP = function () {};
   var SYNTAX_PARSER_NOOP = function () {};
 
 

+ 11 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js

@@ -1902,6 +1902,7 @@ case 1251:
      if ($$[$0-2].identifierChain) {
      if ($$[$0-2].identifierChain) {
        if ($$[$0]) {
        if ($$[$0]) {
          $$[$0-2].alias = $$[$0]
          $$[$0-2].alias = $$[$0]
+         parser.addTableAliasLocation(_$[$0], $$[$0], $$[$0-2].identifierChain);
        }
        }
        parser.addTablePrimary($$[$0-2]);
        parser.addTablePrimary($$[$0-2]);
      }
      }
@@ -1914,15 +1915,24 @@ case 1252:
      if ($$[$0]) {
      if ($$[$0]) {
        $$[$0-1].alias = $$[$0];
        $$[$0-1].alias = $$[$0];
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
+       parser.addSubqueryAliasLocation(_$[$0], $$[$0], $$[$0-1].identifierChain);
      } else {
      } else {
        this.$.suggestKeywords = [{ value: 'AS', weight: 1 }];
        this.$.suggestKeywords = [{ value: 'AS', weight: 1 }];
      }
      }
    
    
+break;
+case 1253:
+
+     if ($$[$0]) {
+       parser.addTableAliasLocation(_$[$0], $$[$0], $$[$0-2].identifierChain);
+     }
+   
 break;
 break;
 case 1254:
 case 1254:
 
 
      if ($$[$0]) {
      if ($$[$0]) {
        $$[$0-2].alias = $$[$0];
        $$[$0-2].alias = $$[$0];
+       parser.addTableAliasLocation(_$[$0], $$[$0], $$[$0-2].identifierChain);
      }
      }
      parser.addTablePrimary($$[$0-2]);
      parser.addTablePrimary($$[$0-2]);
    
    
@@ -1931,6 +1941,7 @@ case 1255:
 
 
      if ($$[$0]) {
      if ($$[$0]) {
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
        parser.addTablePrimary({ subQueryAlias: $$[$0] });
+       parser.addSubqueryAliasLocation(_$[$0], $$[$0]);
      }
      }
    
    
 break;
 break;