kaqing 2.0.98__py3-none-any.whl → 2.0.203__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. adam/__init__.py +0 -2
  2. adam/app_session.py +9 -12
  3. adam/apps.py +18 -4
  4. adam/batch.py +11 -25
  5. adam/checks/check_utils.py +16 -46
  6. adam/checks/cpu.py +7 -1
  7. adam/checks/cpu_metrics.py +52 -0
  8. adam/checks/disk.py +2 -3
  9. adam/columns/columns.py +3 -1
  10. adam/columns/cpu.py +3 -1
  11. adam/columns/cpu_metrics.py +22 -0
  12. adam/columns/memory.py +3 -4
  13. adam/commands/__init__.py +24 -0
  14. adam/commands/alter_tables.py +37 -63
  15. adam/commands/app/app.py +38 -0
  16. adam/commands/{app_ping.py → app/app_ping.py} +8 -14
  17. adam/commands/app/show_app_actions.py +49 -0
  18. adam/commands/{show → app}/show_app_id.py +8 -11
  19. adam/commands/{show → app}/show_app_queues.py +8 -14
  20. adam/commands/app/utils_app.py +106 -0
  21. adam/commands/audit/audit.py +31 -35
  22. adam/commands/audit/audit_repair_tables.py +26 -48
  23. adam/commands/audit/audit_run.py +50 -0
  24. adam/commands/audit/completions_l.py +15 -0
  25. adam/commands/audit/show_last10.py +36 -0
  26. adam/commands/audit/show_slow10.py +36 -0
  27. adam/commands/audit/show_top10.py +36 -0
  28. adam/commands/audit/utils_show_top10.py +71 -0
  29. adam/commands/bash/__init__.py +5 -0
  30. adam/commands/bash/bash.py +36 -0
  31. adam/commands/bash/bash_completer.py +93 -0
  32. adam/commands/bash/utils_bash.py +16 -0
  33. adam/commands/cassandra/__init__.py +0 -0
  34. adam/commands/cassandra/download_cassandra_log.py +45 -0
  35. adam/commands/cassandra/nodetool.py +64 -0
  36. adam/commands/cassandra/nodetool_commands.py +120 -0
  37. adam/commands/{restart.py → cassandra/restart_cluster.py} +12 -26
  38. adam/commands/cassandra/restart_node.py +51 -0
  39. adam/commands/cassandra/restart_nodes.py +47 -0
  40. adam/commands/cassandra/rollout.py +88 -0
  41. adam/commands/cat.py +36 -0
  42. adam/commands/cd.py +14 -92
  43. adam/commands/check.py +18 -21
  44. adam/commands/cli_commands.py +8 -4
  45. adam/commands/clipboard_copy.py +87 -0
  46. adam/commands/code.py +57 -0
  47. adam/commands/command.py +212 -39
  48. adam/commands/commands_utils.py +20 -28
  49. adam/commands/cql/alter_tables.py +66 -0
  50. adam/commands/cql/completions_c.py +29 -0
  51. adam/commands/cql/cqlsh.py +10 -29
  52. adam/commands/cql/utils_cql.py +305 -0
  53. adam/commands/debug/__init__.py +0 -0
  54. adam/commands/debug/debug.py +22 -0
  55. adam/commands/debug/debug_completes.py +35 -0
  56. adam/commands/debug/debug_timings.py +35 -0
  57. adam/commands/deploy/code_start.py +7 -10
  58. adam/commands/deploy/code_stop.py +4 -21
  59. adam/commands/deploy/code_utils.py +3 -3
  60. adam/commands/deploy/deploy.py +4 -21
  61. adam/commands/deploy/deploy_frontend.py +14 -17
  62. adam/commands/deploy/deploy_pg_agent.py +3 -6
  63. adam/commands/deploy/deploy_pod.py +65 -73
  64. adam/commands/deploy/deploy_utils.py +14 -24
  65. adam/commands/deploy/undeploy.py +4 -21
  66. adam/commands/deploy/undeploy_frontend.py +4 -7
  67. adam/commands/deploy/undeploy_pg_agent.py +6 -8
  68. adam/commands/deploy/undeploy_pod.py +11 -12
  69. adam/commands/devices/__init__.py +0 -0
  70. adam/commands/devices/device.py +149 -0
  71. adam/commands/devices/device_app.py +163 -0
  72. adam/commands/devices/device_auit_log.py +49 -0
  73. adam/commands/devices/device_cass.py +179 -0
  74. adam/commands/devices/device_export.py +87 -0
  75. adam/commands/devices/device_postgres.py +160 -0
  76. adam/commands/devices/devices.py +25 -0
  77. adam/commands/download_cassandra_log.py +45 -0
  78. adam/commands/download_file.py +47 -0
  79. adam/commands/exit.py +1 -4
  80. adam/commands/export/__init__.py +0 -0
  81. adam/commands/export/clean_up_all_export_sessions.py +37 -0
  82. adam/commands/export/clean_up_export_sessions.py +39 -0
  83. adam/commands/export/completions_x.py +11 -0
  84. adam/commands/export/download_export_session.py +40 -0
  85. adam/commands/export/drop_export_database.py +39 -0
  86. adam/commands/export/drop_export_databases.py +37 -0
  87. adam/commands/export/export.py +37 -0
  88. adam/commands/export/export_databases.py +247 -0
  89. adam/commands/export/export_select.py +34 -0
  90. adam/commands/export/export_sessions.py +211 -0
  91. adam/commands/export/export_use.py +49 -0
  92. adam/commands/export/export_x_select.py +48 -0
  93. adam/commands/export/exporter.py +361 -0
  94. adam/commands/export/import_files.py +44 -0
  95. adam/commands/export/import_session.py +44 -0
  96. adam/commands/export/importer.py +82 -0
  97. adam/commands/export/importer_athena.py +150 -0
  98. adam/commands/export/importer_sqlite.py +69 -0
  99. adam/commands/export/show_column_counts.py +45 -0
  100. adam/commands/export/show_export_databases.py +39 -0
  101. adam/commands/export/show_export_session.py +39 -0
  102. adam/commands/export/show_export_sessions.py +37 -0
  103. adam/commands/export/utils_export.py +366 -0
  104. adam/commands/find_files.py +51 -0
  105. adam/commands/find_processes.py +76 -0
  106. adam/commands/generate_report.py +52 -0
  107. adam/commands/head.py +36 -0
  108. adam/commands/help.py +12 -8
  109. adam/commands/intermediate_command.py +52 -0
  110. adam/commands/issues.py +14 -40
  111. adam/commands/kubectl.py +38 -0
  112. adam/commands/login.py +26 -25
  113. adam/commands/ls.py +11 -116
  114. adam/commands/medusa/medusa.py +4 -22
  115. adam/commands/medusa/medusa_backup.py +20 -27
  116. adam/commands/medusa/medusa_restore.py +35 -48
  117. adam/commands/medusa/medusa_show_backupjobs.py +17 -18
  118. adam/commands/medusa/medusa_show_restorejobs.py +13 -18
  119. adam/commands/medusa/utils_medusa.py +15 -0
  120. adam/commands/nodetool.py +8 -19
  121. adam/commands/os/__init__.py +0 -0
  122. adam/commands/os/cat.py +36 -0
  123. adam/commands/os/download_file.py +47 -0
  124. adam/commands/os/find_files.py +51 -0
  125. adam/commands/os/find_processes.py +76 -0
  126. adam/commands/os/head.py +36 -0
  127. adam/commands/os/shell.py +41 -0
  128. adam/commands/param_get.py +11 -14
  129. adam/commands/param_set.py +8 -12
  130. adam/commands/postgres/completions_p.py +22 -0
  131. adam/commands/postgres/postgres.py +47 -55
  132. adam/commands/postgres/postgres_databases.py +269 -0
  133. adam/commands/postgres/postgres_ls.py +4 -8
  134. adam/commands/postgres/postgres_preview.py +5 -9
  135. adam/commands/postgres/utils_postgres.py +79 -0
  136. adam/commands/preview_table.py +10 -61
  137. adam/commands/pwd.py +14 -46
  138. adam/commands/reaper/reaper.py +4 -24
  139. adam/commands/reaper/reaper_forward.py +49 -56
  140. adam/commands/reaper/reaper_forward_session.py +6 -0
  141. adam/commands/reaper/reaper_forward_stop.py +10 -16
  142. adam/commands/reaper/reaper_restart.py +7 -14
  143. adam/commands/reaper/reaper_run_abort.py +8 -33
  144. adam/commands/reaper/reaper_runs.py +43 -58
  145. adam/commands/reaper/reaper_runs_abort.py +29 -49
  146. adam/commands/reaper/reaper_schedule_activate.py +14 -33
  147. adam/commands/reaper/reaper_schedule_start.py +9 -33
  148. adam/commands/reaper/reaper_schedule_stop.py +9 -33
  149. adam/commands/reaper/reaper_schedules.py +4 -14
  150. adam/commands/reaper/reaper_status.py +8 -16
  151. adam/commands/reaper/utils_reaper.py +203 -0
  152. adam/commands/repair/repair.py +4 -22
  153. adam/commands/repair/repair_log.py +5 -11
  154. adam/commands/repair/repair_run.py +27 -34
  155. adam/commands/repair/repair_scan.py +32 -40
  156. adam/commands/repair/repair_stop.py +5 -12
  157. adam/commands/restart_cluster.py +47 -0
  158. adam/commands/restart_node.py +51 -0
  159. adam/commands/restart_nodes.py +47 -0
  160. adam/commands/rollout.py +19 -24
  161. adam/commands/shell.py +12 -4
  162. adam/commands/show/show.py +10 -23
  163. adam/commands/show/show_adam.py +3 -3
  164. adam/commands/show/show_cassandra_repairs.py +37 -0
  165. adam/commands/show/show_cassandra_status.py +47 -51
  166. adam/commands/show/show_cassandra_version.py +5 -18
  167. adam/commands/show/show_cli_commands.py +56 -0
  168. adam/commands/show/show_host.py +1 -1
  169. adam/commands/show/show_login.py +23 -27
  170. adam/commands/show/show_params.py +2 -5
  171. adam/commands/show/show_processes.py +18 -21
  172. adam/commands/show/show_storage.py +11 -20
  173. adam/commands/watch.py +26 -29
  174. adam/config.py +5 -15
  175. adam/embedded_params.py +1 -1
  176. adam/log.py +4 -4
  177. adam/repl.py +105 -133
  178. adam/repl_commands.py +68 -28
  179. adam/repl_session.py +9 -1
  180. adam/repl_state.py +300 -62
  181. adam/sql/async_executor.py +44 -0
  182. adam/sql/lark_completer.py +286 -0
  183. adam/sql/lark_parser.py +604 -0
  184. adam/sql/qingl.lark +1076 -0
  185. adam/sql/sql_completer.py +104 -64
  186. adam/sql/sql_state_machine.py +630 -0
  187. adam/sql/term_completer.py +3 -0
  188. adam/sso/authn_ad.py +6 -8
  189. adam/sso/authn_okta.py +4 -6
  190. adam/sso/cred_cache.py +3 -5
  191. adam/sso/idp.py +9 -12
  192. adam/utils.py +640 -10
  193. adam/utils_athena.py +140 -87
  194. adam/utils_audits.py +102 -0
  195. adam/utils_issues.py +32 -0
  196. adam/utils_k8s/app_clusters.py +28 -0
  197. adam/utils_k8s/app_pods.py +35 -0
  198. adam/utils_k8s/cassandra_clusters.py +34 -21
  199. adam/utils_k8s/cassandra_nodes.py +9 -6
  200. adam/utils_k8s/custom_resources.py +16 -17
  201. adam/utils_k8s/ingresses.py +2 -2
  202. adam/utils_k8s/jobs.py +7 -11
  203. adam/utils_k8s/k8s.py +96 -0
  204. adam/utils_k8s/kube_context.py +3 -6
  205. adam/{pod_exec_result.py → utils_k8s/pod_exec_result.py} +11 -5
  206. adam/utils_k8s/pods.py +146 -75
  207. adam/utils_k8s/secrets.py +4 -4
  208. adam/utils_k8s/service_accounts.py +5 -4
  209. adam/utils_k8s/services.py +2 -2
  210. adam/utils_k8s/statefulsets.py +6 -14
  211. adam/utils_local.py +42 -0
  212. adam/utils_net.py +4 -4
  213. adam/utils_repl/__init__.py +0 -0
  214. adam/utils_repl/appendable_completer.py +6 -0
  215. adam/utils_repl/automata_completer.py +48 -0
  216. adam/utils_repl/repl_completer.py +89 -0
  217. adam/utils_repl/state_machine.py +173 -0
  218. adam/utils_sqlite.py +137 -0
  219. adam/version.py +1 -1
  220. {kaqing-2.0.98.dist-info → kaqing-2.0.203.dist-info}/METADATA +1 -1
  221. kaqing-2.0.203.dist-info/RECORD +277 -0
  222. kaqing-2.0.203.dist-info/top_level.txt +2 -0
  223. teddy/__init__.py +0 -0
  224. teddy/lark_parser.py +436 -0
  225. teddy/lark_parser2.py +618 -0
  226. adam/commands/app.py +0 -67
  227. adam/commands/bash.py +0 -92
  228. adam/commands/cp.py +0 -95
  229. adam/commands/cql/cql_completions.py +0 -11
  230. adam/commands/cql/cql_table_completer.py +0 -8
  231. adam/commands/cql/cql_utils.py +0 -115
  232. adam/commands/describe/describe.py +0 -47
  233. adam/commands/describe/describe_keyspace.py +0 -60
  234. adam/commands/describe/describe_keyspaces.py +0 -49
  235. adam/commands/describe/describe_schema.py +0 -49
  236. adam/commands/describe/describe_table.py +0 -60
  237. adam/commands/describe/describe_tables.py +0 -49
  238. adam/commands/devices.py +0 -118
  239. adam/commands/logs.py +0 -39
  240. adam/commands/postgres/postgres_session.py +0 -240
  241. adam/commands/postgres/postgres_utils.py +0 -31
  242. adam/commands/postgres/psql_completions.py +0 -10
  243. adam/commands/postgres/psql_table_completer.py +0 -11
  244. adam/commands/reaper/reaper_session.py +0 -159
  245. adam/commands/report.py +0 -57
  246. adam/commands/show/show_app_actions.py +0 -53
  247. adam/commands/show/show_commands.py +0 -61
  248. adam/commands/show/show_repairs.py +0 -47
  249. adam/sql/state_machine.py +0 -460
  250. kaqing-2.0.98.dist-info/RECORD +0 -191
  251. kaqing-2.0.98.dist-info/top_level.txt +0 -1
  252. /adam/commands/{describe → app}/__init__.py +0 -0
  253. {kaqing-2.0.98.dist-info → kaqing-2.0.203.dist-info}/WHEEL +0 -0
  254. {kaqing-2.0.98.dist-info → kaqing-2.0.203.dist-info}/entry_points.txt +0 -0
