Sfoglia il codice sorgente

HUE-9429 [editor] Split out all the UDFs and make most of the statements pluggable via structure.json in the generic parser

Johan Ahlen 5 anni fa
parent
commit
eba122bd89
59 ha cambiato i file con 1434 aggiunte e 775 eliminazioni
  1. 57 19
      desktop/core/src/desktop/js/parse/jison/sql/calcite/structure.json
  2. 61 23
      desktop/core/src/desktop/js/parse/jison/sql/druid/structure.json
  3. 61 23
      desktop/core/src/desktop/js/parse/jison/sql/elasticsearch/structure.json
  4. 61 23
      desktop/core/src/desktop/js/parse/jison/sql/flink/structure.json
  5. 1 8
      desktop/core/src/desktop/js/parse/jison/sql/generic/alter/alter_common.jison
  6. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/alter/alter_table.jison
  7. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/alter/alter_view.jison
  8. 1 11
      desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_common.jison
  9. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_database.jison
  10. 4 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_role.jison
  11. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_table.jison
  12. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_view.jison
  13. 1 13
      desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_common.jison
  14. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_database.jison
  15. 4 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_role.jison
  16. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_table.jison
  17. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_view.jison
  18. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/insert/insert.jison
  19. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/select.jison
  20. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/set/set_all.jison
  21. 26 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/set/set_common.jison
  22. 0 12
      desktop/core/src/desktop/js/parse/jison/sql/generic/set/set_option.jison
  23. 0 583
      desktop/core/src/desktop/js/parse/jison/sql/generic/sql_udf.jison
  24. 61 23
      desktop/core/src/desktop/js/parse/jison/sql/generic/structure.json
  25. 8 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/truncate/truncate_table.jison
  26. 96 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/aggregate_common.jison
  27. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/avg.jison
  28. 75 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/count.jison
  29. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/max.jison
  30. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/min.jison
  31. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/stddev_pop.jison
  32. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/stddev_samp.jison
  33. 64 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/sum.jison
  34. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/var_pop.jison
  35. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/var_samp.jison
  36. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/variance.jison
  37. 66 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/analytic/analytic.jison
  38. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/array.jison
  39. 83 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/cast.jison
  40. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/if.jison
  41. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/map.jison
  42. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/truncate.jison
  43. 280 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/udf/udf_common.jison
  44. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/update/update_table.jison
  45. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/use/use.jison
  46. 52 14
      desktop/core/src/desktop/js/parse/jison/sql/ksql/structure.json
  47. 61 23
      desktop/core/src/desktop/js/parse/jison/sql/phoenix/structure.json
  48. 0 0
      desktop/core/src/desktop/js/parse/sql/druid/druidAutocompleteParser.js
  49. 0 0
      desktop/core/src/desktop/js/parse/sql/druid/druidSyntaxParser.js
  50. 0 0
      desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchAutocompleteParser.js
  51. 0 0
      desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchSyntaxParser.js
  52. 0 0
      desktop/core/src/desktop/js/parse/sql/flink/flinkAutocompleteParser.js
  53. 0 0
      desktop/core/src/desktop/js/parse/sql/flink/flinkSyntaxParser.js
  54. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericAutocompleteParser.js
  55. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericSyntaxParser.js
  56. 0 0
      desktop/core/src/desktop/js/parse/sql/ksql/ksqlAutocompleteParser.js
  57. 0 0
      desktop/core/src/desktop/js/parse/sql/ksql/ksqlSyntaxParser.js
  58. 0 0
      desktop/core/src/desktop/js/parse/sql/phoenix/phoenixAutocompleteParser.js
  59. 0 0
      desktop/core/src/desktop/js/parse/sql/phoenix/phoenixSyntaxParser.js

+ 57 - 19
desktop/core/src/desktop/js/parse/jison/sql/calcite/structure.json

@@ -2,54 +2,92 @@
   "lexer": "../generic/sql.jisonlex",
   "autocomplete": [
     "../generic/autocomplete_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_error.jison",
-    "../generic/sql_insert.jison",
+    "../generic/insert/insert.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
     "sql_main.jison",
-    "../generic/sql_set.jison",
     "sql_select_stream.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/sql_error.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/autocomplete_footer.jison"
   ],
   "syntax": [
     "../generic/syntax_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_insert.jison",
+    "../generic/insert/insert.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
     "sql_main.jison",
-    "../generic/sql_set.jison",
     "sql_select_stream.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/syntax_footer.jison"
   ]

+ 61 - 23
desktop/core/src/desktop/js/parse/jison/sql/druid/structure.json

@@ -2,24 +2,20 @@
   "lexer": "../generic/sql.jisonlex",
   "autocomplete": [
     "../generic/autocomplete_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_error.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -27,35 +23,55 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_error.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/autocomplete_footer.jison"
   ],
   "syntax": [
     "../generic/syntax_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -63,13 +79,35 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/syntax_footer.jison"
   ]

+ 61 - 23
desktop/core/src/desktop/js/parse/jison/sql/elasticsearch/structure.json

@@ -2,24 +2,20 @@
   "lexer": "../generic/sql.jisonlex",
   "autocomplete": [
     "../generic/autocomplete_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_error.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -27,35 +23,55 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_error.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/autocomplete_footer.jison"
   ],
   "syntax": [
     "../generic/syntax_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -63,13 +79,35 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/syntax_footer.jison"
   ]

+ 61 - 23
desktop/core/src/desktop/js/parse/jison/sql/flink/structure.json

@@ -2,24 +2,20 @@
   "lexer": "../generic/sql.jisonlex",
   "autocomplete": [
     "../generic/autocomplete_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_error.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -27,35 +23,55 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_error.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/autocomplete_footer.jison"
   ],
   "syntax": [
     "../generic/syntax_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -63,13 +79,35 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/syntax_footer.jison"
   ]

+ 1 - 8
desktop/core/src/desktop/js/parse/jison/sql/generic/alter/alter_statement.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/alter/alter_common.jison

@@ -22,15 +22,8 @@ DataDefinition_EDIT
  : AlterStatement_EDIT
  ;
 
-AlterStatement
- : AlterTable
- | AlterView
- ;
-
 AlterStatement_EDIT
