Эх сурвалжийг харах

HUE-6403 [autocomplete] Report complex locations as complex type and not column type

Johan Ahlen 8 жил өмнө
parent
commit
2d163b0

+ 3 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlParseSupport.js

@@ -377,6 +377,9 @@ var SqlParseSupport = (function () {
             parser.yy.locations.splice(i, 1);
           }
         }
+        if (location.type === 'column' && location.identifierChain && location.identifierChain.length > 1 && location.tables && location.tables.length > 0) {
+          location.type = 'complex';
+        }
       }
       if (parser.yy.locations.length > 0) {
         parser.yy.allLocations = parser.yy.allLocations.concat(parser.yy.locations);

+ 1 - 1
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_hive.js

@@ -53,7 +53,7 @@
           locations: [
             { type: 'statement', location: { 'first_line': 1, 'last_line': 1, 'first_column': 1, 'last_column': 23 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] },
-            { type: 'column', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23 }, identifierChain: [{ name: 'col' }, { name: 'field'}], tables: [{ identifierChain: [{ name: 'tbl' }] }] }
+            { type: 'complex', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23 }, identifierChain: [{ name: 'col' }, { name: 'field'}], tables: [{ identifierChain: [{ name: 'tbl' }] }] }
           ],
           lowerCase: false
         }

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

@@ -518,7 +518,7 @@
             { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 38 } },
             { 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: 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' }] }
           ]
         });
@@ -533,7 +533,7 @@
             { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 39 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 16 }, identifierChain: [{ name: 'some_tbl' }] },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 17, last_column: 20 }, identifierChain: [{ name: 'col' }], tables: [{ identifierChain: [{ name: 'some_tbl' }] }] },
-            { type: 'column', location: { first_line: 1, last_line: 1, first_column: 21, last_column: 25 }, identifierChain: [{ name: 'col' }, { name: 'cplx' }], tables: [{ identifierChain: [{ name: 'some_tbl' }] }] },
+            { type: 'complex', location: { first_line: 1, last_line: 1, first_column: 21, last_column: 25 }, identifierChain: [{ name: 'col' }, { name: 'cplx' }], tables: [{ identifierChain: [{ name: 'some_tbl' }] }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 31, last_column: 39 }, identifierChain: [{ name: 'some_tbl' }] }
           ]
         });

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

@@ -2895,8 +2895,8 @@
             expectedResult: {
               locations: [
                 { type: 'statement', location: { first_line: 1, last_line: 7, first_column: 1, last_column: 67 } },
-                { type: 'column', 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: 'column', 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: 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: 'table', location: { first_line: 5, last_line: 5, first_column: 3, last_column: 13 }, identifierChain: [{ name: 'testTable2' }]},
                 { 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' }]},