kaqing 2.0.98__py3-none-any.whl → 2.0.99__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.
- adam/commands/alter_tables.py +0 -7
- adam/commands/audit/audit.py +10 -3
- adam/commands/cql/cql_completions.py +5 -1
- adam/sql/sql_completer.py +31 -8
- adam/sql/state_machine.py +386 -297
- adam/utils_athena.py +4 -1
- adam/version.py +1 -1
- {kaqing-2.0.98.dist-info → kaqing-2.0.99.dist-info}/METADATA +1 -1
- {kaqing-2.0.98.dist-info → kaqing-2.0.99.dist-info}/RECORD +12 -12
- {kaqing-2.0.98.dist-info → kaqing-2.0.99.dist-info}/WHEEL +0 -0
- {kaqing-2.0.98.dist-info → kaqing-2.0.99.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.98.dist-info → kaqing-2.0.99.dist-info}/top_level.txt +0 -0
adam/commands/alter_tables.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
2
|
from adam.commands.cql.cql_utils import tables as get_tables, run_cql
|
|
3
3
|
from adam.config import Config
|
|
4
|
-
from adam.pod_exec_result import PodExecResult
|
|
5
4
|
from adam.repl_state import ReplState, RequiredState
|
|
6
5
|
from adam.utils import log2
|
|
7
6
|
|
|
@@ -80,12 +79,6 @@ class AlterTables(Command):
|
|
|
80
79
|
return state
|
|
81
80
|
|
|
82
81
|
def completion(self, state: ReplState) -> dict[str, any]:
|
|
83
|
-
if state.sts:
|
|
84
|
-
ps = Config().get('cql.alter-tables.gc-grace-periods', '3600,86400,864000,7776000').split(',')
|
|
85
|
-
return super().completion(state, {
|
|
86
|
-
'GC_GRACE_SECONDS': {'=': {p.strip(' \r\n'): {'--include-reaper': None} for p in ps}},
|
|
87
|
-
})
|
|
88
|
-
|
|
89
82
|
return {}
|
|
90
83
|
|
|
91
84
|
def help(self, _: ReplState) -> str:
|
adam/commands/audit/audit.py
CHANGED
|
@@ -50,12 +50,19 @@ class Audit(Command):
|
|
|
50
50
|
if not self.schema_read:
|
|
51
51
|
Config().wait_log(f'Inspecting audit database schema...')
|
|
52
52
|
self.schema_read = True
|
|
53
|
+
# warm up the caches first time when l: drive is accessed
|
|
53
54
|
audit_column_names()
|
|
55
|
+
audit_column_names(partition_cols_only=True)
|
|
54
56
|
|
|
55
|
-
def columns(_):
|
|
56
|
-
|
|
57
|
+
# def columns(_):
|
|
58
|
+
# return audit_column_names()
|
|
57
59
|
|
|
58
|
-
return super().completion(state) | SqlCompleter.completions(
|
|
60
|
+
return super().completion(state) | SqlCompleter.completions(
|
|
61
|
+
lambda: audit_table_names(),
|
|
62
|
+
columns=lambda table: audit_column_names(),
|
|
63
|
+
partition_columns=lambda table: audit_column_names(partition_cols_only=True),
|
|
64
|
+
variant='athena'
|
|
65
|
+
) | {
|
|
59
66
|
'desc': {table: None for table in audit_table_names()}}
|
|
60
67
|
|
|
61
68
|
return {}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
from adam.commands.cql.cql_utils import table_names
|
|
2
|
+
from adam.config import Config
|
|
2
3
|
from adam.repl_state import ReplState
|
|
3
4
|
from adam.sql.sql_completer import SqlCompleter
|
|
4
5
|
|
|
5
6
|
def cql_completions(state: ReplState) -> dict[str, any]:
|
|
7
|
+
ps = Config().get('cql.alter-tables.gc-grace-periods', '3600,86400,864000,7776000').split(',')
|
|
6
8
|
return {
|
|
7
9
|
'describe': {
|
|
8
10
|
'keyspaces': None,
|
|
9
11
|
'table': {t: None for t in table_names(state)},
|
|
10
12
|
'tables': None},
|
|
11
|
-
} | SqlCompleter.completions(lambda: table_names(state)
|
|
13
|
+
} | SqlCompleter.completions(lambda: table_names(state), table_props=lambda: {
|
|
14
|
+
'GC_GRACE_SECONDS': ps
|
|
15
|
+
}, variant='cql')
|
adam/sql/sql_completer.py
CHANGED
|
@@ -11,19 +11,28 @@ __all__ = [
|
|
|
11
11
|
"SqlCompleter",
|
|
12
12
|
]
|
|
13
13
|
|
|
14
|
-
DML_COMPLETER = TermCompleter(['select', 'insert', 'delete', 'update'])
|
|
14
|
+
DML_COMPLETER = TermCompleter(['select', 'insert', 'delete', 'update', 'alter'])
|
|
15
15
|
|
|
16
16
|
def default_columns(tables: list[str]):
|
|
17
17
|
return 'id,x.,y.,z.'.split(',')
|
|
18
18
|
|
|
19
19
|
class SqlCompleter(Completer):
|
|
20
|
-
def __init__(self,
|
|
20
|
+
def __init__(self,
|
|
21
|
+
tables: Callable[[], list[str]],
|
|
22
|
+
dml: str = None,
|
|
23
|
+
columns: Callable[[list[str]], list[str]] = default_columns,
|
|
24
|
+
partition_columns: Callable[[list[str]], list[str]] = lambda x: [],
|
|
25
|
+
table_props: Callable[[], dict[str,list[str]]] = lambda: [],
|
|
26
|
+
variant = 'sql',
|
|
27
|
+
debug = False):
|
|
21
28
|
super().__init__()
|
|
22
29
|
self.dml = dml
|
|
23
30
|
self.tables = tables
|
|
24
31
|
self.columns = columns
|
|
32
|
+
self.partition_columns = partition_columns
|
|
33
|
+
self.table_props = table_props
|
|
25
34
|
self.debug = debug
|
|
26
|
-
self.machine = StateMachine(debug=self.debug)
|
|
35
|
+
self.machine = StateMachine(variant=variant, debug=self.debug)
|
|
27
36
|
|
|
28
37
|
def get_completions(
|
|
29
38
|
self, document: Document, complete_event: CompleteEvent
|
|
@@ -53,8 +62,17 @@ class SqlCompleter(Completer):
|
|
|
53
62
|
for word in self.machine.suggestions[state.to_s].strip(' ').split(','):
|
|
54
63
|
if word == 'tables':
|
|
55
64
|
terms.extend(self.tables())
|
|
65
|
+
elif word == '`tables`':
|
|
66
|
+
terms.append('tables')
|
|
56
67
|
elif word == 'columns':
|
|
57
68
|
terms.extend(self.columns([]))
|
|
69
|
+
elif word == 'partition-columns':
|
|
70
|
+
terms.extend(self.partition_columns([]))
|
|
71
|
+
elif word == 'table-props':
|
|
72
|
+
terms.extend(self.table_props().keys())
|
|
73
|
+
elif word == 'table-prop-values':
|
|
74
|
+
if 'last_name' in state.context and state.context['last_name']:
|
|
75
|
+
terms.extend(self.table_props()[state.context['last_name']])
|
|
58
76
|
elif word == 'single':
|
|
59
77
|
terms.append("'")
|
|
60
78
|
elif word == 'comma':
|
|
@@ -69,10 +87,15 @@ class SqlCompleter(Completer):
|
|
|
69
87
|
for c in completer.get_completions(document, complete_event):
|
|
70
88
|
yield c
|
|
71
89
|
|
|
72
|
-
def completions(table_names: Callable[[], list[str]],
|
|
90
|
+
def completions(table_names: Callable[[], list[str]],
|
|
91
|
+
columns: Callable[[list[str]], list[str]] = default_columns,
|
|
92
|
+
partition_columns: Callable[[list[str]], list[str]] = lambda x: [],
|
|
93
|
+
table_props: Callable[[], dict[str, list[str]]] = lambda: [],
|
|
94
|
+
variant = 'sql'):
|
|
73
95
|
return {
|
|
74
|
-
'delete': SqlCompleter(table_names, 'delete', columns=columns),
|
|
75
|
-
'insert': SqlCompleter(table_names, 'insert', columns=columns),
|
|
76
|
-
'select': SqlCompleter(table_names, 'select', columns=columns),
|
|
77
|
-
'update': SqlCompleter(table_names, 'update', columns=columns),
|
|
96
|
+
'delete': SqlCompleter(table_names, 'delete', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
97
|
+
'insert': SqlCompleter(table_names, 'insert', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
98
|
+
'select': SqlCompleter(table_names, 'select', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
99
|
+
'update': SqlCompleter(table_names, 'update', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
100
|
+
'alter': SqlCompleter(table_names, 'alter', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
78
101
|
}
|
adam/sql/state_machine.py
CHANGED
|
@@ -1,126 +1,3 @@
|
|
|
1
|
-
# <select_statement> ::= SELECT <select_list>
|
|
2
|
-
# FROM <table_expression>
|
|
3
|
-
# [WHERE <search_condition>]
|
|
4
|
-
# [<group_by_clause>]
|
|
5
|
-
# [<having_clause>]
|
|
6
|
-
# [<order_by_clause>]
|
|
7
|
-
# [<limit_clause>]
|
|
8
|
-
|
|
9
|
-
# <search_condition> ::= <boolean_term>
|
|
10
|
-
# | <search_condition> OR <boolean_term>
|
|
11
|
-
|
|
12
|
-
# <boolean_term> ::= <boolean_factor>
|
|
13
|
-
# | <boolean_term> AND <boolean_factor>
|
|
14
|
-
|
|
15
|
-
# <boolean_factor> ::= [NOT] <predicate>
|
|
16
|
-
# | ([NOT] <search_condition>)
|
|
17
|
-
|
|
18
|
-
# <predicate> ::= <comparison_predicate>
|
|
19
|
-
# | <between_predicate>
|
|
20
|
-
# | <in_predicate>
|
|
21
|
-
# | <like_predicate>
|
|
22
|
-
# | <null_predicate>
|
|
23
|
-
# | <exists_predicate>
|
|
24
|
-
# | <quantified_predicate>
|
|
25
|
-
# | <unique_predicate>
|
|
26
|
-
# | <match_predicate>
|
|
27
|
-
# | <overlaps_predicate>
|
|
28
|
-
# | <distinct_predicate>
|
|
29
|
-
# | <member_predicate>
|
|
30
|
-
# | <submultiset_predicate>
|
|
31
|
-
# | <set_predicate>
|
|
32
|
-
|
|
33
|
-
# <comparison_predicate> ::= <row_value_expression> <comparison_operator> <row_value_expression>
|
|
34
|
-
# <comparison_operator> ::= '=' | '<>' | '<' | '<=' | '>' | '>='
|
|
35
|
-
|
|
36
|
-
# <row_value_expression> ::= <value_expression>
|
|
37
|
-
# | (<value_expression> [ { <comma> <value_expression> }... ])
|
|
38
|
-
|
|
39
|
-
# <value_expression> ::= <numeric_value_expression>
|
|
40
|
-
# | <string_value_expression>
|
|
41
|
-
# | <datetime_value_expression>
|
|
42
|
-
# | <interval_value_expression>
|
|
43
|
-
# | <boolean_value_expression>
|
|
44
|
-
# | <user_defined_type_value_expression>
|
|
45
|
-
# | <reference_value_expression>
|
|
46
|
-
# | <collection_value_expression>
|
|
47
|
-
# | <row_value_constructor>
|
|
48
|
-
# | <case_expression>
|
|
49
|
-
# | <cast_expression>
|
|
50
|
-
# | <subquery>
|
|
51
|
-
# | NULL
|
|
52
|
-
# | DEFAULT
|
|
53
|
-
# | <identifier>
|
|
54
|
-
# | <literal>
|
|
55
|
-
|
|
56
|
-
# <insert_statement> ::= INSERT INTO <table_name> [ ( <column_list> ) ]
|
|
57
|
-
# VALUES ( <value_list> )
|
|
58
|
-
# | INSERT INTO <table_name> [ ( <column_list> ) ]
|
|
59
|
-
# <query_expression>
|
|
60
|
-
|
|
61
|
-
# <table_name> ::= <identifier>
|
|
62
|
-
|
|
63
|
-
# <column_list> ::= <column_name> [ , <column_list> ]
|
|
64
|
-
|
|
65
|
-
# <column_name> ::= <identifier>
|
|
66
|
-
|
|
67
|
-
# <value_list> ::= <expression> [ , <value_list> ]
|
|
68
|
-
|
|
69
|
-
# <query_expression> ::= SELECT <select_list> FROM <table_reference_list> [ WHERE <search_condition> ] [ GROUP BY <grouping_column_list> ] [ HAVING <search_condition> ] [ ORDER BY <sort_specification_list> ]
|
|
70
|
-
|
|
71
|
-
# <update_statement> ::= UPDATE <table_name>
|
|
72
|
-
# SET <set_clause_list>
|
|
73
|
-
# [WHERE <search_condition>]
|
|
74
|
-
|
|
75
|
-
# <set_clause_list> ::= <set_clause> { , <set_clause> }
|
|
76
|
-
|
|
77
|
-
# <set_clause> ::= <column_name> = <update_value>
|
|
78
|
-
|
|
79
|
-
# <update_value> ::= <expression> | NULL | DEFAULT
|
|
80
|
-
|
|
81
|
-
# <search_condition> ::= <boolean_expression>
|
|
82
|
-
|
|
83
|
-
# <delete_statement> ::= DELETE FROM <table_name> [ WHERE <search_condition> ]
|
|
84
|
-
|
|
85
|
-
# <table_name> ::= <identifier>
|
|
86
|
-
|
|
87
|
-
# <search_condition> ::= <boolean_expression>
|
|
88
|
-
|
|
89
|
-
# <boolean_expression> ::= <predicate>
|
|
90
|
-
# | <boolean_expression> AND <predicate>
|
|
91
|
-
# | <boolean_expression> OR <predicate>
|
|
92
|
-
# | NOT <predicate>
|
|
93
|
-
# | ( <boolean_expression> )
|
|
94
|
-
|
|
95
|
-
# <predicate> ::= <expression> <comparison_operator> <expression>
|
|
96
|
-
# | <expression> IS NULL
|
|
97
|
-
# | <expression> IS NOT NULL
|
|
98
|
-
# | <expression> LIKE <pattern> [ ESCAPE <escape_character> ]
|
|
99
|
-
# | <expression> IN ( <expression_list> )
|
|
100
|
-
# | EXISTS ( <select_statement> )
|
|
101
|
-
# | ... (other predicates)
|
|
102
|
-
|
|
103
|
-
# <comparison_operator> ::= = | <> | != | > | < | >= | <=
|
|
104
|
-
|
|
105
|
-
# <expression> ::= <literal>
|
|
106
|
-
# | <column_name>
|
|
107
|
-
# | <function_call>
|
|
108
|
-
# | ( <expression> )
|
|
109
|
-
# | <expression> <arithmetic_operator> <expression>
|
|
110
|
-
# | ... (other expressions)
|
|
111
|
-
|
|
112
|
-
# <literal> ::= <numeric_literal> | <string_literal> | <boolean_literal> | <date_literal> | ...
|
|
113
|
-
|
|
114
|
-
# <column_name> ::= <identifier>
|
|
115
|
-
|
|
116
|
-
# <identifier> ::= <letter> { <letter> | <digit> | _ }...
|
|
117
|
-
|
|
118
|
-
# <pattern> ::= <string_literal>
|
|
119
|
-
|
|
120
|
-
# <escape_character> ::= <string_literal> (single character)
|
|
121
|
-
|
|
122
|
-
# <expression_list> ::= <expression> { , <expression> }...
|
|
123
|
-
|
|
124
1
|
from sqlparse.sql import Token
|
|
125
2
|
from sqlparse import tokens as T
|
|
126
3
|
|
|
@@ -128,186 +5,393 @@ __all__ = [
|
|
|
128
5
|
"StateMachine",
|
|
129
6
|
]
|
|
130
7
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
]
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
]
|
|
8
|
+
class SqlSpec:
|
|
9
|
+
SPEC = [
|
|
10
|
+
# <select_statement> ::= SELECT <select_list>
|
|
11
|
+
# FROM <table_expression>
|
|
12
|
+
# [WHERE <search_condition>]
|
|
13
|
+
# [<group_by_clause>]
|
|
14
|
+
# [<having_clause>]
|
|
15
|
+
# [<order_by_clause>]
|
|
16
|
+
# [<limit_clause>]
|
|
17
|
+
|
|
18
|
+
# <search_condition> ::= <boolean_term>
|
|
19
|
+
# | <search_condition> OR <boolean_term>
|
|
20
|
+
|
|
21
|
+
# <boolean_term> ::= <boolean_factor>
|
|
22
|
+
# | <boolean_term> AND <boolean_factor>
|
|
23
|
+
|
|
24
|
+
# <boolean_factor> ::= [NOT] <predicate>
|
|
25
|
+
# | ([NOT] <search_condition>)
|
|
26
|
+
|
|
27
|
+
# <predicate> ::= <comparison_predicate>
|
|
28
|
+
# | <between_predicate>
|
|
29
|
+
# | <in_predicate>
|
|
30
|
+
# | <like_predicate>
|
|
31
|
+
# | <null_predicate>
|
|
32
|
+
# | <exists_predicate>
|
|
33
|
+
# | <quantified_predicate>
|
|
34
|
+
# | <unique_predicate>
|
|
35
|
+
# | <match_predicate>
|
|
36
|
+
# | <overlaps_predicate>
|
|
37
|
+
# | <distinct_predicate>
|
|
38
|
+
# | <member_predicate>
|
|
39
|
+
# | <submultiset_predicate>
|
|
40
|
+
# | <set_predicate>
|
|
41
|
+
|
|
42
|
+
# <comparison_predicate> ::= <row_value_expression> <comparison_operator> <row_value_expression>
|
|
43
|
+
# <comparison_operator> ::= '=' | '<>' | '<' | '<=' | '>' | '>='
|
|
44
|
+
|
|
45
|
+
# <row_value_expression> ::= <value_expression>
|
|
46
|
+
# | (<value_expression> [ { <comma> <value_expression> }... ])
|
|
47
|
+
|
|
48
|
+
# <value_expression> ::= <numeric_value_expression>
|
|
49
|
+
# | <string_value_expression>
|
|
50
|
+
# | <datetime_value_expression>
|
|
51
|
+
# | <interval_value_expression>
|
|
52
|
+
# | <boolean_value_expression>
|
|
53
|
+
# | <user_defined_type_value_expression>
|
|
54
|
+
# | <reference_value_expression>
|
|
55
|
+
# | <collection_value_expression>
|
|
56
|
+
# | <row_value_constructor>
|
|
57
|
+
# | <case_expression>
|
|
58
|
+
# | <cast_expression>
|
|
59
|
+
# | <subquery>
|
|
60
|
+
# | NULL
|
|
61
|
+
# | DEFAULT
|
|
62
|
+
# | <identifier>
|
|
63
|
+
# | <literal>
|
|
64
|
+
' > select > select',
|
|
65
|
+
'select_ > name|* > select_a ^ *',
|
|
66
|
+
'select_a > , > select_a_comma_',
|
|
67
|
+
'select_a_comma_ > name|* > select_a ^ *',
|
|
68
|
+
'select_a_ > from > select_from ^ from',
|
|
69
|
+
'select_from_ > name|audit > select_from_x ^ (select,tables',
|
|
70
|
+
'- > ( > select_from_lp_',
|
|
71
|
+
'- < ) > select_from_sq',
|
|
72
|
+
'select_from_lp_ > select > select',
|
|
73
|
+
'select_from_x > , > select_from_x_comma_ ^ (select,tables',
|
|
74
|
+
'select_from_sq_ > as > select_from_x_as ^ as',
|
|
75
|
+
'select_from_x_comma_ > name > select_from_x ^ tables',
|
|
76
|
+
'select_from_x_ ^ as,where,inner join,left outer join,right outer join,full outer join,group by,order by,limit',
|
|
77
|
+
'select_from_x_as_x_ > , > select_from_x_comma_ ^ where,inner join,left outer join,right outer join,full outer join,group by,order by,limit',
|
|
78
|
+
'- > as > select_from_x_as',
|
|
79
|
+
'- > where > select_where',
|
|
80
|
+
'- > order > select_order',
|
|
81
|
+
'- > order by > select_order_by',
|
|
82
|
+
'- > limit > select_where_sc_limit',
|
|
83
|
+
'- > group > select_group',
|
|
84
|
+
'- > group by > select_group_by',
|
|
85
|
+
'- > inner > select_from_x_inner',
|
|
86
|
+
'- > inner join > select_join',
|
|
87
|
+
'- > left > select_from_x_left',
|
|
88
|
+
'- > left join > select_join',
|
|
89
|
+
'- > left outer join > select_join',
|
|
90
|
+
'- > right > select_from_x_right',
|
|
91
|
+
'- > right join > select_join',
|
|
92
|
+
'- > right outer join > select_join',
|
|
93
|
+
'- > full > select_from_x_full',
|
|
94
|
+
'- > full outer join > select_join',
|
|
95
|
+
'select_from_x_as_ > name > select_from_x_as_x ^ x,y,z',
|
|
96
|
+
'select_from_x_as_x > , > select_from_x_as_x_comma_',
|
|
97
|
+
'select_from_x_as_x_comma_ > name > select_from_x ^ tables',
|
|
98
|
+
'select_where_ > name > select_where_a ^ columns',
|
|
99
|
+
'select_where_a > name > select_where_a ^ columns,=,<,<=,>,>=,<>',
|
|
100
|
+
'- > comparison > select_where_a_op',
|
|
101
|
+
'select_where_a_ > comparison > select_where_a_op ^ =,<,<=,>,>=,<>,like,not,in',
|
|
102
|
+
'- > not > select_where_a_not',
|
|
103
|
+
'- > in > select_where_a_in',
|
|
104
|
+
'select_where_a_not_ > comparison > select_where_a_not_op ^ like,in',
|
|
105
|
+
'- > in > select_where_a_in',
|
|
106
|
+
'select_where_a_in > ( > select_where_a_in_lp_ ^ (',
|
|
107
|
+
'- < ) > select_where_sc',
|
|
108
|
+
'select_where_a_in_lp_ > name|single|num > select_where_a_in_lp_a ^ single,select',
|
|
109
|
+
'- > select > select_where_a_in_lp_select',
|
|
110
|
+
'select_where_a_in_lp_select_ > name > select_a ^ id',
|
|
111
|
+
'select_where_a_in_lp_a > , > select_where_a_in_lp_a_comma_ ^ comma,)',
|
|
112
|
+
'select_where_a_in_lp_a_comma_ > name|single|num > select_where_a_in_lp_a ^ single',
|
|
113
|
+
'select_where_a_not_op > name|single|num > select_where_sc ^ single',
|
|
114
|
+
'select_where_a_op > name|single|num > select_where_sc ^ single',
|
|
115
|
+
'select_where_sc_ > and|or > select_where ^ and,or,order by,group by,limit',
|
|
116
|
+
'- > group > select_group',
|
|
117
|
+
'- > group by > select_group_by',
|
|
118
|
+
'- > order > select_order',
|
|
119
|
+
'- > order by > select_order_by',
|
|
120
|
+
'- > limit > select_where_sc_limit',
|
|
121
|
+
'select_group_ > by > select_group_by ^ by',
|
|
122
|
+
'select_group_by_ > name > select_group_by_a ^ columns',
|
|
123
|
+
'select_group_by_a > name > select_group_by_a ^ columns',
|
|
124
|
+
'- > , > select_group_by_a_comma_ ^ columns',
|
|
125
|
+
'select_group_by_a_comma_ > name > select_group_by_a ^ columns',
|
|
126
|
+
'select_group_by_a_ > limit > select_where_sc_limit ^ limit,order by',
|
|
127
|
+
'- > order > select_order',
|
|
128
|
+
'- > order by > select_order_by',
|
|
129
|
+
'select_order_ > by > select_order_by ^ by',
|
|
130
|
+
'select_order_by_ > name > select_order_by_a ^ columns',
|
|
131
|
+
'select_order_by_a > name > select_order_by_a ^ columns',
|
|
132
|
+
'- > , > select_order_by_a_comma_',
|
|
133
|
+
'select_order_by_a_comma_ > name > select_order_by_a ^ columns',
|
|
134
|
+
'select_order_by_a_ > desc|asc > select_order_by_a_desc ^ desc,asc,limit',
|
|
135
|
+
'- > limit > select_where_sc_limit',
|
|
136
|
+
'select_order_by_a_desc > , > select_order_by_a_comma_',
|
|
137
|
+
'select_order_by_a_desc_ > limit > select_where_sc_limit ^ limit',
|
|
138
|
+
'select_where_sc_limit_ > num > select_where_sc_limit_num ^ 1',
|
|
139
|
+
'select_where_sc_limit_num_rp__ > as > select_from_x_as ^ as',
|
|
140
|
+
'select_where_x_inner_ > join > select_join',
|
|
141
|
+
'select_join_ > name > select_x_join_y ^ tables',
|
|
142
|
+
'select_from_x_left_ > join > select_join ^ outer join',
|
|
143
|
+
'- > outer > select_from_x_left_outer',
|
|
144
|
+
'select_from_x_left_outer_ > join > select_join ^ join',
|
|
145
|
+
'select_from_x_right_ > join > select_join ^ outer join',
|
|
146
|
+
'- > outer > select_from_x_right_outer',
|
|
147
|
+
'select_from_x_right_outer_ > join > select_join ^ join',
|
|
148
|
+
'select_from_x_full_ > join > select_join ^ outer join',
|
|
149
|
+
'- > outer > select_from_x_full_outer',
|
|
150
|
+
'select_from_x_full_outer_ > join > select_join ^ join',
|
|
151
|
+
'select_x_join_y > name > select_x_join_y ^ tables',
|
|
152
|
+
'select_x_join_y_ > as > select_x_join_y_as ^ as,on',
|
|
153
|
+
'- > on > select_x_join_y_on ^ as,on',
|
|
154
|
+
'select_x_join_y_as_ > name > select_x_join_y_as_y ^ x,y,z',
|
|
155
|
+
'select_x_join_y_as_y_ > on > select_x_join_y_on ^ on',
|
|
156
|
+
'select_x_join_y_on_ > name > select_x_join_y_on_a ^ columns',
|
|
157
|
+
'select_x_join_y_on_a > name > select_x_join_y_on_a ^ columns,=',
|
|
158
|
+
'- > comparison > select_x_join_y_on_a_op',
|
|
159
|
+
'select_x_join_y_on_a_ > comparison > select_x_join_y_on_a_op ^ =',
|
|
160
|
+
'select_x_join_y_on_a_op > name > select_x_join_y_on_a_op_b ^ columns',
|
|
161
|
+
'select_x_join_y_on_a_op_b > name > select_x_join_y_on_a_op_b ^ columns',
|
|
162
|
+
'- > _ > select_from_x_as_x_',
|
|
163
|
+
|
|
164
|
+
# <insert_statement> ::= INSERT INTO <table_name> [ ( <column_list> ) ]
|
|
165
|
+
# VALUES ( <value_list> )
|
|
166
|
+
# | INSERT INTO <table_name> [ ( <column_list> ) ]
|
|
167
|
+
# <query_expression>
|
|
168
|
+
|
|
169
|
+
# <table_name> ::= <identifier>
|
|
170
|
+
|
|
171
|
+
# <column_list> ::= <column_name> [ , <column_list> ]
|
|
172
|
+
|
|
173
|
+
# <column_name> ::= <identifier>
|
|
174
|
+
|
|
175
|
+
# <value_list> ::= <expression> [ , <value_list> ]
|
|
176
|
+
|
|
177
|
+
# <query_expression> ::= SELECT <select_list> FROM <table_reference_list> [ WHERE <search_condition> ] [ GROUP BY <grouping_column_list> ] [ HAVING <search_condition> ] [ ORDER BY <sort_specification_list> ]
|
|
178
|
+
' > insert > insert',
|
|
179
|
+
'insert_ > into > insert_into ^ into',
|
|
180
|
+
'insert_into_ > name > insert_into_x ^ tables',
|
|
181
|
+
'insert_into_x > name > insert_into_x ^ tables',
|
|
182
|
+
'- > ( > insert_into_x_lp_',
|
|
183
|
+
'insert_into_x_ > ( > insert_into_x_lp_ ^ (,values(',
|
|
184
|
+
'- > values > insert_values',
|
|
185
|
+
'insert_into_x_lp_ > name > insert_into_x_lp_a ^ id',
|
|
186
|
+
'insert_into_x_lp_a > , > insert_into_x_lp_a_comma_',
|
|
187
|
+
'- > ) > insert_into_x_lp_a_rp_',
|
|
188
|
+
'insert_into_x_lp_a_comma_ > name > insert_into_x_lp_a ^ id',
|
|
189
|
+
'insert_into_x_lp_a_rp__ > values > insert_values ^ values(,select',
|
|
190
|
+
'- > select > select',
|
|
191
|
+
'insert_values > ( > insert_values_lp_',
|
|
192
|
+
'insert_values_lp_ > name|single|num > insert_values_lp_v ^ single',
|
|
193
|
+
'insert_values_lp_v > , > insert_values_lp_v_comma_',
|
|
194
|
+
'insert_values_lp_v_comma_ > name|single|num > insert_values_lp_v',
|
|
195
|
+
|
|
196
|
+
# <update_statement> ::= UPDATE <table_name>
|
|
197
|
+
# SET <set_clause_list>
|
|
198
|
+
# [WHERE <search_condition>]
|
|
199
|
+
|
|
200
|
+
# <set_clause_list> ::= <set_clause> { , <set_clause> }
|
|
201
|
+
|
|
202
|
+
# <set_clause> ::= <column_name> = <update_value>
|
|
203
|
+
|
|
204
|
+
# <update_value> ::= <expression> | NULL | DEFAULT
|
|
205
|
+
|
|
206
|
+
# <search_condition> ::= <boolean_expression>
|
|
207
|
+
' > update > update',
|
|
208
|
+
'update_ > name > update_x ^ tables',
|
|
209
|
+
'update_x > name > update_x ^ tables',
|
|
210
|
+
'update_x_ > set > update_set ^ set',
|
|
211
|
+
'update_set_ > name > update_set_a ^ id',
|
|
212
|
+
'update_set_a > comparison > update_set_a_op',
|
|
213
|
+
'update_set_a_op > name|single|num > update_set_sc ^ single',
|
|
214
|
+
'update_set_sc > , > update_set_sc_comma_',
|
|
215
|
+
'update_set_sc_comma_ > name > update_set_a ^ id',
|
|
216
|
+
'update_set_sc_ > , > update_set_sc_comma_ ^ where',
|
|
217
|
+
'- > where > update_where',
|
|
218
|
+
'update_where_ > name > update_where_a ^ id',
|
|
219
|
+
'update_where_a > comparison > update_where_a_op',
|
|
220
|
+
'update_where_a_ > comparison > update_where_a_op ^ =,<,<=,>,>=,<>,like,not,in',
|
|
221
|
+
'- > not > update_where_a_not',
|
|
222
|
+
'- > in > update_where_a_in',
|
|
223
|
+
'update_where_a_not_ > comparison > update_where_a_not_op ^ like,in',
|
|
224
|
+
'- > in > update_where_a_in',
|
|
225
|
+
'update_where_a_in > ( > update_where_a_in_lp_ ^ (',
|
|
226
|
+
'- < ) > update_where_sc',
|
|
227
|
+
'update_where_a_in_lp_ > name|single|num > update_where_a_in_lp_a ^ single,select',
|
|
228
|
+
'- > select > update_where_a_in_lp_select',
|
|
229
|
+
'update_where_a_in_lp_select_ > name > select_a ^ id',
|
|
230
|
+
'update_where_a_in_lp_a > , > update_where_a_in_lp_a_comma_ ^ comma,)',
|
|
231
|
+
'update_where_a_in_lp_a_comma_ > name|single|num > update_where_a_in_lp_a ^ single',
|
|
232
|
+
'update_where_a_not_op > name|single|num > update_where_sc ^ single',
|
|
233
|
+
'update_where_a_op > name|single|num > update_where_sc ^ single',
|
|
234
|
+
'update_where_sc_ > and|or > update_where ^ and,or',
|
|
235
|
+
|
|
236
|
+
# <delete_statement> ::= DELETE FROM <table_name> [ WHERE <search_condition> ]
|
|
237
|
+
|
|
238
|
+
# <table_name> ::= <identifier>
|
|
239
|
+
|
|
240
|
+
# <search_condition> ::= <boolean_expression>
|
|
241
|
+
|
|
242
|
+
# <boolean_expression> ::= <predicate>
|
|
243
|
+
# | <boolean_expression> AND <predicate>
|
|
244
|
+
# | <boolean_expression> OR <predicate>
|
|
245
|
+
# | NOT <predicate>
|
|
246
|
+
# | ( <boolean_expression> )
|
|
247
|
+
|
|
248
|
+
# <predicate> ::= <expression> <comparison_operator> <expression>
|
|
249
|
+
# | <expression> IS NULL
|
|
250
|
+
# | <expression> IS NOT NULL
|
|
251
|
+
# | <expression> LIKE <pattern> [ ESCAPE <escape_character> ]
|
|
252
|
+
# | <expression> IN ( <expression_list> )
|
|
253
|
+
# | EXISTS ( <select_statement> )
|
|
254
|
+
# | ... (other predicates)
|
|
255
|
+
|
|
256
|
+
# <comparison_operator> ::= = | <> | != | > | < | >= | <=
|
|
257
|
+
|
|
258
|
+
# <expression> ::= <literal>
|
|
259
|
+
# | <column_name>
|
|
260
|
+
# | <function_call>
|
|
261
|
+
# | ( <expression> )
|
|
262
|
+
# | <expression> <arithmetic_operator> <expression>
|
|
263
|
+
# | ... (other expressions)
|
|
264
|
+
|
|
265
|
+
# <literal> ::= <numeric_literal> | <string_literal> | <boolean_literal> | <date_literal> | ...
|
|
266
|
+
|
|
267
|
+
# <column_name> ::= <identifier>
|
|
268
|
+
|
|
269
|
+
# <identifier> ::= <letter> { <letter> | <digit> | _ }...
|
|
270
|
+
|
|
271
|
+
# <pattern> ::= <string_literal>
|
|
272
|
+
|
|
273
|
+
# <escape_character> ::= <string_literal> (single character)
|
|
274
|
+
|
|
275
|
+
# <expression_list> ::= <expression> { , <expression> }...
|
|
276
|
+
' > delete > delete',
|
|
277
|
+
'delete_ > from > delete_from ^ from',
|
|
278
|
+
'delete_from_ > name > delete_from_x ^ tables',
|
|
279
|
+
'delete_from_x > name > delete_from_x ^ tables',
|
|
280
|
+
'delete_from_x_ > where > update_where ^ where',
|
|
281
|
+
|
|
282
|
+
# <alter table action> ::=
|
|
283
|
+
# ADD <column definition>
|
|
284
|
+
# | DROP COLUMN <column name>
|
|
285
|
+
# | MODIFY COLUMN <column name> <column modification>
|
|
286
|
+
# | RENAME TO <new table name>
|
|
287
|
+
# | ADD CONSTRAINT <constraint definition>
|
|
288
|
+
# | DROP CONSTRAINT <constraint name>
|
|
289
|
+
# | ... (other actions like adding/dropping indexes, partitions, etc.)
|
|
290
|
+
|
|
291
|
+
# <column definition> ::= <column name> <data type> [ <column constraint> ... ]
|
|
292
|
+
|
|
293
|
+
# <column modification> ::=
|
|
294
|
+
# SET DATA TYPE <data type>
|
|
295
|
+
# | SET DEFAULT <expression>
|
|
296
|
+
# | DROP DEFAULT
|
|
297
|
+
# | SET NOT NULL
|
|
298
|
+
# | DROP NOT NULL
|
|
299
|
+
# | ...
|
|
300
|
+
|
|
301
|
+
# <constraint definition> ::=
|
|
302
|
+
# PRIMARY KEY ( <column name list> )
|
|
303
|
+
# | UNIQUE ( <column name list> )
|
|
304
|
+
# | FOREIGN KEY ( <column name list> ) REFERENCES <referenced table> ( <referenced column list> )
|
|
305
|
+
# | CHECK ( <search condition> )
|
|
306
|
+
|
|
307
|
+
' > alter > alter',
|
|
308
|
+
'alter_ > table > alter_table ^ table',
|
|
309
|
+
'alter_table_ > name|audit > alter_table_t ^ tables',
|
|
310
|
+
'alter_table_t > name|audit > alter_table_t ^ tables',
|
|
311
|
+
'alter_table_t_ > add > alter_table_add ^ add,add constraint,drop column,drop constraint,rename to',
|
|
312
|
+
'- > drop > alter_table_drop',
|
|
313
|
+
]
|
|
314
|
+
|
|
315
|
+
KEYWORDS = [
|
|
316
|
+
'select', 'from', 'as', 'not', 'in', 'where',
|
|
317
|
+
'and', 'or', 'group', 'by', 'group by', 'order', 'order by', 'limit', 'asc', 'desc',
|
|
318
|
+
'inner join', 'on', 'left', 'right', 'full', 'outer', 'left outer join',
|
|
319
|
+
'left join', 'right outer join', 'right join', 'full join', 'full outer join',
|
|
320
|
+
'insert', 'into', 'values',
|
|
321
|
+
'update', 'where', 'set',
|
|
322
|
+
'delete',
|
|
323
|
+
'audit',
|
|
324
|
+
'alter', 'table', 'tables', 'add', 'drop', 'with'
|
|
325
|
+
]
|
|
326
|
+
|
|
327
|
+
def spec(self):
|
|
328
|
+
return SqlSpec.SPEC
|
|
329
|
+
|
|
330
|
+
def keywords(self):
|
|
331
|
+
return SqlSpec.KEYWORDS
|
|
332
|
+
|
|
333
|
+
class CqlSpec(SqlSpec):
|
|
334
|
+
SPEC = SqlSpec.SPEC + [
|
|
335
|
+
# ALTER TABLE [ <keyspace_name> . ] <table_name>
|
|
336
|
+
# ( ALTER <column_name> TYPE <cql_type>
|
|
337
|
+
# | ADD ( <column_definition_list> )
|
|
338
|
+
# | DROP ( <column_list> )
|
|
339
|
+
# | RENAME <column_name> TO <column_name> [ AND <column_name> TO <column_name> ... ]
|
|
340
|
+
# | WITH <table_properties> );
|
|
341
|
+
|
|
342
|
+
'alter_ > table > alter_table ^ table,`tables`',
|
|
343
|
+
'- > tables > alter_tables',
|
|
344
|
+
'alter_tables_ > with > alter_table_with ^ with',
|
|
345
|
+
'alter_table_t_ > with > alter_table_with ^ with,add,drop',
|
|
346
|
+
'alter_table_with_ > name > alter_table_with_p ^ table-props',
|
|
347
|
+
'alter_table_with_p > comparison > alter_table_with_p_op ^ =',
|
|
348
|
+
'alter_table_with_p_op > name|single|num > alter_table_with_p_op ^ table-prop-values',
|
|
349
|
+
]
|
|
350
|
+
|
|
351
|
+
def spec(self):
|
|
352
|
+
return CqlSpec.SPEC
|
|
353
|
+
|
|
354
|
+
class AthenaSpec(SqlSpec):
|
|
355
|
+
SPEC = SqlSpec.SPEC + [
|
|
356
|
+
'alter_table_t_ > add > alter_table_add ^ add partition,drop partition',
|
|
357
|
+
'alter_table_add_ > partition > alter_partition ^ partition',
|
|
358
|
+
'alter_table_drop_ > partition > alter_partition ^ partition',
|
|
359
|
+
'alter_partition > ( > alter_partition_lp ^ (',
|
|
360
|
+
'alter_partition_lp > name > alter_partition_lp_a ^ partition-columns',
|
|
361
|
+
'alter_partition_lp_a > comparison > alter_partition_lp_a_op ^ =',
|
|
362
|
+
'alter_partition_lp_a_op > single > alter_partition_lp_a_op_v ^ single',
|
|
363
|
+
'alter_partition_lp_a_op_v > , > alter_partition_lp_sc ^ single',
|
|
364
|
+
'alter_partition_lp_sc > name|) > alter_partition_lp_a ^ partition-columns',
|
|
365
|
+
]
|
|
366
|
+
|
|
367
|
+
KEYWORDS = SqlSpec.KEYWORDS + [
|
|
368
|
+
'partition'
|
|
369
|
+
]
|
|
370
|
+
|
|
371
|
+
def spec(self):
|
|
372
|
+
return AthenaSpec.SPEC
|
|
373
|
+
|
|
374
|
+
def keywords(self):
|
|
375
|
+
return AthenaSpec.KEYWORDS
|
|
299
376
|
|
|
300
377
|
class StateTo:
|
|
301
378
|
def __init__(self, to_s: str, comeback_token: str = None, comeback_state: str = None):
|
|
302
379
|
self.to_s = to_s
|
|
303
380
|
self.comeback_token = comeback_token
|
|
304
381
|
self.comeback_state = comeback_state
|
|
382
|
+
self.context: dict[str, str] = {}
|
|
305
383
|
|
|
306
384
|
def __str__(self):
|
|
307
385
|
return f'{self.to_s} comeback[{self.comeback_token} {self.comeback_state}]'
|
|
308
386
|
|
|
309
387
|
class StateMachine:
|
|
310
|
-
def __init__(self, indent=0, lp_level = 0, debug = False):
|
|
388
|
+
def __init__(self, variant = 'sql', indent=0, lp_level = 0, debug = False):
|
|
389
|
+
self.variant = SqlSpec()
|
|
390
|
+
if variant == 'cql':
|
|
391
|
+
self.variant = CqlSpec()
|
|
392
|
+
elif variant == 'athena':
|
|
393
|
+
self.variant = AthenaSpec()
|
|
394
|
+
|
|
311
395
|
self.states: dict[str, StateTo] = {}
|
|
312
396
|
self.suggestions: dict[str, str] = {}
|
|
313
397
|
|
|
@@ -319,7 +403,7 @@ class StateMachine:
|
|
|
319
403
|
from_ss_to_add = []
|
|
320
404
|
from_ss = ['']
|
|
321
405
|
words: str = None
|
|
322
|
-
for l in
|
|
406
|
+
for l in self.variant.spec():
|
|
323
407
|
t_and_w = l.split('^')
|
|
324
408
|
if len(t_and_w) > 1:
|
|
325
409
|
words = t_and_w[1]
|
|
@@ -404,7 +488,7 @@ class StateMachine:
|
|
|
404
488
|
if self.debug:
|
|
405
489
|
if token.ttype == T.Whitespace:
|
|
406
490
|
print('_ ', end='')
|
|
407
|
-
elif token.ttype in [T.DML, T.Wildcard, T.Punctuation]:
|
|
491
|
+
elif token.ttype in [T.DML, T.Wildcard, T.Punctuation, T.CTE]:
|
|
408
492
|
print(f'{token.value} ', end='')
|
|
409
493
|
elif token.ttype:
|
|
410
494
|
tks = str(token.ttype).split('.')
|
|
@@ -415,18 +499,20 @@ class StateMachine:
|
|
|
415
499
|
print(f'{token.value}:{typ} ', end='')
|
|
416
500
|
# print(" " * self.indent + f"Token: {token.value}, Type: {token.ttype}@{token.ttype.__class__}")
|
|
417
501
|
|
|
502
|
+
last_name = None
|
|
418
503
|
if token.is_group:
|
|
419
504
|
state = self.traverse_tokens(token.tokens, state)
|
|
420
505
|
else:
|
|
421
506
|
comeback_state = None
|
|
422
507
|
|
|
423
508
|
it = ''
|
|
424
|
-
if (t := token.value.lower()) in
|
|
509
|
+
if (t := token.value.lower()) in self.variant.keywords():
|
|
425
510
|
it = t
|
|
426
511
|
elif token.ttype == T.Text.Whitespace:
|
|
427
512
|
it = '_'
|
|
428
513
|
elif token.ttype == T.Name:
|
|
429
514
|
it = 'name'
|
|
515
|
+
last_name = token.value
|
|
430
516
|
elif token.ttype == T.Literal.String.Single:
|
|
431
517
|
it = 'single'
|
|
432
518
|
elif token.ttype in [T.Literal.Number.Integer, T.Literal.Number.Float]:
|
|
@@ -451,10 +537,13 @@ class StateMachine:
|
|
|
451
537
|
if comeback_state:
|
|
452
538
|
state = comeback_state
|
|
453
539
|
else:
|
|
540
|
+
context = state.context
|
|
454
541
|
state = self.states[f'{state.to_s} > {it}']
|
|
455
|
-
|
|
542
|
+
state.context = context
|
|
543
|
+
|
|
544
|
+
if last_name:
|
|
545
|
+
state.context['last_name'] = last_name
|
|
456
546
|
except:
|
|
457
547
|
pass
|
|
458
|
-
# print('error')
|
|
459
548
|
|
|
460
549
|
return state
|
adam/utils_athena.py
CHANGED
|
@@ -22,7 +22,7 @@ def audit_table_names():
|
|
|
22
22
|
return table_names
|
|
23
23
|
|
|
24
24
|
@functools.lru_cache()
|
|
25
|
-
def audit_column_names(tables: list[str] = [], database: str = None):
|
|
25
|
+
def audit_column_names(tables: list[str] = [], database: str = None, partition_cols_only = False):
|
|
26
26
|
if not database:
|
|
27
27
|
database = Config().get('audit.athena.database', 'audit')
|
|
28
28
|
|
|
@@ -32,6 +32,9 @@ def audit_column_names(tables: list[str] = [], database: str = None):
|
|
|
32
32
|
table_names = "'" + "','".join([table.strip() for table in tables]) + "'"
|
|
33
33
|
|
|
34
34
|
query = f"select column_name from information_schema.columns where table_name in ({table_names}) and table_schema = '{database}'"
|
|
35
|
+
if partition_cols_only:
|
|
36
|
+
query = f"{query} and extra_info = 'partition key'"
|
|
37
|
+
|
|
35
38
|
_, _, rs = audit_query(query)
|
|
36
39
|
if rs:
|
|
37
40
|
return [row['Data'][0].get('VarCharValue') for row in rs[1:]]
|
adam/version.py
CHANGED
|
@@ -14,9 +14,9 @@ adam/repl_commands.py,sha256=GKdpHm4e0it7qVwjzBrsIoa5szpvZC30kJmHbWCvooA,4691
|
|
|
14
14
|
adam/repl_session.py,sha256=uIogcvWBh7wd8QQ-p_JgLsyJ8YJgINw5vOd6JIsd7Vo,472
|
|
15
15
|
adam/repl_state.py,sha256=VlQpV19Sg5vL8H3o8lQxZB5atyuTuN5iEQsd6xpSkQQ,8774
|
|
16
16
|
adam/utils.py,sha256=sbsNZP3qGJtb6fXCa4dDXHry5ay9ev583cCZIQzy07s,7382
|
|
17
|
-
adam/utils_athena.py,sha256=
|
|
17
|
+
adam/utils_athena.py,sha256=6OYed6dQ4dg2GZ3MPYt7fArWweEwyMpx2SUky0lb8Pc,3314
|
|
18
18
|
adam/utils_net.py,sha256=65fhBnWMCkhGtyHqz95qcHaCo35q-WX1RBkkXG8dKpI,416
|
|
19
|
-
adam/version.py,sha256=
|
|
19
|
+
adam/version.py,sha256=l7x3KRDwSOrLpvpwWDkKXD93Vqw7u4092yk8G8uCR70,139
|
|
20
20
|
adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
21
|
adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
|
|
22
22
|
adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
|
|
@@ -49,7 +49,7 @@ adam/columns/pod_name.py,sha256=IYw0ZKA7Fb9LaGXENqzZTiTgL98tahwFRtfy0KkKh2Q,280
|
|
|
49
49
|
adam/columns/volume_cassandra.py,sha256=9KRNOzjNYganI9avN6zaA5_-7yxD4rV-KNxro9CSUg4,753
|
|
50
50
|
adam/columns/volume_root.py,sha256=29ujLoCAf9LO75u62LxEaPD58s6ihV-tcK17OeLSOM0,556
|
|
51
51
|
adam/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
|
-
adam/commands/alter_tables.py,sha256=
|
|
52
|
+
adam/commands/alter_tables.py,sha256=VfAidKqXV8_24kgk4aGfCPLh6_lrJ7BxtGQbHKFv3_Y,3240
|
|
53
53
|
adam/commands/app.py,sha256=7alV8wK801t67_rUe6EmhtHJTl-6K7fGCm6Uz1dDgpM,1963
|
|
54
54
|
adam/commands/app_ping.py,sha256=Xk7cfefphXM2w-UvpnhNUTZ3BU38f0deehUb2FEyLCI,1337
|
|
55
55
|
adam/commands/bash.py,sha256=XKmbH0oWPHbzCuI54nrvSW901gUP9KWb3-NBMwBBMQk,2979
|
|
@@ -79,10 +79,10 @@ adam/commands/rollout.py,sha256=Db9P4Owd3aPcRLIGhwyEElBNm_2Ke54KbiXyVKmztcE,2959
|
|
|
79
79
|
adam/commands/shell.py,sha256=wY_PIx7Lt6vuxhFArlfxdEnBbrouCJ3yNHhFn17DEqw,848
|
|
80
80
|
adam/commands/watch.py,sha256=fU2LGll-Igl08HpUQALOnh8l3s3AMGFX26NCLhqbfcw,2438
|
|
81
81
|
adam/commands/audit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
82
|
-
adam/commands/audit/audit.py,sha256=
|
|
82
|
+
adam/commands/audit/audit.py,sha256=SOsh0FucedxfD7TQi2mvPdhu21ikTRTQQq06oueBf28,2664
|
|
83
83
|
adam/commands/audit/audit_repair_tables.py,sha256=ciKmacngg1r14uR8Z_uzgNH_sk0QlCQvJHLjcWeeDnQ,3330
|
|
84
84
|
adam/commands/cql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
85
|
-
adam/commands/cql/cql_completions.py,sha256=
|
|
85
|
+
adam/commands/cql/cql_completions.py,sha256=PxARSyVnNHNfpC-6-8sfgChdUI5KGxs64U5EMgU6lvQ,616
|
|
86
86
|
adam/commands/cql/cql_table_completer.py,sha256=Tth6lmZ1eCEbJeAVZojTx594ttQeeVf-OjhhkSLyRnI,312
|
|
87
87
|
adam/commands/cql/cql_utils.py,sha256=n1XBvgC0Bi0AwUdLZHzXi3n2VQivAXF-Ll7g2dyK_M4,4058
|
|
88
88
|
adam/commands/cql/cqlsh.py,sha256=qEQufaDVi9FXkvruum6OHQDfLX01DVWVDnWsAjyCZYQ,2661
|
|
@@ -156,8 +156,8 @@ adam/commands/show/show_processes.py,sha256=K7sBSyvCukp3bfoi0SBaqMV5a4Af8paEQXVZ
|
|
|
156
156
|
adam/commands/show/show_repairs.py,sha256=m82ukc6YxjvJc9rdKXsiJLtXrEUCiaE-VPqgxDsIOeM,1477
|
|
157
157
|
adam/commands/show/show_storage.py,sha256=WuBB5AEFm4g7oBz_YCbtkrF2GEeJ-J2tqCVmvzwmwuI,1837
|
|
158
158
|
adam/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
159
|
-
adam/sql/sql_completer.py,sha256=
|
|
160
|
-
adam/sql/state_machine.py,sha256=
|
|
159
|
+
adam/sql/sql_completer.py,sha256=QOdMu5ZFGikoE121WpJ9zGew58968M0_n5dN_ar4dNk,4538
|
|
160
|
+
adam/sql/state_machine.py,sha256=gDktPZKwi88o7flExAAPBCFeQkzE_XrAf8QCVv3sFrA,31797
|
|
161
161
|
adam/sql/term_completer.py,sha256=bNnHAVf9NZl52xS_BQpikbOK39gDBJADnT9gSvG0iqI,2539
|
|
162
162
|
adam/sso/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
163
163
|
adam/sso/authenticator.py,sha256=BCm16L9zf5aLU47-sTCnudn2zLPwd8M2wwRminJfsqw,615
|
|
@@ -184,8 +184,8 @@ adam/utils_k8s/service_accounts.py,sha256=v2oQSqCrNvt2uRnKlNwR3fjtpUG7oF5nqgzEB7
|
|
|
184
184
|
adam/utils_k8s/services.py,sha256=EOJJGACVbbRvu5T3rMKqIJqgYic1_MSJ17EA0TJ6UOk,3156
|
|
185
185
|
adam/utils_k8s/statefulsets.py,sha256=5g7KxGRHgEewT8rnZneDTaJDylUf-dHH2edWJEoorr8,4667
|
|
186
186
|
adam/utils_k8s/volumes.py,sha256=RIBmlOSWM3V3QVXLCFT0owVOyh4rGG1ETp521a-6ndo,1137
|
|
187
|
-
kaqing-2.0.
|
|
188
|
-
kaqing-2.0.
|
|
189
|
-
kaqing-2.0.
|
|
190
|
-
kaqing-2.0.
|
|
191
|
-
kaqing-2.0.
|
|
187
|
+
kaqing-2.0.99.dist-info/METADATA,sha256=7_Kc3E3wICNIh1l1pLrPduCHFBiQu0-3eVXgfDI2rt8,132
|
|
188
|
+
kaqing-2.0.99.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
189
|
+
kaqing-2.0.99.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
|
|
190
|
+
kaqing-2.0.99.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
|
|
191
|
+
kaqing-2.0.99.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|