- : AlterTable_EDIT
- | AlterView_EDIT
- | 'ALTER' 'CURSOR'
+ : 'ALTER' 'CURSOR'
    {
      parser.suggestKeywords(['TABLE', 'VIEW']);
    }

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/alter/alter_table.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+AlterStatement
+ : AlterTable
+ ;
+
+AlterStatement_EDIT
+ : AlterTable_EDIT
+ ;
+
 AlterTable
  : AlterTableLeftSide PartitionSpec
  ;

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/alter/alter_view.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+AlterStatement
+ : AlterView
+ ;
+
+AlterStatement_EDIT
+ : AlterView_EDIT
+ ;
+
 AlterView
  : AlterViewLeftSide 'AS' QuerySpecification
  ;

+ 1 - 11
desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_statement.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_common.jison

@@ -22,18 +22,8 @@ DataDefinition_EDIT
  : CreateStatement_EDIT
  ;
 
-CreateStatement
- : DatabaseDefinition
- | TableDefinition
- | ViewDefinition
- | RoleDefinition
- ;
-
 CreateStatement_EDIT
- : DatabaseDefinition_EDIT
- | TableDefinition_EDIT
- | ViewDefinition_EDIT
- | 'CREATE' 'CURSOR'
+ : 'CREATE' 'CURSOR'
    {
      parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
    }

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_database.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+CreateStatement
+ : DatabaseDefinition
+ ;
+
+CreateStatement_EDIT
+ : DatabaseDefinition_EDIT
+ ;
+
 DatabaseDefinition
  : 'CREATE' DatabaseOrSchema OptionalIfNotExists
  | 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals

+ 4 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_role.jison

@@ -14,6 +14,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+CreateStatement
+ : RoleDefinition
+ ;
+
 RoleDefinition
  : 'CREATE' 'ROLE' RegularIdentifier
  ;

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_table.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+CreateStatement
+ : TableDefinition
+ ;
+
+CreateStatement_EDIT
+ : TableDefinition_EDIT
+ ;
+
 TableDefinition
  : 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
  ;

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/create/create_view.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+CreateStatement
+ : ViewDefinition
+ ;
+
+CreateStatement_EDIT
+ : ViewDefinition_EDIT
+ ;
+
 ViewDefinition
  : 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
  ;

+ 1 - 13
desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_statement.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_common.jison

@@ -22,20 +22,8 @@ DataDefinition_EDIT
  : DropStatement_EDIT
  ;
 
-DropStatement
- : DropDatabaseStatement
- | DropRoleStatement
- | DropTableStatement
- | DropViewStatement
- | TruncateTableStatement
- ;
-
 DropStatement_EDIT
- : DropDatabaseStatement_EDIT
- | DropTableStatement_EDIT
- | DropViewStatement_EDIT
- | TruncateTableStatement_EDIT
- | 'DROP' 'CURSOR'
+ : 'DROP' 'CURSOR'
    {
      parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
    }

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_database.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+DropStatement
+ : DropDatabaseStatement
+ ;
+
+DropStatement_EDIT
+ : DropDatabaseStatement_EDIT
+ ;
+
 DropDatabaseStatement
  : 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
  ;

+ 4 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_role.jison

