diff --git a/src/autocomplete/databases/yql/helpers.ts b/src/autocomplete/databases/yql/helpers.ts index 4d634fc9..c82aca4d 100644 --- a/src/autocomplete/databases/yql/helpers.ts +++ b/src/autocomplete/databases/yql/helpers.ts @@ -298,8 +298,12 @@ function getColumnsSuggestions({ function getSimpleTypesSuggestions({ anyRuleInList, + allRulesInList, }: GetParticularSuggestionProps): boolean | undefined { - return anyRuleInList(YQLParser.RULE_type_name_simple); + const simpleTypeInExpression = + allRulesInList([YQLParser.RULE_id_expr, YQLParser.RULE_select_stmt]) && + !anyRuleInList(YQLParser.RULE_table_ref); + return anyRuleInList(YQLParser.RULE_type_name_simple) || simpleTypeInExpression; } function getPragmasSuggestions({ diff --git a/src/autocomplete/databases/yql/tests/yq/select/group-by-clause.test.ts b/src/autocomplete/databases/yql/tests/yq/select/group-by-clause.test.ts index 2e142501..600e36b4 100644 --- a/src/autocomplete/databases/yql/tests/yq/select/group-by-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yq/select/group-by-clause.test.ts @@ -42,6 +42,7 @@ function getAfterGroupByCommonExpections(autocompleteResult: YqlAutocompleteResu expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestTableFunctions).toBeFalsy(); } diff --git a/src/autocomplete/databases/yql/tests/yq/select/join-clause.test.ts b/src/autocomplete/databases/yql/tests/yq/select/join-clause.test.ts index d60630b2..a5770e14 100644 --- a/src/autocomplete/databases/yql/tests/yq/select/join-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yq/select/join-clause.test.ts @@ -71,6 +71,7 @@ test('should suggest tables after JOIN', () => { expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeFalsy(); + expect(autocompleteResult.suggestSimpleTypes).toBeFalsy(); expect(autocompleteResult.suggestUdfs).toBeFalsy(); expect(autocompleteResult.suggestTableFunctions).toBeTruthy(); }); @@ -84,6 +85,7 @@ test('should suggest tables after JOIN between statements', () => { expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeFalsy(); + expect(autocompleteResult.suggestSimpleTypes).toBeFalsy(); expect(autocompleteResult.suggestUdfs).toBeFalsy(); expect(autocompleteResult.suggestTableFunctions).toBeTruthy(); }); diff --git a/src/autocomplete/databases/yql/tests/yq/select/order-by-clause.test.ts b/src/autocomplete/databases/yql/tests/yq/select/order-by-clause.test.ts index 2fe86b36..247d4325 100644 --- a/src/autocomplete/databases/yql/tests/yq/select/order-by-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yq/select/order-by-clause.test.ts @@ -36,6 +36,7 @@ function getAfterOrderByCommonExpections(autocompleteResult: YqlAutocompleteResu expect(autocompleteResult.suggestAggregateFunctions).toBeTruthy(); expect(autocompleteResult.suggestWindowFunctions).toBeTruthy(); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestTableFunctions).toBeFalsy(); expect(autocompleteResult.suggestKeywords).toEqual(afterOrderByKeywords); diff --git a/src/autocomplete/databases/yql/tests/yq/select/select.test.ts b/src/autocomplete/databases/yql/tests/yq/select/select.test.ts index 26e6e887..d97bd460 100644 --- a/src/autocomplete/databases/yql/tests/yq/select/select.test.ts +++ b/src/autocomplete/databases/yql/tests/yq/select/select.test.ts @@ -35,8 +35,9 @@ test('should suggest properly after SELECT', () => { {value: 'TAGGED'}, ]; expect(autocompleteResult.suggestKeywords).toEqual(keywordsSuggestion); - expect(autocompleteResult.suggestFunctions).toEqual(true); - expect(autocompleteResult.suggestUdfs).toEqual(true); + expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); + expect(autocompleteResult.suggestUdfs).toBeTruthy(); }); test('should suggest properly after FROM', () => { const autocompleteResult = parseYqQueryWithCursor('FROM |'); @@ -258,6 +259,7 @@ test('should suggest properly after HAVING', () => { ]; expect(autocompleteResult.suggestKeywords).toEqual(keywordsSuggestion); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestColumns).toBeTruthy(); }); @@ -293,6 +295,7 @@ test('should suggest properly after LIMIT', () => { ]; expect(autocompleteResult.suggestKeywords).toEqual(keywordsSuggestion); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); }); diff --git a/src/autocomplete/databases/yql/tests/yq/select/where-clause.test.ts b/src/autocomplete/databases/yql/tests/yq/select/where-clause.test.ts index 7be52ea2..a71c0b61 100644 --- a/src/autocomplete/databases/yql/tests/yq/select/where-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yq/select/where-clause.test.ts @@ -37,6 +37,7 @@ function getAfterWhereCommonExpections(autocompleteResult: YqlAutocompleteResult expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestTableFunctions).toBeFalsy(); expect(autocompleteResult.suggestKeywords).toEqual(AfterWhereKeywords); diff --git a/src/autocomplete/databases/yql/tests/yql/create/create-user.test.ts b/src/autocomplete/databases/yql/tests/yql/create/create-user.test.ts index 43f406e8..39b9e818 100644 --- a/src/autocomplete/databases/yql/tests/yql/create/create-user.test.ts +++ b/src/autocomplete/databases/yql/tests/yql/create/create-user.test.ts @@ -45,5 +45,6 @@ test('should suggest properly after PASSWORD', () => { ]; expect(autocompleteResult.suggestKeywords).toEqual(keywordsSuggestion); expect(autocompleteResult.suggestFunctions).toBeFalsy(); + expect(autocompleteResult.suggestSimpleTypes).toBeFalsy(); expect(autocompleteResult.suggestUdfs).toBeFalsy(); }); diff --git a/src/autocomplete/databases/yql/tests/yql/select/group-by-clause.test.ts b/src/autocomplete/databases/yql/tests/yql/select/group-by-clause.test.ts index 5a542c40..4d242bee 100644 --- a/src/autocomplete/databases/yql/tests/yql/select/group-by-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yql/select/group-by-clause.test.ts @@ -42,6 +42,7 @@ function getAfterGroupByCommonExpections(autocompleteResult: YqlAutocompleteResu expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestTableFunctions).toBeFalsy(); } diff --git a/src/autocomplete/databases/yql/tests/yql/select/join-clause.test.ts b/src/autocomplete/databases/yql/tests/yql/select/join-clause.test.ts index 6c17849d..015499bb 100644 --- a/src/autocomplete/databases/yql/tests/yql/select/join-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yql/select/join-clause.test.ts @@ -71,6 +71,7 @@ test('should suggest tables after JOIN', () => { expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeFalsy(); + expect(autocompleteResult.suggestSimpleTypes).toBeFalsy(); expect(autocompleteResult.suggestUdfs).toBeFalsy(); expect(autocompleteResult.suggestTableFunctions).toBeTruthy(); }); @@ -84,6 +85,7 @@ test('should suggest tables after JOIN between statements', () => { expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeFalsy(); + expect(autocompleteResult.suggestSimpleTypes).toBeFalsy(); expect(autocompleteResult.suggestUdfs).toBeFalsy(); expect(autocompleteResult.suggestTableFunctions).toBeTruthy(); }); diff --git a/src/autocomplete/databases/yql/tests/yql/select/order-by-clause.test.ts b/src/autocomplete/databases/yql/tests/yql/select/order-by-clause.test.ts index 9f075b4a..285a3642 100644 --- a/src/autocomplete/databases/yql/tests/yql/select/order-by-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yql/select/order-by-clause.test.ts @@ -36,6 +36,7 @@ function getAfterOrderByCommonExpections(autocompleteResult: YqlAutocompleteResu expect(autocompleteResult.suggestAggregateFunctions).toBeTruthy(); expect(autocompleteResult.suggestWindowFunctions).toBeTruthy(); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestTableFunctions).toBeFalsy(); expect(autocompleteResult.suggestKeywords).toEqual(afterOrderByKeywords); diff --git a/src/autocomplete/databases/yql/tests/yql/select/select.test.ts b/src/autocomplete/databases/yql/tests/yql/select/select.test.ts index ca312523..f67396cb 100644 --- a/src/autocomplete/databases/yql/tests/yql/select/select.test.ts +++ b/src/autocomplete/databases/yql/tests/yql/select/select.test.ts @@ -35,8 +35,9 @@ test('should suggest properly after SELECT', () => { {value: 'TAGGED'}, ]; expect(autocompleteResult.suggestKeywords).toEqual(keywordsSuggestion); - expect(autocompleteResult.suggestFunctions).toEqual(true); - expect(autocompleteResult.suggestUdfs).toEqual(true); + expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestUdfs).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); }); test('should suggest properly after FROM', () => { const autocompleteResult = parseYqlQueryWithCursor('FROM |'); @@ -258,6 +259,7 @@ test('should suggest properly after HAVING', () => { ]; expect(autocompleteResult.suggestKeywords).toEqual(keywordsSuggestion); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestColumns).toBeTruthy(); }); @@ -293,6 +295,7 @@ test('should suggest properly after LIMIT', () => { ]; expect(autocompleteResult.suggestKeywords).toEqual(keywordsSuggestion); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); }); diff --git a/src/autocomplete/databases/yql/tests/yql/select/where-clause.test.ts b/src/autocomplete/databases/yql/tests/yql/select/where-clause.test.ts index e3652fe6..7fc17a81 100644 --- a/src/autocomplete/databases/yql/tests/yql/select/where-clause.test.ts +++ b/src/autocomplete/databases/yql/tests/yql/select/where-clause.test.ts @@ -37,6 +37,7 @@ function getAfterWhereCommonExpections(autocompleteResult: YqlAutocompleteResult expect(autocompleteResult.suggestAggregateFunctions).toBeFalsy(); expect(autocompleteResult.suggestWindowFunctions).toBeFalsy(); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestTableFunctions).toBeFalsy(); expect(autocompleteResult.suggestKeywords).toEqual(AfterWhereKeywords); @@ -66,6 +67,7 @@ test('should suggest properly after WHERE expr', () => { expect(autocompleteResult.suggestAggregateFunctions).toBeTruthy(); expect(autocompleteResult.suggestWindowFunctions).toBeTruthy(); expect(autocompleteResult.suggestFunctions).toBeTruthy(); + expect(autocompleteResult.suggestSimpleTypes).toBeTruthy(); expect(autocompleteResult.suggestUdfs).toBeTruthy(); expect(autocompleteResult.suggestTableFunctions).toBeFalsy(); expect(autocompleteResult.suggestKeywords).toEqual(AfterWhereKeywords);