adam/sql/qingl.lark ADDED
@@ -0,0 +1,1076 @@
1
+ # SEAN replaced with qing_a_statement, qing_c0_statement, qing_p0_statement, qing_x0_statement
2
+ start: statement_sequence
3
+
4
+ WHITESPACE: (" " | /\t/ | /\n/ | /\r/ )+
5
+ %ignore WHITESPACE
6
+
7
+ # SEAN replaced with @host statement ( ";" statement )* ";"? "&"?
8
+ statement_sequence: statement ( ";" statement )* ";"? "&"?
9
+
10
+ statement: dcl_statement
11
+ | ddl_statement
12
+ | dml_statement
13
+ | dql_statement
14
+ | utility_statement
15
+ | qing_statement
16
+
17
+ ddl_statement: create_statement
18
+ | drop_statement
19
+ | other_statement
20
+
21
+ # --------------------- SEAN added -------------------
22
+
23
+ # replaced with qing_c_statement, qing_l_statement, , qing_x_statement
24
+ qing_statement: qing_p_statement
25
+
26
+ host_name: IDENTIFIER
27
+
28
+ # --------------------- p: -------------------
29
+
30
+ qing_p_statement: preview_table_statement
31
+ | alter_table_statement
32
+
33
+ preview_table_statement: "PREVIEW"i path
34
+ alter_table_statement: "ALTER"i "TABLE"i keyspace_ref (add_column_action | drop_column_action | modify_column_action | rename_table_action | add_constraint_action)
35
+
36
+ add_column_action: "ADD"i "COLUMN"i? column_definition
37
+ drop_column_action: "DROP"i "COLUMN"i? column_name
38
+ modify_column_action: ("MODIFY"i | "ALTER"i) "COLUMN"i? column_definition
39
+ rename_table_action: "RENAME"i ("TO"i | "AS"i) IDENTIFIER
40
+ add_constraint_action: "ADD"i constraint_definition
41
+
42
+ column_name: IDENTIFIER
43
+ column_definition: IDENTIFIER data_type ("NOT" "NULL")? ("PRIMARY" "KEY")?
44
+
45
+ data_type: "INT"i | "INTEGER"i | "VARCHAR"i "(" nbr ")" | "CHAR"i "(" nbr ")" | "TEXT"i | "DATE"i | "BOOLEAN"i
46
+
47
+ constraint_definition: ("CONSTRAINT"i IDENTIFIER)? ("PRIMARY"i "KEY"i "(" column_name_list ")") | ("FOREIGN"i "KEY"i "(" column_name_list ") REFERENCES"i keyspace_ref "(" column_name_list ")") | ("CHECK"i "(" expr ")")
48
+
49
+ column_name_list: column_name ("," column_name)*
50
+
51
+ # --------------------- c: -------------------
52
+
53
+ qing_c_statement: preview_table_statement
54
+ | alter_cql_table_statement
55
+ | alter_tables_statement
56
+ | describe_statement
57
+ | consistency_statement
58
+ | drop_export_db_statement
59
+ | use_export_db_statement
60
+ | "SHOW"i show_c_subcommand
61
+ | ("@" host_name)? qing_targettable_statement
62
+
63
+ qing_targettable_statement: export_statement
64
+ | import_statement
65
+ | clean_up_export_session_statement
66
+ | download_session_statement
67
+
68
+ show_c_subcommand: show_export_command
69
+
70
+ show_export_command: "EXPORT"i ("DATABASES"i | "SESSION"i export_session_name | "SESSIONS"i)
71
+
72
+ alter_cql_table_statement: "ALTER"i "TABLE"i keyspace_ref (add_column_action | drop_column_action | modify_column_action | rename_table_action | add_constraint_action | "WITH"i properties) ("AND"i properties)*
73
+ alter_tables_statement: "ALTER"i "TABLES"i "WITH"i properties
74
+
75
+ properties: ( property ( "AND"i property )* )?
76
+ property: property_name "=" property_value
77
+ property_name: IDENTIFIER
78
+ property_value: literal | map_literal
79
+ map_literal: "{" ( property_name ":" property_value ( "," property_name ":" property_value )* )? "}"
80
+
81
+ describe_statement: "DESCRIBE"i (describe_table | "TABLES"i | describe_keyspace | "KEYSPACES"i | "SCHEMA"i)
82
+ describe_table: "TABLE"i keyspace_name
83
+ describe_keyspace: "KEYSPACE"i keyspace_name
84
+
85
+ keyspace_name: IDENTIFIER
86
+
87
+ export_statement: "EXPORT"i export_tables? ("WITH"i consistency_statement)? export_to?
88
+ export_tables: ("*" ("IN"i keyspace_name)?) | (export_table ("," export_table)*)
89
+ export_table: path ("(" column_name_list ")")? ("AS"i path)?
90
+
91
+ consistency_statement: "CONSISTENCY"i consistency_type
92
+ consistency_type: IDENTIFIER
93
+
94
+ export_to: "TO"i export_database_type
95
+ import_statement: "IMPORT"i (import_session | import_files) ("TO"i IDENTIFIER)?
96
+ import_session: "SESSION"i export_session_name
97
+ import_files: "FILES"i file_path ("AS"i file_path)
98
+
99
+ export_database_type: IDENTIFIER
100
+ export_session_name: IDENTIFIER
101
+ export_database_name: IDENTIFIER
102
+
103
+ file_path: (file_name "/")* file_name
104
+ file_name: (IDENTIFIER ".")* IDENTIFIER
105
+
106
+ drop_export_db_statement: "DROP"i (drop_all_export_dbs | drop_export_database)
107
+ drop_all_export_dbs: "ALL"i "EXPORT"i "DATABASES"i
108
+ drop_export_database: "EXPORT"i "DATABASE"i export_database_name
109
+
110
+ use_export_db_statement: "USE"i export_database_name
111
+
112
+ clean_up_export_session_statement: "CLEAN"i "UP"i (clean_up_all_export_sessions | clean_up_export_sessions)
113
+ clean_up_all_export_sessions: "ALL"i "EXPORT"i "SESSIONS"i
114
+ clean_up_export_sessions: "EXPORT"i "SESSIONS"i export_session_name ("," export_session_name)*
115
+
116
+ download_session_statement: "DOWNLOAD"i "EXPORT"i "SESSION"i export_session_name
117
+
118
+ # --------------------- l: -------------------
119
+
120
+ qing_l_statement: preview_table_statement
121
+ | alter_athena_table_statement
122
+ | describe_table_statement
123
+ | "AUDIT"i ("REPAIR"i | "RUN"i)?
124
+ | show_topn_statement
125
+
126
+ alter_athena_table_statement: "ALTER"i "TABLE"i keyspace_ref (add_column_action | drop_column_action | modify_column_action | rename_table_action | add_constraint_action | add_partition_action | drop_partition_action)
127
+ add_partition_action: "ADD"i "PARTITION"i partition_ref
128
+ drop_partition_action: "DROP"i "PARTITION"i partition_ref
129
+
130
+ partition_ref: "(" partition_name "=" single_quoted_string ("," partition_name "=" single_quoted_string)* ")"
131
+ partition_name: IDENTIFIER
132
+
133
+ describe_table_statement: "DESCRIBE"i "TABLE"i path
134
+
135
+ show_topn_statement: "SHOW"i topn_type topn_count ("OVER"i topn_window)?
136
+ topn_count: digit+
137
+ topn_type: IDENTIFIER
138
+ topn_window: IDENTIFIER
139
+
140
+ # --------------------- x: -------------------
141
+
142
+ qing_x_statement: preview_table_statement
143
+ | describe_table_statement
144
+ | drop_export_db_statement
145
+
146
+ qing_x0_statement: drop_export_db_statement
147
+
148
+ # --------------------- a: -------------------
149
+
150
+ # --------------------- SEAN end -------------------
151
+
152
+ create_statement: create_scope
153
+ | create_collection
154
+ | create_primary_index
155
+ | create_index
156
+ | create_function
157
+ | create_sequence
158
+
159
+ drop_statement: drop_scope
160
+ | drop_collection
161
+ | drop_primary_index
162
+ | drop_index
163
+ | drop_function
164
+
165
+ other_statement: alter_index
166
+ | build_index
167
+ | execute_function
168
+
169
+ create_scope: "CREATE"i "SCOPE"i ( namespace_ref ":" )? bucket_ref "." scope_ref if_not_exists?
170
+
171
+ if_not_exists: "IF"i "NOT"i "EXISTS"i
172
+
173
+ create_collection: "CREATE"i "COLLECTION"i ( ( namespace_ref ":" )? bucket_ref "." scope_ref "." )? \
174
+ collection_ref if_not_exists?
175
+
176
+ drop_scope: "DROP"i "SCOPE"i ( namespace_ref ":")? bucket_ref "." scope_ref if_exists?
177
+
178
+ if_exists: "IF"i "EXISTS"i
179
+
180
+ drop_collection: "DROP"i "COLLECTION"i \
181
+ ( ( namespace_ref ":")? bucket_ref "." scope_ref "." )? \
182
+ collection_ref if_exists?
183
+
184
+ create_primary_index: "CREATE"i "PRIMARY"i "INDEX"i index_name? ( "IF"i "NOT"i "EXISTS"i )? "ON"i \
185
+ keyspace_ref index_using? index_with?
186
+
187
+ index_using: "USING"i "GSI"i
188
+
189
+ index_with: "WITH"i expr
190
+
191
+ create_index: "CREATE"i "INDEX"i index_name if_not_exists? "ON"i keyspace_ref \
192
+ LPAREN index_key lead_key_attribs? ( ( "," index_key key_attribs? )+ )? RPAREN \
193
+ index_partition? where_clause? index_using? index_with?
194
+
195
+ index_key: expr | array_expr
196
+
197
+ lead_key_attribs: (index_order include_missing?) | (include_missing index_order?)
198
+
199
+ key_attribs: index_order
200
+
201
+ include_missing: "INCLUDE"i "MISSING"i
202
+
203
+ index_order: "ASC"i | "DESC"i
204
+
205
+ array_expr: full_array_expr | simple_array_expr
206
+
207
+ full_array_expr: ( "ALL"i | "DISTINCT"i ) "ARRAY"i expr \
208
+ "FOR"i var ( "IN"i | "WITHIN"i ) expr \
209
+ ( "," var ( "IN"i | "WITHIN"i ) expr )* ("WHEN"i cond)? "END"i \
210
+
211
+ simple_array_expr: ( "ALL"i | "DISTINCT"i ) expr
212
+
213
+ pairs_function: "PAIRS"i LPAREN ( "SELF"i | index_key_object ) RPAREN
214
+
215
+ index_key_object: expr
216
+
217
+ index_partition: "PARTITION"i "BY"i "HASH"i LPAREN partition_key_expr \
218
+ ( "," partition_key_expr )* RPAREN
219
+
220
+ partition_key_expr: expr
221
+
222
+ alter_index: "ALTER"i "INDEX"i ( ( index_path "." index_name ) | ( index_name "ON"i keyspace_ref ) \
223
+ index_using? index_with )
224
+
225
+ build_index: "BUILD"i "INDEX"i "ON"i keyspace_ref LPAREN index_term ( "," index_term )* RPAREN index_using?
226
+
227
+ index_term: index_name | subquery_expr
228
+
229
+ drop_primary_index: "DROP"i "PRIMARY"i "INDEX"i if_exists? "ON"i keyspace_ref index_using?
230
+
231
+ drop_index: "DROP"i "INDEX"i ( ( index_path "." index_name if_exists? ) | \
232
+ index_name if_exists? "ON"i keyspace_ref ) index_using?
233
+
234
+ index_path: keyspace_full | keyspace_prefix | keyspace_partial
235
+
236
+ keyspace_full: namespace_ref ":" bucket_ref "." scope_ref "." collection_ref
237
+
238
+ keyspace_prefix: ( namespace_ref ":" )? bucket_ref
239
+
240
+ create_function: create_function_inline | create_function_external
241
+
242
+ create_function_inline: "CREATE"i ( "OR"i "REPLACE"i )? "FUNCTION"i function_ref LPAREN params? RPAREN if_not_exists? \
243
+ ( ( LBRACE body RBRACE ) | ( "LANGUAGE"i "INLINE"i "AS"i body ) )
244
+
245
+ create_function_external: "CREATE"i ( "OR"i "REPLACE"i )? "FUNCTION"i function_ref LPAREN params? RPAREN if_not_exists? \
246
+ "LANGUAGE"i "JAVASCRIPT"i "AS"i obj "AT"i
247
+
248
+
249
+ function_ref: ( namespace_ref ":" ( bucket_ref "." scope_ref "." )? )? identifier_ref
250
+
251
+ params: ( identifier_or_star ( "," identifier_or_star )* ) | "..."
252
+
253
+ body: ( expr | let_clause )*
254
+
255
+ obj: json_object
256
+
257
+ create_sequence: "CREATE"i "SEQUENCE"i ( \
258
+ ( sequence if_not_exists? )
259
+ | ( if_not_exists? sequence ) ) ( create_sequence_options | sequence_with )?
260
+
261
+ sequence: ( ( namespace_ref ":" )? bucket_ref "." scope_ref "." )? identifier_ref
262
+
263
+ create_sequence_options: ( start_with
264
+ | increment_by
265
+ | maxvalue
266
+ | minvalue
267
+ | cycle
268
+ | cache )*
269
+
270
+ start_with: "START"i "WITH"i nbr
271
+
272
+ increment_by: "INCREMENT"i "BY"i nbr
273
+
274
+ maxvalue: ( "MAXVALUE"i nbr ) | ( "NO"i "MAXVALUE"i )
275
+
276
+ minvalue: ( "MINVALUE"i nbr ) | ( "NO"i "MINVALUE"i )
277
+
278
+ cycle: "NO"i? "CYCLE"i
279
+
280
+ cache: ( "CACHE"i nbr ) | ( "NO"i "CACHE"i )
281
+
282
+ sequence_with: "WITH"i expr
283
+
284
+ drop_function: "DROP"i "FUNCTION"i function_ref if_exists?
285
+
286
+ execute_function: "EXECUTE"i "FUNCTION"i function_ref LPAREN ( expr ( "," expr )* )? RPAREN
287
+
288
+ dml_statement: delete_statement
289
+ | insert_statement
290
+ | merge_statement
291
+ | update_statement
292
+ | upsert_statement
293
+
294
+ delete_statement: "DELETE"i "FROM"i target_keyspace use_keys_clause? where_clause? returning_clause?
295
+
296
+ insert_statement: "INSERT"i "INTO"i target_keyspace ( insert_values | insert_select )
297
+
298
+ insert_values: ( LPAREN "PRIMARY"i? "KEY"i "," "VALUE"i ( "," options )? RPAREN )? values_clause
299
+
300
+ values_clause: "VALUES"i LPAREN key_expr "," value_expr ( "," "OPTIONS"i )? RPAREN \
301
+ ( "," "VALUES"i? LPAREN key_expr "," value_expr ( "," "OPTIONS"i )? RPAREN )*
302
+
303
+
304
+ insert_select: LPAREN "PRIMARY"i? "KEY"i key_expr ( "," "VALUE"i value_expr )? \
305
+ ( "," "OPTIONS"i options )? RPAREN select_statement
306
+
307
+
308
+ options: obj
309
+
310
+ merge_statement: "MERGE"i "INTO"i ( ansi_merge | lookup_merge ) limit_clause? returning_clause?
311
+
312
+ ansi_merge: target_keyspace use_index_clause "USING"i ansi_merge_source \
313
+ ansi_merge_predicate ansi_merge_actions
314
+
315
+ ansi_merge_source: ( merge_source_keyspace | merge_source_subquery | merge_source_expr ) \
316
+ ansi_join_hints?
317
+
318
+ ansi_merge_predicate: "ON"i expr
319
+
320
+ ansi_merge_actions: merge_update? merge_delete? ansi_merge_insert?
321
+
322
+ ansi_merge_insert: "WHEN"i "NOT"i "MATCHED"i "THEN"i "INSERT"i LPAREN "KEY"i? key_expr \
323
+ ( "," "VALUE"i? value_expr )? ( "," "OPTIONS"i? options )? RPAREN where_clause?
324
+
325
+
326
+ lookup_merge: target_keyspace "USING"i lookup_merge_source lookup_merge_predicate \
327
+ lookup_merge_actions
328
+
329
+ lookup_merge_source: ( merge_source_keyspace use_clause? )
330
+ | merge_source_subquery
331
+ | merge_source_expr
332
+
333
+ lookup_merge_predicate: "ON"i "PRIMARY"i? "KEY"i expr
334
+
335
+ lookup_merge_actions: merge_update? merge_delete? lookup_merge_insert?
336
+
337
+ lookup_merge_insert: "WHEN"i "NOT"i "MATCHED"i "THEN"i "INSERT"i expr where_clause?
338
+
339
+ merge_source_keyspace: keyspace_ref ( "AS"i? alias )?
340
+
341
+ merge_source_subquery: subquery_expr "AS"i? alias
342
+
343
+ merge_source_expr: expr ( "AS"i? alias )?
344
+
345
+ merge_update: "WHEN"i "MATCHED"i "THEN"i "UPDATE"i set_clause? unset_clause? where_clause?
346
+
347
+ merge_delete: "WHEN"i "MATCHED"i "THEN"i "DELETE"i where_clause?
348
+
349
+ update_statement: "UPDATE"i target_keyspace use_keys_clause? set_clause? unset_clause? \
350
+ where_clause? limit_clause? returning_clause?
351
+
352
+ upsert_statement: "UPSERT"i "INTO"i target_keyspace ( insert_values | insert_select ) \
353
+ returning_clause?
354
+
355
+ target_keyspace: keyspace_ref ( "AS"i? alias )?
356
+
357
+ returning_clause: "RETURNING"i ( ( result_expr ( "," result_expr )* ) | \
358
+ ( ( "RAW"i | "ELEMENT"i | "VALUE"i ) expr ) )
359
+
360
+
361
+ set_clause: "SET"i ( path "=" expr update_for? ) \
362
+ ( "," ( path "=" expr update_for? ) )*
363
+
364
+ unset_clause: "UNSET"i path update_for? ( "," path update_for? )*
365
+
366
+ update_for: ( "FOR"i ( name_var ":" )? var ( "IN"i | "WITHIN"i ) path \
367
+ ( "," ( name_var ":" )? var ( "IN"i | "WITHIN"i ) path )* )+ \
368
+ ( "WHEN"i cond )? "END"i
369
+
370
+
371
+ key_expr: expr
372
+
373
+ value_expr: expr
374
+
375
+ dql_statement: select_statement
376
+ | infer_statement
377
+ | update_statistics
378
+
379
+ select_statement: select_term ( set_op select_term )* order_by_clause? limit_clause? offset_clause?
380
+
381
+ select_term: subselect | LPAREN select_statement RPAREN
382
+
383
+ subselect: select_from | from_select
384
+
385
+ select_from: with_clause? select_clause from_clause? let_clause? where_clause? group_by_clause? window_clause?
386
+
387
+ from_select: with_clause? from_clause let_clause? where_clause? group_by_clause? window_clause? select_clause
388
+
389
+ set_op: ( "UNION"i | "INTERSECT"i | "EXCEPT"i ) "ALL"i?
390
+
391
+ with_clause: "WITH"i alias "AS"i LPAREN ( select_statement | expr ) RPAREN \
392
+ ( "," alias "AS"i LPAREN ( select_statement | expr ) RPAREN )*
393
+
394
+ alias: identifier_ref
395
+
396
+ # SEAN replaced with ("SELECT"i | "XELECT"i) hint_comment? projection
397
+ select_clause: "SELECT"i hint_comment? projection
398
+
399
+ projection: ( "ALL"i | "DISTINCT"i )? ( result_expr ( "," result_expr )* | \
400
+ ( "RAW"i | "ELEMENT"i | "VALUE"i ) expr ( "AS"i? alias )? )
401
+
402
+ result_expr: ( ( path "." )? "*") | expr ( "AS"i? alias )?
403
+
404
+ path: identifier_ref ( LBRACKET expr RBRACKET )* ( "." identifier_ref ( LBRACKET expr RBRACKET )* )*
405
+
406
+ from_clause: "FROM"i from_terms
407
+
408
+ from_terms: ( from_keyspace | from_subquery | from_generic ) \
409
+ ( join_clause | nest_clause | unnest_clause )* comma_separated_join*
410
+
411
+ from_keyspace: keyspace_ref ( "AS"i? alias )? use_clause?
412
+
413
+ keyspace_ref: keyspace_path | keyspace_partial
414
+
415
+ keyspace_path: ( namespace_ref ":" )? bucket_ref ( "." scope_ref "." collection_ref )?
416
+
417
+ keyspace_partial: collection_ref
418
+
419
+ namespace_ref: identifier_ref
420
+
421
+ bucket_ref: identifier_ref
422
+
423
+ scope_ref: identifier_ref
424
+
425
+ collection_ref: identifier_ref
426
+
427
+ from_subquery: subquery_expr "AS"i? alias
428
+
429
+ subquery_expr: LPAREN select_statement RPAREN
430
+
431
+ from_generic: expr ( "AS"i? alias)?
432
+
433
+ join_clause: ansi_join_clause | lookup_join_clause | index_join_clause
434
+
435
+ ansi_join_clause: ansi_join_type? "JOIN"i ansi_join_rhs ansi_join_predicate
436
+
437
+ ansi_join_type: "INNER"i | ( "LEFT"i | "RIGHT"i ) "OUTER"i?
438
+
439
+ ansi_join_rhs: rhs_keyspace | rhs_subquery | rhs_generic
440
+
441
+ rhs_keyspace: keyspace_ref ( "AS"i? alias )? ansi_join_hints?
442
+
443
+ rhs_subquery: subquery_expr "AS"i? alias
444
+
445
+ rhs_generic: expr ( "AS"i? alias )?
446
+
447
+ ansi_join_hints: use_hash_hint | use_nl_hint | multiple_hints
448
+
449
+ use_hash_hint: "USE"i use_hash_term
450
+
451
+ use_hash_term: "HASH"i LPAREN ( "BUILD"i | "PROBE"i ) RPAREN
452
+
453
+ use_nl_hint: "USE"i use_nl_term
454
+
455
+ use_nl_term: "NL"i
456
+
457
+ multiple_hints: "USE"i ( ( ansi_hint_terms other_hint_terms ) | ( other_hint_terms ansi_hint_terms ) )
458
+
459
+ ansi_hint_terms: use_hash_term | use_nl_term
460
+
461
+ other_hint_terms: use_index_term | use_keys_term
462
+
463
+ ansi_join_predicate: "ON"i expr
464
+
465
+ lookup_join_clause: lookup_join_type? "JOIN"i lookup_join_rhs lookup_join_predicate
466
+
467
+ lookup_join_type: "INNER"i | ( "LEFT"i "OUTER"i? )
468
+
469
+ lookup_join_rhs: keyspace_ref ( "AS"i? alias )?
470
+
471
+ lookup_join_predicate: "ON"i "PRIMARY"i? "KEYS"i expr
472
+
473
+ index_join_clause: index_join_type? "JOIN"i index_join_rhs index_join_predicate
474
+
475
+ index_join_type: "INNER"i | ( "LEFT"i "OUTER"i? )
476
+
477
+ index_join_rhs: keyspace_ref ( "AS"i? alias )?
478
+
479
+ index_join_predicate: "ON"i "PRIMARY"i? "KEY"i expr "FOR"i alias
480
+
481
+ comma_separated_join: "," ( rhs_keyspace | rhs_subquery | rhs_generic )
482
+
483
+ nest_clause: ansi_nest_clause | lookup_nest_clause | index_nest_clause
484
+
485
+ ansi_nest_clause: ansi_nest_type? "NEST"i ansi_nest_rhs ansi_nest_predicate
486
+
487
+ ansi_nest_type: "INNER"i | ( "LEFT"i "OUTER"i? )
488
+
489
+ ansi_nest_rhs: keyspace_ref ( "AS"i? alias )?
490
+
491
+ ansi_nest_predicate: "ON"i expr
492
+
493
+ lookup_nest_clause: lookup_nest_type? "NEST"i lookup_nest_rhs lookup_nest_predicate
494
+
495
+ lookup_nest_type: "INNER"i | ( "LEFT"i "OUTER"i? )
496
+
497
+ lookup_nest_rhs: keyspace_ref ( "AS"i? alias )?
498
+
499
+ lookup_nest_predicate: "ON"i "KEYS"i expr
500
+
501
+ index_nest_clause: index_nest_type? "NEST"i index_nest_rhs index_nest_predicate
502
+
503
+ index_nest_type: "INNER"i | ( "LEFT"i "OUTER"i? )
504
+
505
+ index_nest_rhs: keyspace_ref ( "AS"i? alias )?
506
+
507
+ index_nest_predicate: "ON"i "KEY"i expr "FOR"i alias
508
+
509
+ unnest_clause: unnest_type? ( "UNNEST"i | "FLATTEN"i ) expr ( "AS"i? alias )?
510
+
511
+ unnest_type: "INNER"i | ( "LEFT"i "OUTER"i? )
512
+
513
+ use_clause: use_keys_clause | use_index_clause
514
+
515
+ use_keys_clause: "USE"i use_keys_term
516
+
517
+ use_keys_term: "PRIMARY"i? "KEYS"i expr
518
+
519
+ use_index_clause: "USE"i use_index_term
520
+
521
+ use_index_term: "INDEX"i LPAREN index_ref ( "," index_ref )* RPAREN
522
+
523
+ index_ref: index_name? index_type?
524
+
525
+ index_name: identifier_ref
526
+
527
+ index_type: "USING"i ( "GSI"i | "FTS"i )
528
+
529
+ let_clause: "LET"i alias "=" expr ( "," alias "=" expr )*
530
+
531
+ where_clause: "WHERE"i cond
532
+
533
+ cond: expr
534
+
535
+ group_by_clause: "GROUP"i "BY"i group_term ( "," group_term )* \
536
+ letting_clause? having_clause? | letting_clause
537
+
538
+ group_term: expr ( "AS"i? alias )?
539
+
540
+ letting_clause: "LETTING"i alias "=" expr ( "," alias "=" expr )*
541
+
542
+ having_clause: "HAVING"i cond
543
+
544
+ window_clause: "WINDOW"i window_declaration ( "," window_declaration )*
545
+
546
+ window_declaration: window_name "AS"i LPAREN window_definition RPAREN
547
+
548
+ window_name: identifier_ref
549
+
550
+ window_definition: window_ref? window_partition_clause? window_order_clause? window_frame_clause?
551
+
552
+ window_ref: identifier_ref
553
+
554
+ window_partition_clause: "PARTITION"i "BY"i expr ( "," expr )*
555
+
556
+ window_order_clause: "ORDER"i "BY"i ordering_term ( "," ordering_term )*
557
+
558
+ window_frame_clause: ( "ROWS"i | "RANGE"i | "GROUPS"i ) window_frame_extent window_frame_exclusion?
559
+
560
+ window_frame_extent: ( "UNBOUNDED"i "PRECEDING"i )
561
+ | ( "CURRENT"i "ROW"i )
562
+ | ( "BETWEEN"i ( ( "UNBOUNDED"i "PRECEDING"i )
563
+ | ( "CURRENT"i "ROW"i )
564
+ | ( "PRECEDING"i | "FOLLOWING"i ) \
565
+ ) )
566
+
567
+ window_frame_exclusion: "EXCLUDE"i ( ( "CURRENT"i "ROW"i ) | "GROUP"i | "TIES"i | ( "NO"i "OTHERS"i ) )
568
+
569
+ order_by_clause: "ORDER"i "BY"i ordering_term ( "," ordering_term )*
570
+
571
+ ordering_term: expr ( "ASC"i | "DESC"i )? ( "NULLS"i ( "FIRST"i | "LAST"i ) )?
572
+
573
+ limit_clause: "LIMIT"i expr
574
+
575
+ offset_clause: "OFFSET"i expr
576
+
577
+ hint_comment: block_hint_comment | line_hint_comment
578
+
579
+ block_hint_comment: "/*+" hints "*/"
580
+
581
+ line_hint_comment: "--+" hints
582
+
583
+ hints: simple_hint_sequence | json_hint_object
584
+
585
+ simple_hint_sequence: simple_hint+
586
+
587
+ simple_hint: ordered_hint_simple
588
+ | gsi_hint_simple
589
+ | fts_hint_simple
590
+ | hash_hint_simple
591
+ | nl_hint_simple
592
+
593
+ ordered_hint_simple: "ORDERED"i
594
+
595
+ gsi_hint_simple: "INDEX"i LPAREN keyspace_statement RPAREN
596
+
597
+ keyspace_statement: "KEYSPACE"i identifier_ref
598
+
599
+ fts_hint_simple: "INDEX_FTS"i LPAREN keyspace_statement RPAREN
600
+
601
+ nl_hint_simple: "USE_NL"i LPAREN ( keyspace_statement )+ RPAREN
602
+
603
+ hash_hint_simple: "USE_HASH"i LPAREN ( keyspace_statement ( "/" ( "BUILD"i | "PROBE"i ) )? )+ RPAREN
604
+
605
+ json_hint_object: LBRACE json_hint ( "," json_hint )* RBRACE
606
+
607
+ json_hint: ordered_hint_json
608
+ | gsi_hint_json
609
+ | fts_hint_json
610
+ | hash_hint_json
611
+ | nl_hint_json
612
+
613
+ ordered_hint_json: "\"ORDERED\"" ":" "TRUE"i
614
+
615
+ gsi_hint_json: "\"INDEX\"" ":" ( index_array | index_object )
616
+
617
+ fts_hint_json: "\"INDEX_FTS\"" ":" ( index_array | index_object )
618
+
619
+ nl_hint_json: "\"USE_NS\"" ":" ( keyspace_array | keyspace_object )
620
+
621
+ hash_hint_json: "\"USE_HASH\"" ":" ( hash_array | hash_object )
622
+
623
+ index_array: LBRACKET index_object ( "," index_object )* RBRACKET
624
+
625
+ index_object: LBRACE keyspace_property "," indexes_property RBRACE
626
+
627
+ indexes_property: "\"INDEXES\"" ":" ( "NULL"i
628
+ | ( "\"" index "\"" )
629
+ | ( LBRACKET "\"" index "\"" RBRACKET ( "," "\"" index "\"" )* RBRACKET ) \
630
+ )
631
+
632
+ index: index_ref
633
+
634
+ keyspace_array: LBRACKET keyspace_object ( "," keyspace_object )* RBRACKET
635
+
636
+ keyspace_object: LBRACE keyspace_property RBRACE
637
+
638
+ keyspace_property: ( "\"KEYSPACE\"" | "\"ALIAS\"" ) ":" "\"" keyspace_statement "\""
639
+
640
+ hash_array: LBRACKET hash_object ( "," hash_object )* RBRACKET
641
+
642
+ hash_object: LBRACE keyspace_property ( "," option_property )? RBRACE
643
+
644
+ option_property: "\"OPTION\"" ":" ( "\"BUILD\"" | "\"PROBE\"" | "NULL"i )
645
+
646
+ expr: ( \
647
+ ( \
648
+ function_call
649
+ | path
650
+ | json_value
651
+ | literal
652
+ | named_arg
653
+ | nested_expr
654
+ | new_array_expr
655
+ | ( LPAREN expr RPAREN )
656
+ | subquery_expr \
657
+ ) ( \
658
+ comparison_term
659
+ | arithmetic_term
660
+ | concatenation_term
661
+ | logical_term
662
+ | collection_expr \
663
+ )* \
664
+ ) | case_expr | ( LPAREN expr RPAREN )
665
+
666
+ literal: str | nbr | bool | "NULL"i | "MISSING"i
667
+
668
+ nbr: digit+ ( "." digit+ )? ( "E"i ( "+" | "-" ) digit+ )?
669
+
670
+ digit: "0".."9"
671
+
672
+ str: double_quoted_string | single_quoted_string
673
+
674
+ double_quoted_string: "\"" double_quoted_string_character* "\""
675
+
676
+ single_quoted_string: "'" single_quoted_string_character* "'"
677
+
678
+ double_quoted_string_character: ( escape_sequence | "\\\"" | string_char )
679
+
680
+ single_quoted_string_character: ( escape_sequence | "\\'" | string_char )
681
+
682
+ escape_sequence: /\\[nrt\\]/ | /\\u[0-9a-fA-F]{4}/
683
+
684
+ string_char: /./
685
+
686
+ bool: "TRUE"i | "FALSE"i
687
+
688
+ identifier_or_star: identifier_ref | "*"
689
+
690
+ fn_names: FUNCS | grammar_funcs
691
+
692
+ FUNCS: "ABS"i
693
+ | "ACOS"i
694
+ | "ARRAY_APPEND"i
695
+ | "ARRAY_AVG"i
696
+ | "ARRAY_CONCAT"i
697
+ | "ARRAY_CONTAINS"i
698
+ | "ARRAY_COUNT"i
699
+ | "ARRAY_DISTINCT"i
700
+ | "ARRAY_FLATTEN"i
701
+ | "ARRAY_IFNULL"i
702
+ | "ARRAY_INSERT"i
703
+ | "ARRAY_INTERSECT"i
704
+ | "ARRAY_LENGTH"i
705
+ | "ARRAY_MAX"i
706
+ | "ARRAY_MIN"i
707
+ | "ARRAY_POSITION"i
708
+ | "ARRAY_PREPEND"i
709
+ | "ARRAY_PUT"i
710
+ | "ARRAY_RANGE"i
711
+ | "ARRAY_REMOVE"i
712
+ | "ARRAY_REPEAT"i
713
+ | "ARRAY_REPLACE"i
714
+ | "ARRAY_REVERSE"i
715
+ | "ARRAY_SORT"i
716
+ | "ARRAY_STAR"i
717
+ | "ARRAY_SUM"i
718
+ | "ARRAY_SYMDIFF"i
719
+ | "ARRAY_SYMDIFF1"i
720
+ | "ARRAY_SYMDIFFN"i
721
+ | "ARRAY_UNION"i
722
+ | "ASIN"i
723
+ | "ATAN"i
724
+ | "ATAN2"i
725
+ | "AVG"i
726
+ | "CEIL"i
727
+ | "CLOCK_LOCAL"i
728
+ | "CLOCK_MILLIS"i
729
+ | "CLOCK_STR"i
730
+ | "CLOCK_TZ"i
731
+ | "CLOCK_UTC"i
732
+ | "CONCAT"i
733
+ | "CONTAINS"i
734
+ | "COS"i
735
+ | "COUNT"i
736
+ | "DATE_ADD_MILLIS"i
737
+ | "DATE_DIFF_STR"i
738
+ | "DATE_FORMAT_STR"i
739
+ | "DATE_PART_MILLIS"i
740
+ | "DATE_PART_STR"i
741
+ | "DATE_RANGE_MILLIS"i
742
+ | "DATE_RANGE_STR"i
743
+ | "DATE_TRUNC_MILLIS"i
744
+ | "DATE_TRUNC_STR"i
745
+ | "DECODE_JSON"i
746
+ | "DEGREES"i
747
+ | "DURATION_TO_STR"i
748
+ | "ENCODE_JSON"i
749
+ | "ENCODED_SIZE"i
750
+ | "EXP"i
751
+ | "FLOOR"i
752
+ | "GREATEST"i
753
+ | "IF_INF"i
754
+ | "IF_MISSING"i
755
+ | "IF_MISSING_OR_NULL"i
756
+ | "IF_NAN"i
757
+ | "IF_NAN_OR_INF"i
758
+ | "IF_NULL"i
759
+ | "IFINF"i
760
+ | "IFMISSING"i
761
+ | "IFMISSINGORNULL"i
762
+ | "IFNAN"i
763
+ | "IFNANORINF"i
764
+ | "IFNULL"i
765
+ | "INITCAP"i
766
+ | "IS_ARRAY"i
767
+ | "IS_ATOM"i
768
+ | "IS_BOOL"i
769
+ | "IS_BOOLEAN"i
770
+ | "IS_NUM"i
771
+ | "IS_NUMBER"i
772
+ | "IS_OBJ"i
773
+ | "IS_OBJECT"i
774
+ | "IS_STR"i
775
+ | "IS_STRING"i
776
+ | "ISARRAY"i
777
+ | "LEAST"i
778
+ | "LENGTH"i
779
+ | "LN"i
780
+ | "LOG"i
781
+ | "LOWER"i
782
+ | "LTRIM"i
783
+ | "MAX"i
784
+ | "META"i
785
+ | "MILLIS"i
786
+ | "MILLIS_TO_LOCAL"i
787
+ | "MILLIS_TO_STR"i
788
+ | "MILLIS_TO_TZ"i
789
+ | "MILLIS_TO_UTC"i
790
+ | "MILLIS_TO_ZONE_NAME"i
791
+ | "MIN"i
792
+ | "MISSING_IF"i
793
+ | "MISSINGIF"i
794
+ | "NOW_LOCAL"i
795
+ | "NOW_MILLIS"i
796
+ | "NOW_STR"i
797
+ | "NOW_TZ"i
798
+ | "NOW_UTC"i
799
+ | "NULL_IF"i
800
+ | "NULLIF"i
801
+ | "OBJECT_ADD"i
802
+ | "OBJECT_CONCAT"i
803
+ | "OBJECT_INNER_VALUES"i
804
+ | "OBJECT_LENGTH"i
805
+ | "OBJECT_NAMES"i
806
+ | "OBJECT_PAIRS"i
807
+ | "OBJECT_PUT"i
808
+ | "OBJECT_REMOVE"i
809
+ | "OBJECT_RENAME"i
810
+ | "OBJECT_REPLACE"i
811
+ | "OBJECT_UNWRAP"i
812
+ | "OBJECT_VALUES"i
813
+ | "PAIRS"i
814
+ | "PI"i
815
+ | "POSINFIF"i
816
+ | "POSITION"i
817
+ | "POWER"i
818
+ | "RADIANS"i
819
+ | "RANDOM"i
820
+ | "REGEXP_CONTAINS"i
821
+ | "REGEXP_LIKE"i
822
+ | "REGEXP_POSITION"i
823
+ | "REGEXP_REPLACE"i
824
+ | "REPEAT"i
825
+ | "REPLACE"i
826
+ | "REVERSE"i
827
+ | "ROUND"i
828
+ | "RTRIM"i
829
+ | "SIGN"i
830
+ | "SIN"i
831
+ | "SPLIT"i
832
+ | "SQRT"i
833
+ | "STR_TO_DURATION"i
834
+ | "STR_TO_MILLIS"i
835
+ | "STR_TO_TZ"i
836
+ | "STR_TO_UTC"i
837
+ | "STR_TO_ZONE_NAME"i
838
+ | "SUBSTR"i
839
+ | "SUM"i
840
+ | "TAN"i
841
+ | "TITLE"i
842
+ | "TO_ARRAY"i
843
+ | "TO_ATOM"i
844
+ | "TO_BOOL"i
845
+ | "TO_BOOLEAN"i
846
+ | "TO_NUM"i
847
+ | "TO_NUMBER"i
848
+ | "TO_OBJ"i
849
+ | "TO_OBJECT"i
850
+ | "TO_STR"i
851
+ | "TO_STRING"i
852
+ | "TOARRAY"i
853
+ | "TOATOM"i
854
+ | "TOBOOL"i
855
+ | "TOBOOLEAN"i
856
+ | "TONUM"i
857
+ | "TONUMBER"i
858
+ | "TOOBJ"i
859
+ | "TOOBJECT"i
860
+ | "TOSTR"i
861
+ | "TOSTRING"i
862
+ | "TRIM"i
863
+ | "TRUNC"i
864
+ | "TYPE"i
865
+ | "TYPENAME"i
866
+ | "UPPER"i
867
+ | "UUID"i
868
+ | "WEEKDAY_MILLIS"i
869
+ | "WEEKDAY_STR"i
870
+
871
+ grammar_funcs: "TYPE"i | "TITLE"i | "SUM"i
872
+
873
+ named_arg: "$" IDENTIFIER
874
+
875
+ IDENTIFIER: /[a-zA-Z_][0-9a-zA-Z_\-$]*/
876
+
877
+ identifier_ref: IDENTIFIER | grammar_funcs | escaped_identifier
878
+
879
+ escaped_identifier: BACKTICK ( IDENTIFIER | grammar_funcs ) BACKTICK
880
+
881
+ arithmetic_term: ( "+" expr )
882
+ | ( "*" expr )
883
+ | ( "/" expr )
884
+ | ( "%" expr )
885
+ | ( "-" expr )
886
+
887
+ comparison_term: relational_expr
888
+ | between_expr
889
+ | like_expr
890
+ | is_expr
891
+
892
+ relational_expr: ( "==" expr )
893
+ | ( "=" expr )
894
+ | ( "!=" expr )
895
+ | ( "<>" expr )
896
+ | ( ">" expr )
897
+ | ( ">=" expr )
898
+ | ( "<" expr )
899
+ | ( "<=" expr )
900
+
901
+ between_expr: "NOT"i? "BETWEEN"i expr "AND"i expr
902
+
903
+ like_expr: "NOT"i? "LIKE"i expr
904
+
905
+ is_expr: "IS"i "NOT"i? ( "NULL"i | "MISSING"i | "VALUED"i )
906
+
907
+ concatenation_term: "||" expr
908
+
909
+ logical_term: and_expr | or_expr | not_expr
910
+
911
+ and_expr: "AND"i cond
912
+
913
+ or_expr: "OR"i cond
914
+
915
+ not_expr: "NOT"i cond
916
+
917
+ case_expr: simple_case_expr | searched_case_expr
918
+
919
+ simple_case_expr: "CASE"i expr ( "WHEN"i expr "THEN"i expr )+ ( "ELSE"i expr )? "END"i
920
+
921
+ searched_case_expr: "CASE"i ( "WHEN"i cond "THEN"i expr)+ ( "ELSE"i expr )? "END"i
922
+
923
+ collection_expr: exists_expr | in_expr | within_expr | range_cond
924
+
925
+ exists_expr: "EXISTS"i expr
926
+
927
+ in_expr: "NOT"i? "IN"i expr
928
+
929
+ within_expr: "NOT?" "WITHIN"i expr
930
+
931
+ range_cond: ( ( "ANY"i | "SOME"i ) ( "AND"i "EVERY"i )? | "EVERY"i ) range_expr "SATISFIES"i cond "END"i
932
+
933
+ range_expr: ( name_var ":" )? var ( "IN"i | "WITHIN"i ) expr \
934
+ ( "," ( name_var ":" )? var ( "IN"i | "WITHIN"i ) expr )*
935
+
936
+ var: identifier_ref
937
+
938
+ name_var: identifier_ref
939
+
940
+ new_array_expr: LBRACKET ( expr ( "," expr )* )? RBRACKET
941
+
942
+ nested_expr: field_expr | element_expr | slice_expr
943
+
944
+ field_expr: "." ( identifier_ref | ( ( escaped_identifier | ( LBRACKET expr RBRACKET ) ) "i"i? ) )
945
+
946
+ element_expr: LBRACKET expr RBRACKET
947
+
948
+ slice_expr: LBRACKET expr ":" expr? RBRACKET
949
+
950
+ function_call: ( builtin_function
951
+ | ordinary_function
952
+ | aggregate_function
953
+ | window_function ) ( "." path )?
954
+
955
+ function_name: identifier_ref
956
+
957
+ aggregate_function_name: FUNCS | "TYPE"i | identifier_ref
958
+
959
+ window_function_name: FUNCS | "TYPE"i | identifier_ref
960
+
961
+ ordinary_function: function_name LPAREN ( expr ( "," expr )* )? RPAREN
962
+
963
+ builtin_function: ( FUNCS | "TYPE"i ) LPAREN ( expr ( "," expr )* )? RPAREN
964
+
965
+ aggregate_function: aggregate_function_name LPAREN \
966
+ ( ( aggregate_quantifier? expr ) | ( ( path "." )? "*" ) ) RPAREN \
967
+ filter_clause? over_clause?
968
+
969
+ aggregate_quantifier: "ALL"i | "DISTINCT"i
970
+
971
+ filter_clause: "FILTER"i LPAREN "WHERE"i cond RPAREN
972
+
973
+ window_function: window_function_name LPAREN window_function_arguments RPAREN \
974
+ window_function_options? over_clause
975
+
976
+ window_function_arguments: ( expr ("," expr ( "," expr )? )? )?
977
+
978
+ window_function_options: nthval_from? nulls_treatment?
979
+
980
+ nthval_from: "FROM"i ( "FIRST"i | "LAST"i )
981
+
982
+ nulls_treatment: ( "RESPECT"i | "IGNORE"i ) "NULLS"i
983
+
984
+ over_clause: "OVER"i ( ( LPAREN window_definition RPAREN ) | window_ref )
985
+
986
+ comment: block_comment
987
+
988
+ block_comment: "/*" ( "\r"i )* "*/"
989
+
990
+ tcl_statement: begin_transaction
991
+ | set_transaction
992
+ | savepoint_statement
993
+ | rollback_transaction
994
+ | commit_transaction
995
+
996
+ begin_transaction: ( "BEGIN"i | "START"i ) ( "WORK"i | "TRAN"i | "TRANSACTION"i ) \
997
+ ( "ISOLATION"i "LEVEL"i "READ"i "COMMITTED"i )?
998
+
999
+ set_transaction: "SET"i "TRANSACTION"i "ISOLATION"i "LEVEL"i "READ"i "COMMITTED"i
1000
+
1001
+ savepoint_statement: "SAVEPOINT"i savepointname
1002
+
1003
+ rollback_transaction: "ROLLBACK"i ( "WORK"i | "TRAN"i | "TRANSACTION"i )?
1004
+
1005
+ commit_transaction: "COMMIT"i ( "WORK"i | "TRAN"i | "TRANSACTION"i )?
1006
+
1007
+ savepointname: identifier_ref
1008
+
1009
+ utility_statement: advise_statement | explain_statement
1010
+
1011
+ advise_statement: "ADVISE"i "INDEX"i? ( select_statement
1012
+ | update_statement
1013
+ | delete_statement
1014
+ | merge_statement )
1015
+
1016
+ explain_statement: "INFER"i ( "COLLECTION"i | "KEYSPACE"i )? keyspace_ref ( "WITH"i options )?
1017
+
1018
+ infer_statement: "INFER"i ( "COLLECTION"i | "KEYSPACE"i )? keyspace_ref ( "WITH"i options )?
1019
+
1020
+ name: identifier_ref
1021
+
1022
+ parameters: array_expr
1023
+
1024
+ update_statistics: update_statistics_expr
1025
+ | update_statistics_index
1026
+ | update_statistics_delete
1027
+ | update_statistics_indexes
1028
+
1029
+ update_statistics_expr: ( ( "UPDATE"i "STATISTICS"i "FOR"i? ) | ( "ANALYZE"i ( "KEYSPACE"i | "COLLECTION"i )? ) ) \
1030
+ keyspace_ref LPAREN index_key ( "," index_key )* RPAREN index_with?
1031
+
1032
+ update_statistics_index: ( ( "UPDATEi" "STATISTICS"i "FOR"i? ) | "ANALYZE"i ) \
1033
+ index_clause index_using? index_with?
1034
+
1035
+ index_clause: "INDEX"i ( ( index_path "." index_name ) | ( index_name "ON"i keyspace_ref ) )
1036
+
1037
+ update_statistics_indexes: ( ( "UPDATE"i "STATISTICS"i "FOR"i? ) | ( "ANALYZE"i ( "KEYSPACE"i | "COLLECTION"i )? ) ) \
1038
+ keyspace_ref indexes_clause index_using? index_with?
1039
+
1040
+ indexes_clause: "INDEX"i ( ( LPAREN ( ( index_name ( "," index_name )* ) | subquery_expr ) RPAREN ) | "ALL"i )
1041
+
1042
+ update_statistics_delete: ( ( "UPDATE"i "STATISTICS"i "FOR"i? ) | ( "ANALYZE"i ( "KEYSPACE"i | "COLLECTION"i )? ) ) \
1043
+ keyspace_ref delete_clause
1044
+
1045
+ delete_clause: "DELETE"i ( delete_expr | delete_all )
1046
+
1047
+ delete_expr: "STATISTICS"i? LPAREN index_key ( "," index_key )* RPAREN
1048
+
1049
+ delete_all: "ALL"i | "STATISTICS"i
1050
+
1051
+ dcl_statement: grant_statement | revoke_statement
1052
+
1053
+ grant_statement: "GRANT"i role ( "," role )* ( "ON"i keyspace_ref ( "," keyspace_ref )* )? "TO"i user ( "," user )*
1054
+
1055
+ revoke_statement: "REVOKE"i role ( "," role )* ( "ON"i keyspace_ref ( "," keyspace_ref )* )? \
1056
+ "FROM"i user ( "," user )*
1057
+
1058
+ role: identifier_ref
1059
+
1060
+ user: identifier_ref
1061
+
1062
+ json_value: json_object | json_array
1063
+
1064
+ json_array: LBRACKET ( expr ( "," expr )* )? RBRACKET
1065
+
1066
+ json_object: LBRACE ( json_field ( "," json_field )* )? RBRACE
1067
+
1068
+ json_field: str ":" expr
1069
+
1070
+ LBRACKET: "["
1071
+ RBRACKET: "]"
1072
+ LBRACE: "{"
1073
+ RBRACE: "}"
1074
+ BACKTICK: "`"
1075
+ LPAREN: "("
1076
+ RPAREN: ")"