@@ -14,6 +14,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+DropStatement
+ : DropRoleStatement
+ ;
+
 DropRoleStatement
  : 'DROP' 'ROLE' RegularIdentifier
  ;

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_table.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+DropStatement
+ : DropTableStatement
+ ;
+
+DropStatement_EDIT
+ : DropTableStatement_EDIT
+ ;
+
 DropTableStatement
  : 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
    {

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/drop/drop_view.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+DropStatement
+ : DropViewStatement
+ ;
+
+DropStatement_EDIT
+ : DropViewStatement_EDIT
+ ;
+
 DropViewStatement
  : 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
    {

+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_insert.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/insert/insert.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/select/select_statement.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/select.jison


+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/set/set_all.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+SetSpecification
+ : 'SET' 'ALL'
+ ;

+ 26 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/set/set_common.jison

@@ -0,0 +1,26 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+DataDefinition
+ : SetSpecification
+ ;
+
+DataDefinition_EDIT
+ : 'SET' 'CURSOR'
+   {
+     parser.suggestSetOptions();
+   }
+ ;

+ 0 - 12
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_set.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/set/set_option.jison

@@ -14,20 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-DataDefinition
- : SetSpecification
- ;
-
-DataDefinition_EDIT
- : 'SET' 'CURSOR'
-   {
-     parser.suggestSetOptions();
-   }
- ;
-
 SetSpecification
  : 'SET' SetOption '=' SetValue
- | 'SET' 'ALL'
  ;
 
 SetOption

+ 0 - 583
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_udf.jison

@@ -1,583 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-NonParenthesizedValueExpressionPrimary
- : ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart
-   {
-     // We need to handle arbitrary UDFs here instead of inside UserDefinedFunction or there will be a conflict
-     // with columnReference for functions like: db.udf(foo)
-     var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
-     parser.addFunctionArgumentLocations(fn, $2.expressions, $1.chain);
-     if ($1.lastLoc && $1.lastLoc.location) {
-       $1.lastLoc.type = 'function';
-       $1.lastLoc.function = fn;
-       $1.lastLoc.location = {
-         first_line: $1.lastLoc.location.first_line,
-         last_line: $1.lastLoc.location.last_line,
-         first_column: $1.lastLoc.location.first_column,
-         last_column: $1.lastLoc.location.last_column - 1
-       }
-       if ($1.lastLoc !== $1.firstLoc) {
-          $1.firstLoc.type = 'database';
-       } else {
-         delete $1.lastLoc.identifierChain;
-       }
-     }
-     if ($2.expressions && $2.expressions.length) {
-       $$ = { function: fn, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
-     } else {
-       $$ = { function: fn, types: ['UDFREF'] }
-     }
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart
-  {
-    parser.addFunctionLocation(@1, $1);
-    if ($2.expressions && $2.expressions.length) {
-      $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
-    } else {
-      $$ = { function: $1, types: ['UDFREF'] }
-    }
-  }
- | UserDefinedFunction
- ;
-
-NonParenthesizedValueExpressionPrimary_EDIT
- : ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart_EDIT
-   {
-     var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
-     parser.addFunctionArgumentLocations(fn, $2.expressions, $1.chain);
-     $1.lastLoc.type = 'function';
-     $1.lastLoc.function = fn;
-     $1.lastLoc.location = {
-       first_line: $1.lastLoc.location.first_line,
-       last_line: $1.lastLoc.location.last_line,
-       first_column: $1.lastLoc.location.first_column,
-       last_column: $1.lastLoc.location.last_column - 1
-     }
-     if ($1.lastLoc !== $1.firstLoc) {
-        $1.firstLoc.type = 'database';
-     } else {
-       delete $1.lastLoc.identifierChain;
-     }
-     if ($2.activePosition) {
-       parser.applyArgumentTypesToSuggestions(fn, $2.activePosition);
-     }
-     $$ = { function: fn, types: ['UDFREF'] };
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
-   {
-     parser.addFunctionLocation(@1, $1);
-     parser.addFunctionArgumentLocations($1, $2.expressions);
-     if ($2.activePosition) {
-       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | UserDefinedFunction_EDIT
- ;
-
-UserDefinedFunction
- : AggregateFunction OptionalOverClause
-   {
-     if (!$2) {
-       $1.suggestKeywords = ['OVER'];
-     }
-   }
- | AnalyticFunction OverClause
- | CastFunction
- ;
-
-UserDefinedFunction_EDIT
- : AggregateFunction_EDIT
- | AggregateFunction OptionalOverClause_EDIT
- | AnalyticFunction_EDIT
- | AnalyticFunction_EDIT OverClause
- | AnalyticFunction 'CURSOR'
-   {
-     parser.suggestKeywords(['OVER']);
-   }
- | AnalyticFunction OverClause_EDIT
- | CastFunction_EDIT
- ;
-
-ArbitraryFunction
- : RegularIdentifier ArbitraryFunctionRightPart
-   {
-     parser.addFunctionLocation(@1, $1);
-     parser.addFunctionArgumentLocations($1, $2.expressions);
-     if ($2.expressions && $2.expressions.length) {
-       $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
-     } else {
-       $$ = { function: $1, types: ['UDFREF'] }
-     }
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart
-   {
-     parser.addFunctionLocation(@1, $1);
-     parser.addFunctionArgumentLocations($1, $2.expressions);
-     if ($2.expressions && $2.expressions.length) {
-       $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
-     } else {
-       $$ = { function: $1, types: ['UDFREF'] }
-     }
-   }
- ;
-
-ArbitraryFunction_EDIT
- : RegularIdentifier ArbitraryFunctionRightPart_EDIT
-   {
-     parser.addFunctionLocation(@1, $1);
-     parser.addFunctionArgumentLocations($1, $2.expressions);
-     if ($2.activePosition) {
-       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
-   {
-     parser.addFunctionLocation(@1, $1);
-     parser.addFunctionArgumentLocations($1, $2.expressions);
-     if ($2.activePosition) {
-       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-ArbitraryFunctionName
- : 'ARRAY'
- | 'IF'
- | 'MAP'
- | 'TRUNCATE'
- ;
-
-ArbitraryFunctionRightPart
- : '(' ')'
- | '(' UdfArgumentList ')'  -> $2
- ;
-
-ArbitraryFunctionRightPart_EDIT
- : '(' AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = {
-       activePosition: 1,
-       expressions: [{ expression: { text: '' }, location: @2 }]
-     }
-   }
- | '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($2.expressions[$2.expressions.length - 1].expression);
-     $$ = $1;
-   }
- | '(' UdfArgumentList_EDIT RightParenthesisOrError      -> $2
- ;
-
-UdfArgumentList
- : ValueExpression
-   {
-     $$ = {
-       activePosition: 1,
-       expressions: [{ expression: $1, location: @1 }]
-     }
-   }
- | UdfArgumentList ',' ValueExpression
-   {
-     $$ = {
-       activePosition: $1.activePosition + 1,
-       expressions: $1.expressions.concat([{ expression: $3, location: @3 }])
-     }
-   }
- ;
-
-UdfArgumentList_EDIT
- : ValueExpression_EDIT
-   {
-     $$ = {
-       activePosition: 1,
-       expressions: [{ expression: $1, location: @1 }]
-     }
-   }
- | UdfArgumentList ',' ValueExpression_EDIT
-   {
-     $$ = {
-       activePosition: $1.activePosition + 1,
-       expressions: $1.expressions.concat([{ expression: $3, location: @3 }])
-     }
-   }
- | ValueExpression_EDIT ',' UdfArgumentList
-   {
-     $$ = {
-       activePosition: 1,
-       expressions: [{ expression: $1, location: @1 }].concat($3.expressions)
-     }
-   }
- | UdfArgumentList ',' ValueExpression_EDIT ',' UdfArgumentList
-   {
-     $$ = {
-       activePosition: $1.activePosition + 1,
-       expressions: $1.expressions.concat([{ expression: $3, location: @3 }]).concat($5.expressions)
-     }
-   }
- | UdfArgumentList ',' AnyCursor
-   {
-     parser.valueExpressionSuggest();
-     $$ = {
-       activePosition: $1.activePosition + 1,
-       expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }])
-     }
-   }
- | UdfArgumentList ',' AnyCursor ',' UdfArgumentList
-   {
-     parser.valueExpressionSuggest();
-     $$ = {
-       activePosition: $1.activePosition + 1,
-       expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }]).concat($5.expressions)
-     }
-   }
- | UdfArgumentList 'CURSOR' ',' UdfArgumentList
-   {
-     parser.suggestValueExpressionKeywords($1.expressions[$1.expressions.length - 1].expression);
-     $$ = {
-       activePosition: $1.activePosition,
-       expressions: $1.expressions.concat($4.expressions)
-     }
-   }
- | AnyCursor ',' UdfArgumentList
-   {
-     parser.valueExpressionSuggest();
-     $$ = {
-       cursorAtStart : true,
-       activePosition: 1,
-       expressions: [{ expression: { text: '' }, location: @1 }].concat($3.expressions)
-     };
-   }
- | AnyCursor ','
-   {
-     parser.valueExpressionSuggest();
-     $$ = {
-       cursorAtStart : true,
-       activePosition: 1,
-       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }]
-     };
-   }
- | ',' AnyCursor
-   {
-     parser.valueExpressionSuggest();
-     $$ = {
-       activePosition: 2,
-       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }]
-     };
-   }
- | ',' AnyCursor ',' UdfArgumentList
-   {
-     parser.valueExpressionSuggest();
-     $$ = {
-       activePosition: 2,
-       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }].concat($4.expressions)
-     };
-   }
- ;
-
-AggregateFunction
- : CountFunction
- | SumFunction
- | OtherAggregateFunction
- ;
-
-AggregateFunction_EDIT
- : CountFunction_EDIT
- | SumFunction_EDIT
- | OtherAggregateFunction_EDIT
- ;
-
-AnalyticFunction
- : 'ANALYTIC' '(' ')'
-  {
-    $$ = { function: $1, types: ['UDFREF'] }
-  }
- | 'ANALYTIC' '(' UdfArgumentList ')'
-   {
-     parser.addFunctionArgumentLocations($1, $3.expressions);
-     $$ = {
-       function: $1,
-       expression: $3.expressions[$3.expressions.length - 1].expression,
-       types: ['UDFREF']
-     }
-   }
- ;
-
-AnalyticFunction_EDIT
- : 'ANALYTIC' '(' AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     parser.applyArgumentTypesToSuggestions($1, 1);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'ANALYTIC' '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
-   {
-     parser.addFunctionArgumentLocations($1, $3.expressions);
-     parser.suggestValueExpressionKeywords($3.expressions[$3.expressions.length - 1].expression);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'ANALYTIC' '(' UdfArgumentList_EDIT RightParenthesisOrError
-   {
-     parser.addFunctionArgumentLocations($1, $3.expressions);
-     parser.applyArgumentTypesToSuggestions($1, $3.activePosition);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-OptionalOverClause
- :
- | OverClause
- ;
-
-OptionalOverClause_EDIT
- : OverClause_EDIT
- ;
-
-OverClause
- : 'OVER' RegularOrBacktickedIdentifier
- | 'OVER' WindowExpression
- ;
-
-OverClause_EDIT
- : 'OVER' WindowExpression_EDIT
- ;
-
-CastFunction
- : 'CAST' '(' ValueExpression 'AS' PrimitiveType ')'
-   {
-     var expression = $3;
-     parser.extractExpressionText(expression, $3, $4, $5);
-     parser.addFunctionArgumentLocations($1, [{
-       expression: expression,
-       location: {
-         first_line: @3.first_line,
-         last_line: @5.last_line,
-         first_column: @3.first_column,
-         last_column: @5.last_column
-       }
-     }]);
-     $$ = { types: [ $5.toUpperCase() ] }
-   }
- | 'CAST' '(' ')'                                      -> { types: [ 'T' ] }
- ;
-
-CastFunction_EDIT
- : 'CAST' '(' AnyCursor 'AS' PrimitiveType RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { types: [ $5.toUpperCase() ] };
-   }
- | 'CAST' '(' AnyCursor 'AS' RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' ValueExpression_EDIT 'AS' PrimitiveType RightParenthesisOrError  -> { types: [ $5.toUpperCase() ] }
- | 'CAST' '(' ValueExpression_EDIT 'AS' RightParenthesisOrError                -> { types: [ 'T' ] }
- | 'CAST' '(' ValueExpression_EDIT RightParenthesisOrError                     -> { types: [ 'T' ] }
- | 'CAST' '(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($3, [{ value: 'AS', weight: 2 }]);
-     $$ =  { types: [ $5.toUpperCase() ] };
-   }
- | 'CAST' '(' ValueExpression 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($3, [{ value: 'AS', weight: 2 }]);
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' ValueExpression 'AS' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords(parser.getTypeKeywords());
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' 'AS' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords(parser.getTypeKeywords());
-     $$ = { types: [ 'T' ] };
-   }
- ;
-
-CountFunction
- : 'COUNT' '(' '*' ')'
-   {
-     parser.addFunctionArgumentLocations($1, [{
-       expression: { text: $3 },
-       location: @3
-     }]);
-     $$ = { function: $1, types: ['UDFREF'] }
-   }
- | 'COUNT' '(' ')'
-   {
-     $$ = { function: $1, types: ['UDFREF'] }
-   }
- | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList ')'
-   {
-     parser.addFunctionArgumentLocations($1, $4.expressions);
-     $$ = { function: $1, types: ['UDFREF'] }
-   }
- ;
-
-CountFunction_EDIT
- : 'COUNT' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     var keywords = parser.getSelectListKeywords();
-     if (!$3) {
-       keywords.push('DISTINCT');
-       if (parser.yy.result.suggestKeywords) {
-         keywords = parser.yy.result.suggestKeywords.concat(keywords);
-       }
-     }
-     parser.suggestKeywords(keywords);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
-   {
-     if ($4.cursorAtStart) {
-       var keywords = parser.getSelectListKeywords();
-       if (!$3) {
-         keywords.push('DISTINCT');
-       }
-       parser.suggestKeywords(keywords);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-OtherAggregateFunction
- : OtherAggregateFunction_Type '(' OptionalAllOrDistinct ')'
-   {
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList ')'
-   {
-     parser.addFunctionArgumentLocations($1, $4.expressions);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-OtherAggregateFunction_EDIT
- : OtherAggregateFunction_Type '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     var keywords = parser.getSelectListKeywords(true);
-     if (!$3) {
-       if ($1.toLowerCase() === 'group_concat') {
-         keywords.push('ALL');
-       } else {
-         keywords.push('DISTINCT');
-       }
-     }
-     if (parser.yy.result.suggestKeywords) {
-       keywords = parser.yy.result.suggestKeywords.concat(keywords);
-     }
-     parser.suggestKeywords(keywords);
-     parser.applyArgumentTypesToSuggestions($1, 1);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
-   {
-     if ($4.cursorAtStart) {
-       var keywords = parser.getSelectListKeywords(true);
-       if (!$3) {
-         if ($1.toLowerCase() === 'group_concat') {
-           keywords.push('ALL');
-         } else {
-           keywords.push('DISTINCT');
-         }
-       }
-       if (parser.yy.result.suggestKeywords) {
-         keywords = parser.yy.result.suggestKeywords.concat(keywords);
-       }
-       parser.suggestKeywords(keywords);
-     }
-     if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
-       parser.applyArgumentTypesToSuggestions($1, $4.activePosition);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-OtherAggregateFunction_Type
- : 'AVG'
- | 'MAX'
- | 'MIN'
- | 'STDDEV_POP'
- | 'STDDEV_SAMP'
- | 'VAR_POP'
- | 'VAR_SAMP'
- | 'VARIANCE'
- ;
-
-SumFunction
- : 'SUM' '(' OptionalAllOrDistinct ValueExpression ')'
-   {
-     parser.addFunctionArgumentLocations($1, $4.expressions);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'SUM' '(' ')'
-   {
-     $$ = { function: $1, types: ['UDFREF'] }
-   }
- ;
-
-SumFunction_EDIT
- : 'SUM' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     parser.applyArgumentTypesToSuggestions($1, 1);
-     var keywords = parser.getSelectListKeywords(true);
-     if (!$3) {
-       keywords.push('DISTINCT');
-     }
-     if (parser.yy.result.suggestKeywords) {
-       keywords = parser.yy.result.suggestKeywords.concat(keywords);
-     }
-     parser.suggestKeywords(keywords);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'SUM' '(' OptionalAllOrDistinct ValueExpression 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($4);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'SUM' '(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
-   {
-     if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
-       parser.applyArgumentTypesToSuggestions($1, 1);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;

+ 61 - 23
desktop/core/src/desktop/js/parse/jison/sql/generic/structure.json

@@ -2,24 +2,20 @@
   "lexer": "sql.jisonlex",
   "autocomplete": [
     "autocomplete_header.jison",
-    "alter/alter_statement.jison",
+    "alter/alter_common.jison",
     "alter/alter_table.jison",
     "alter/alter_view.jison",
-    "create/create_statement.jison",
+    "create/create_common.jison",
     "create/create_database.jison",
     "create/create_role.jison",
     "create/create_table.jison",
     "create/create_view.jison",
-    "drop/drop_statement.jison",
+    "drop/drop_common.jison",
     "drop/drop_database.jison",
     "drop/drop_role.jison",
     "drop/drop_table.jison",
     "drop/drop_view.jison",
-    "drop/truncate_table.jison",
-    "sql_error.jison",
-    "sql_insert.jison",
-    "sql_main.jison",
-    "select/select_statement.jison",
+    "insert/insert.jison",
     "select/cte_select_statement.jison",
     "select/from_clause.jison",
     "select/group_by_clause.jison",
@@ -27,35 +23,55 @@
     "select/joins.jison",
     "select/limit_clause.jison",
     "select/order_by_clause.jison",
+    "select/select.jison",
     "select/select_conditions.jison",
     "select/union_clause.jison",
     "select/where_clause.jison",
-    "sql_set.jison",
-    "sql_udf.jison",
-    "sql_update.jison",
-    "sql_use.jison",
+    "set/set_common.jison",
+    "set/set_all.jison",
+    "set/set_option.jison",
+    "truncate/truncate_table.jison",
+    "udf/aggregate/aggregate_common.jison",
+    "udf/aggregate/avg.jison",
+    "udf/aggregate/count.jison",
+    "udf/aggregate/max.jison",
+    "udf/aggregate/min.jison",
+    "udf/aggregate/stddev_pop.jison",
+    "udf/aggregate/stddev_samp.jison",
+    "udf/aggregate/sum.jison",
+    "udf/aggregate/var_pop.jison",
+    "udf/aggregate/var_samp.jison",
+    "udf/aggregate/variance.jison",
+    "udf/analytic/analytic.jison",
+    "udf/function/array.jison",
+    "udf/function/cast.jison",
+    "udf/function/if.jison",
+    "udf/function/map.jison",
+    "udf/function/truncate.jison",
+    "udf/udf_common.jison",
+    "update/update_table.jison",
+    "use/use.jison",
+    "sql_error.jison",
+    "sql_main.jison",
     "sql_valueExpression.jison",
     "autocomplete_footer.jison"
   ],
   "syntax": [
     "syntax_header.jison",
-    "alter/alter_statement.jison",
+    "alter/alter_common.jison",
     "alter/alter_table.jison",
     "alter/alter_view.jison",
-    "create/create_statement.jison",
+    "create/create_common.jison",
     "create/create_database.jison",
     "create/create_role.jison",
     "create/create_table.jison",
     "create/create_view.jison",
-    "drop/drop_statement.jison",
+    "drop/drop_common.jison",
     "drop/drop_database.jison",
     "drop/drop_role.jison",
     "drop/drop_table.jison",
     "drop/drop_view.jison",
-    "drop/truncate_table.jison",
-    "sql_insert.jison",
-    "sql_main.jison",
-    "select/select_statement.jison",
+    "insert/insert.jison",
     "select/cte_select_statement.jison",
     "select/from_clause.jison",
     "select/group_by_clause.jison",
@@ -63,13 +79,35 @@
     "select/joins.jison",
     "select/limit_clause.jison",
     "select/order_by_clause.jison",
+    "select/select.jison",
     "select/select_conditions.jison",
     "select/union_clause.jison",
     "select/where_clause.jison",
-    "sql_set.jison",
-    "sql_udf.jison",
-    "sql_update.jison",
-    "sql_use.jison",
+    "set/set_common.jison",
+    "set/set_all.jison",
+    "set/set_option.jison",
+    "truncate/truncate_table.jison",
+    "udf/aggregate/aggregate_common.jison",
+    "udf/aggregate/avg.jison",
+    "udf/aggregate/count.jison",
+    "udf/aggregate/max.jison",
+    "udf/aggregate/min.jison",
+    "udf/aggregate/stddev_pop.jison",
+    "udf/aggregate/stddev_samp.jison",
+    "udf/aggregate/sum.jison",
+    "udf/aggregate/var_pop.jison",
+    "udf/aggregate/var_samp.jison",
+    "udf/aggregate/variance.jison",
+    "udf/analytic/analytic.jison",
+    "udf/function/array.jison",
+    "udf/function/cast.jison",
+    "udf/function/if.jison",
+    "udf/function/map.jison",
+    "udf/function/truncate.jison",
+    "udf/udf_common.jison",
+    "update/update_table.jison",
+    "use/use.jison",
+    "sql_main.jison",
     "sql_valueExpression.jison",
     "syntax_footer.jison"
   ]

+ 8 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/drop/truncate_table.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/truncate/truncate_table.jison

@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+DataDefinition
+ : TruncateTableStatement
+ ;
+
+DataDefinition_EDIT
+ : TruncateTableStatement_EDIT
+ ;
+
 TruncateTableStatement
  : 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
    {

+ 96 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/aggregate_common.jison

@@ -0,0 +1,96 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+UserDefinedFunction
+ : AggregateFunction OptionalOverClause
+   {
+     if (!$2) {
+       $1.suggestKeywords = ['OVER'];
+     }
+   }
+ ;
+
+UserDefinedFunction_EDIT
+ : AggregateFunction_EDIT
+ | AggregateFunction OptionalOverClause_EDIT
+ ;
+
+AggregateFunction
+ : OtherAggregateFunction
+ ;
+
+AggregateFunction_EDIT
+ : OtherAggregateFunction_EDIT
+ ;
+
+OtherAggregateFunction
+ : OtherAggregateFunction_Type '(' OptionalAllOrDistinct ')'
+   {
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList ')'
+   {
+     parser.addFunctionArgumentLocations($1, $4.expressions);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ ;
+
+OtherAggregateFunction_EDIT
+ : OtherAggregateFunction_Type '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     var keywords = parser.getSelectListKeywords(true);
+     if (!$3) {
+       if ($1.toLowerCase() === 'group_concat') {
+         keywords.push('ALL');
+       } else {
+         keywords.push('DISTINCT');
+       }
+     }
+     if (parser.yy.result.suggestKeywords) {
+       keywords = parser.yy.result.suggestKeywords.concat(keywords);
+     }
+     parser.suggestKeywords(keywords);
+     parser.applyArgumentTypesToSuggestions($1, 1);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
+   {
+     if ($4.cursorAtStart) {
+       var keywords = parser.getSelectListKeywords(true);
+       if (!$3) {
+         if ($1.toLowerCase() === 'group_concat') {
+           keywords.push('ALL');
+         } else {
+           keywords.push('DISTINCT');
+         }
+       }
+       if (parser.yy.result.suggestKeywords) {
+         keywords = parser.yy.result.suggestKeywords.concat(keywords);
+       }
+       parser.suggestKeywords(keywords);
+     }
+     if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
+       parser.applyArgumentTypesToSuggestions($1, $4.activePosition);
+     }
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/avg.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'AVG'
+ ;

+ 75 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/count.jison

@@ -0,0 +1,75 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+AggregateFunction
+ : CountFunction
+ ;
+
+AggregateFunction_EDIT
+ : CountFunction_EDIT
+ ;
+
+CountFunction
+ : 'COUNT' '(' '*' ')'
+   {
+     parser.addFunctionArgumentLocations($1, [{
+       expression: { text: $3 },
+       location: @3
+     }]);
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
+ | 'COUNT' '(' ')'
+   {
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList ')'
+   {
+     parser.addFunctionArgumentLocations($1, $4.expressions);
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
+ ;
+
+CountFunction_EDIT
+ : 'COUNT' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     var keywords = parser.getSelectListKeywords();
+     if (!$3) {
+       keywords.push('DISTINCT');
+       if (parser.yy.result.suggestKeywords) {
+         keywords = parser.yy.result.suggestKeywords.concat(keywords);
+       }
+     }
+     parser.suggestKeywords(keywords);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
+   {
+     if ($4.cursorAtStart) {
+       var keywords = parser.getSelectListKeywords();
+       if (!$3) {
+         keywords.push('DISTINCT');
+       }
+       parser.suggestKeywords(keywords);
+     }
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/max.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'MAX'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/min.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'MIN'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/stddev_pop.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'STDDEV_POP'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/stddev_samp.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'STDDEV_SAMP'
+ ;

+ 64 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/sum.jison

@@ -0,0 +1,64 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+AggregateFunction
+ : SumFunction
+ ;
+
+AggregateFunction_EDIT
+ : SumFunction_EDIT
+ ;
+
+SumFunction
+ : 'SUM' '(' OptionalAllOrDistinct ValueExpression ')'
+   {
+     parser.addFunctionArgumentLocations($1, $4.expressions);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'SUM' '(' ')'
+   {
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
+ ;
+
+SumFunction_EDIT
+ : 'SUM' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     parser.applyArgumentTypesToSuggestions($1, 1);
+     var keywords = parser.getSelectListKeywords(true);
+     if (!$3) {
+       keywords.push('DISTINCT');
+     }
+     if (parser.yy.result.suggestKeywords) {
+       keywords = parser.yy.result.suggestKeywords.concat(keywords);
+     }
+     parser.suggestKeywords(keywords);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'SUM' '(' OptionalAllOrDistinct ValueExpression 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestValueExpressionKeywords($4);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'SUM' '(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
+   {
+     if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
+       parser.applyArgumentTypesToSuggestions($1, 1);
+     }
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/var_pop.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'VAR_POP'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/var_samp.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'VAR_SAMP'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/aggregate/variance.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'VARIANCE'
+ ;

+ 66 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/analytic/analytic.jison

@@ -0,0 +1,66 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+UserDefinedFunction
+ : AnalyticFunction OverClause
+ ;
+
+UserDefinedFunction_EDIT
+ : AnalyticFunction_EDIT
+ | AnalyticFunction_EDIT OverClause
+ | AnalyticFunction 'CURSOR'
+   {
+     parser.suggestKeywords(['OVER']);
+   }
+ | AnalyticFunction OverClause_EDIT
+ ;
+
+AnalyticFunction
+ : 'ANALYTIC' '(' ')'
+  {
+    $$ = { function: $1, types: ['UDFREF'] }
+  }
+ | 'ANALYTIC' '(' UdfArgumentList ')'
+   {
+     parser.addFunctionArgumentLocations($1, $3.expressions);
+     $$ = {
+       function: $1,
+       expression: $3.expressions[$3.expressions.length - 1].expression,
+       types: ['UDFREF']
+     }
+   }
+ ;
+
+AnalyticFunction_EDIT
+ : 'ANALYTIC' '(' AnyCursor RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     parser.applyArgumentTypesToSuggestions($1, 1);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'ANALYTIC' '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
+   {
+     parser.addFunctionArgumentLocations($1, $3.expressions);
+     parser.suggestValueExpressionKeywords($3.expressions[$3.expressions.length - 1].expression);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'ANALYTIC' '(' UdfArgumentList_EDIT RightParenthesisOrError
+   {
+     parser.addFunctionArgumentLocations($1, $3.expressions);
+     parser.applyArgumentTypesToSuggestions($1, $3.activePosition);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/array.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+ArbitraryFunctionName
+ : 'ARRAY'
+ ;

+ 83 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/cast.jison

@@ -0,0 +1,83 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+UserDefinedFunction
+ : CastFunction
+ ;
+
+UserDefinedFunction_EDIT
+ : CastFunction_EDIT
+ ;
+
+CastFunction
+ : 'CAST' '(' ValueExpression 'AS' PrimitiveType ')'
+   {
+     var expression = $3;
+     parser.extractExpressionText(expression, $3, $4, $5);
+     parser.addFunctionArgumentLocations($1, [{
+       expression: expression,
+       location: {
+         first_line: @3.first_line,
+         last_line: @5.last_line,
+         first_column: @3.first_column,
+         last_column: @5.last_column
+       }
+     }]);
+     $$ = { types: [ $5.toUpperCase() ] }
+   }
+ | 'CAST' '(' ')'                                      -> { types: [ 'T' ] }
+ ;
+
+CastFunction_EDIT
+ : 'CAST' '(' AnyCursor 'AS' PrimitiveType RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     $$ = { types: [ $5.toUpperCase() ] };
+   }
+ | 'CAST' '(' AnyCursor 'AS' RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     $$ = { types: [ 'T' ] };
+   }
+ | 'CAST' '(' AnyCursor RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     $$ = { types: [ 'T' ] };
+   }
+ | 'CAST' '(' ValueExpression_EDIT 'AS' PrimitiveType RightParenthesisOrError  -> { types: [ $5.toUpperCase() ] }
+ | 'CAST' '(' ValueExpression_EDIT 'AS' RightParenthesisOrError                -> { types: [ 'T' ] }
+ | 'CAST' '(' ValueExpression_EDIT RightParenthesisOrError                     -> { types: [ 'T' ] }
+ | 'CAST' '(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
+   {
+     parser.suggestValueExpressionKeywords($3, [{ value: 'AS', weight: 2 }]);
+     $$ =  { types: [ $5.toUpperCase() ] };
+   }
+ | 'CAST' '(' ValueExpression 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestValueExpressionKeywords($3, [{ value: 'AS', weight: 2 }]);
+     $$ = { types: [ 'T' ] };
+   }
+ | 'CAST' '(' ValueExpression 'AS' 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestKeywords(parser.getTypeKeywords());
+     $$ = { types: [ 'T' ] };
+   }
+ | 'CAST' '(' 'AS' 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestKeywords(parser.getTypeKeywords());
+     $$ = { types: [ 'T' ] };
+   }
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/if.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+ArbitraryFunctionName
+ : 'IF'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/map.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+ArbitraryFunctionName
+ : 'MAP'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/function/truncate.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+ArbitraryFunctionName
+ : 'TRUNCATE'
+ ;

+ 280 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/udf/udf_common.jison

@@ -0,0 +1,280 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+NonParenthesizedValueExpressionPrimary
+ : ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart
+   {
+     // We need to handle arbitrary UDFs here instead of inside UserDefinedFunction or there will be a conflict
+     // with columnReference for functions like: db.udf(foo)
+     var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
+     parser.addFunctionArgumentLocations(fn, $2.expressions, $1.chain);
+     if ($1.lastLoc && $1.lastLoc.location) {
+       $1.lastLoc.type = 'function';
+       $1.lastLoc.function = fn;
+       $1.lastLoc.location = {
+         first_line: $1.lastLoc.location.first_line,
+         last_line: $1.lastLoc.location.last_line,
+         first_column: $1.lastLoc.location.first_column,
+         last_column: $1.lastLoc.location.last_column - 1
+       }
+       if ($1.lastLoc !== $1.firstLoc) {
+          $1.firstLoc.type = 'database';
+       } else {
+         delete $1.lastLoc.identifierChain;
+       }
+     }
+     if ($2.expressions && $2.expressions.length) {
+       $$ = { function: fn, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
+     } else {
+       $$ = { function: fn, types: ['UDFREF'] }
+     }
+   }
+ | ArbitraryFunctionName ArbitraryFunctionRightPart
+  {
+    parser.addFunctionLocation(@1, $1);
+    if ($2.expressions && $2.expressions.length) {
+      $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
+    } else {
+      $$ = { function: $1, types: ['UDFREF'] }
+    }
+  }
+ | UserDefinedFunction
+ ;
+
+NonParenthesizedValueExpressionPrimary_EDIT
+ : ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart_EDIT
+   {
+     var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
+     parser.addFunctionArgumentLocations(fn, $2.expressions, $1.chain);
+     $1.lastLoc.type = 'function';
+     $1.lastLoc.function = fn;
+     $1.lastLoc.location = {
+       first_line: $1.lastLoc.location.first_line,
+       last_line: $1.lastLoc.location.last_line,
+       first_column: $1.lastLoc.location.first_column,
+       last_column: $1.lastLoc.location.last_column - 1
+     }
+     if ($1.lastLoc !== $1.firstLoc) {
+        $1.firstLoc.type = 'database';
+     } else {
+       delete $1.lastLoc.identifierChain;
+     }
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions(fn, $2.activePosition);
+     }
+     $$ = { function: fn, types: ['UDFREF'] };
+   }
+ | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
+   {
+     parser.addFunctionLocation(@1, $1);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
+     }
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | UserDefinedFunction_EDIT
+ ;
+
+ArbitraryFunction
+ : RegularIdentifier ArbitraryFunctionRightPart
+   {
+     parser.addFunctionLocation(@1, $1);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.expressions && $2.expressions.length) {
+       $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
+     } else {
+       $$ = { function: $1, types: ['UDFREF'] }
+     }
+   }
+ | ArbitraryFunctionName ArbitraryFunctionRightPart
+   {
+     parser.addFunctionLocation(@1, $1);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.expressions && $2.expressions.length) {
+       $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
+     } else {
+       $$ = { function: $1, types: ['UDFREF'] }
+     }
+   }
+ ;
+
+ArbitraryFunction_EDIT
+ : RegularIdentifier ArbitraryFunctionRightPart_EDIT
+   {
+     parser.addFunctionLocation(@1, $1);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
+     }
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
+   {
+     parser.addFunctionLocation(@1, $1);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
+     }
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ ;
+
+ArbitraryFunctionRightPart
+ : '(' ')'
+ | '(' UdfArgumentList ')'  -> $2
+ ;
+
+ArbitraryFunctionRightPart_EDIT
+ : '(' AnyCursor RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: { text: '' }, location: @2 }]
+     }
+   }
+ | '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestValueExpressionKeywords($2.expressions[$2.expressions.length - 1].expression);
+     $$ = $1;
+   }
+ | '(' UdfArgumentList_EDIT RightParenthesisOrError      -> $2
+ ;
+
+UdfArgumentList
+ : ValueExpression
+   {
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: $1, location: @1 }]
+     }
+   }
+ | UdfArgumentList ',' ValueExpression
+   {
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: $3, location: @3 }])
+     }
+   }
+ ;
+
+UdfArgumentList_EDIT
+ : ValueExpression_EDIT
+   {
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: $1, location: @1 }]
+     }
+   }
+ | UdfArgumentList ',' ValueExpression_EDIT
+   {
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: $3, location: @3 }])
+     }
+   }
+ | ValueExpression_EDIT ',' UdfArgumentList
+   {
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: $1, location: @1 }].concat($3.expressions)
+     }
+   }
+ | UdfArgumentList ',' ValueExpression_EDIT ',' UdfArgumentList
+   {
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: $3, location: @3 }]).concat($5.expressions)
+     }
+   }
+ | UdfArgumentList ',' AnyCursor
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }])
+     }
+   }
+ | UdfArgumentList ',' AnyCursor ',' UdfArgumentList
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }]).concat($5.expressions)
+     }
+   }
+ | UdfArgumentList 'CURSOR' ',' UdfArgumentList
+   {
+     parser.suggestValueExpressionKeywords($1.expressions[$1.expressions.length - 1].expression);
+     $$ = {
+       activePosition: $1.activePosition,
+       expressions: $1.expressions.concat($4.expressions)
+     }
+   }
+ | AnyCursor ',' UdfArgumentList
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       cursorAtStart : true,
+       activePosition: 1,
+       expressions: [{ expression: { text: '' }, location: @1 }].concat($3.expressions)
+     };
+   }
+ | AnyCursor ','
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       cursorAtStart : true,
+       activePosition: 1,
+       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }]
+     };
+   }
+ | ',' AnyCursor
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: 2,
+       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }]
+     };
+   }
+ | ',' AnyCursor ',' UdfArgumentList
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: 2,
+       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }].concat($4.expressions)
+     };
+   }
+ ;
+
+OptionalOverClause
+ :
+ | OverClause
+ ;
+
+OptionalOverClause_EDIT
+ : OverClause_EDIT
+ ;
+
+OverClause
+ : 'OVER' RegularOrBacktickedIdentifier
+ | 'OVER' WindowExpression
+ ;
+
+OverClause_EDIT
+ : 'OVER' WindowExpression_EDIT
+ ;

