kaqing 2.0.184__py3-none-any.whl → 2.0.227__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.

Potentially problematic release.


This version of kaqing might be problematic. Click here for more details.

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