+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_update.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/update/update_table.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_use.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/use/use.jison


+ 52 - 14
desktop/core/src/desktop/js/parse/jison/sql/ksql/structure.json

@@ -2,22 +2,22 @@
   "lexer": "sql.jisonlex",
   "autocomplete": [
     "../generic/autocomplete_header.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
+    "../generic/truncate/truncate_table.jison",
     "../generic/sql_error.jison",
-    "../generic/sql_insert.jison",
+    "../generic/insert/insert.jison",
     "sql_list.jison",
     "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/select/select.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -28,29 +28,48 @@
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
     "sql_show.jison",
-    "../generic/sql_udf.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/autocomplete_footer.jison"
   ],
   "syntax": [
     "../generic/syntax_header.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_insert.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/insert/insert.jison",
     "sql_list.jison",
     "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/select/select.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -61,9 +80,28 @@
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
     "sql_show.jison",
-    "../generic/sql_udf.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/syntax_footer.jison"
   ]

+ 61 - 23
desktop/core/src/desktop/js/parse/jison/sql/phoenix/structure.json

@@ -2,24 +2,20 @@
   "lexer": "../generic/sql.jisonlex",
   "autocomplete": [
     "../generic/autocomplete_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_error.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -27,35 +23,55 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_error.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/autocomplete_footer.jison"
   ],
   "syntax": [
     "../generic/syntax_header.jison",
-    "../generic/alter/alter_statement.jison",
+    "../generic/alter/alter_common.jison",
     "../generic/alter/alter_table.jison",
     "../generic/alter/alter_view.jison",
-    "../generic/create/create_statement.jison",
+    "../generic/create/create_common.jison",
     "../generic/create/create_database.jison",
     "../generic/create/create_role.jison",
     "../generic/create/create_table.jison",
     "../generic/create/create_view.jison",
-    "../generic/drop/drop_statement.jison",
+    "../generic/drop/drop_common.jison",
     "../generic/drop/drop_database.jison",
     "../generic/drop/drop_role.jison",
     "../generic/drop/drop_table.jison",
     "../generic/drop/drop_view.jison",
-    "../generic/drop/truncate_table.jison",
-    "../generic/sql_insert.jison",
-    "../generic/sql_main.jison",
-    "../generic/select/select_statement.jison",
+    "../generic/insert/insert.jison",
     "../generic/select/cte_select_statement.jison",
     "../generic/select/from_clause.jison",
     "../generic/select/group_by_clause.jison",
@@ -63,13 +79,35 @@
     "../generic/select/joins.jison",
     "../generic/select/limit_clause.jison",
     "../generic/select/order_by_clause.jison",
+    "../generic/select/select.jison",
     "../generic/select/select_conditions.jison",
     "../generic/select/union_clause.jison",
     "../generic/select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/set/set_common.jison",
+    "../generic/set/set_all.jison",
+    "../generic/set/set_option.jison",
+    "../generic/truncate/truncate_table.jison",
+    "../generic/udf/aggregate/aggregate_common.jison",
+    "../generic/udf/aggregate/avg.jison",
+    "../generic/udf/aggregate/count.jison",
+    "../generic/udf/aggregate/max.jison",
+    "../generic/udf/aggregate/min.jison",
+    "../generic/udf/aggregate/stddev_pop.jison",
+    "../generic/udf/aggregate/stddev_samp.jison",
+    "../generic/udf/aggregate/sum.jison",
+    "../generic/udf/aggregate/var_pop.jison",
+    "../generic/udf/aggregate/var_samp.jison",
+    "../generic/udf/aggregate/variance.jison",
+    "../generic/udf/analytic/analytic.jison",
+    "../generic/udf/function/array.jison",
+    "../generic/udf/function/cast.jison",
+    "../generic/udf/function/if.jison",
+    "../generic/udf/function/map.jison",
+    "../generic/udf/function/truncate.jison",
+    "../generic/udf/udf_common.jison",
+    "../generic/update/update_table.jison",
+    "../generic/use/use.jison",
+    "../generic/sql_main.jison",
     "../generic/sql_valueExpression.jison",
     "../generic/syntax_footer.jison"
   ]

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/druid/druidAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/druid/druidSyntaxParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchSyntaxParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/flink/flinkAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/flink/flinkSyntaxParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic/genericAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic/genericSyntaxParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/ksql/ksqlAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/ksql/ksqlSyntaxParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/phoenix/phoenixAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/phoenix/phoenixSyntaxParser.js


Some files were not shown because too many files changed in this diff