forked from rucio/rucio
/
filter_engine.py
601 lines (539 loc) · 30 KB
/
filter_engine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import ast
import fnmatch
import operator
from datetime import date, datetime, timedelta
from importlib import import_module
from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union
import sqlalchemy
from sqlalchemy import and_, cast, or_
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.sql.expression import text
from rucio.common import exception
from rucio.common.utils import parse_did_filter_from_string_fe
from rucio.db.sqla.constants import DIDType
from rucio.db.sqla.session import read_session
if TYPE_CHECKING:
from collections.abc import Callable, Iterable
from sqlalchemy.orm import Session
from rucio.db.sqla.models import ModelBase
KeyType = TypeVar("KeyType", str, InstrumentedAttribute)
FilterTuple = tuple[KeyType, Callable[[object, object], Any], Union[bool, datetime, float, str]]
# lookup table converting keyword suffixes to pythonic operators.
OPERATORS_CONVERSION_LUT = {
"gte": operator.ge,
"lte": operator.le,
"lt": operator.lt,
"gt": operator.gt,
"ne": operator.ne,
"": operator.eq
}
# lookup table converting pythonic operators to oracle operators
ORACLE_OP_MAP = {
operator.eq: "==",
operator.ne: "<>",
operator.gt: ">",
operator.lt: "<",
operator.ge: ">=",
operator.le: "<="
}
# lookup table converting pythonic operators to postgres operators
POSTGRES_OP_MAP = {
operator.eq: "=",
operator.ne: "!=",
operator.gt: ">",
operator.lt: "<",
operator.ge: ">=",
operator.le: "<="
}
# understood date formats.
VALID_DATE_FORMATS = (
'%Y-%m-%d %H:%M:%S',
'%Y-%m-%dT%H:%M:%S',
'%Y-%m-%d %H:%M:%S.%fZ',
'%Y-%m-%dT%H:%M:%S.%fZ',
'%a, %d %b %Y %H:%M:%S UTC'
)
class FilterEngine:
"""
An engine to provide advanced filtering functionality to DID listing requests.
"""
def __init__(
self,
filters: Union[str, dict[str, Any], list[dict[str, Any]]],
model_class: Optional[type["ModelBase"]] = None,
strict_coerce: bool = True
):
if isinstance(filters, str):
filters, _ = parse_did_filter_from_string_fe(filters, omit_name=True)
elif isinstance(filters, dict):
filters = [filters]
elif isinstance(filters, list):
filters = filters
else:
raise exception.DIDFilterSyntaxError("Input filters are of an unrecognised type.")
filters = self._make_input_backwards_compatible(filters=filters)
self._filters, self.mandatory_model_attributes = self._translate_filters(filters=filters, model_class=model_class, strict_coerce=strict_coerce)
self._sanity_check_translated_filters()
@property
def filters(self) -> list[list["FilterTuple"]]:
return self._filters
def _coerce_filter_word_to_model_attribute(self, word: Any, model_class: Optional[type["ModelBase"]], strict: bool = True) -> Any:
"""
Attempts to coerce a filter word to an attribute of a <model_class>.
:param model_class: The word.
:param model_class: The SQL model class.
:params: strict: Enforce that keywords must be coercable to a model attribute.
:returns: The coerced attribute if successful or (if strict is False) the word if not.
:raises: KeyNotFound
"""
if isinstance(word, str):
if hasattr(model_class, word):
return getattr(model_class, word)
else:
if strict:
raise exception.KeyNotFound("'{}' keyword could not be coerced to model class attribute. Attribute not found.".format(word))
return word
def _make_input_backwards_compatible(self, filters: list[dict[str, Any]]) -> list[dict[str, Any]]:
"""
Backwards compatibility for previous versions of filtering.
Does the following:
- converts "created_after" key to "created_at.gte"
- converts "created_before" key to "created_at.lte"
"""
for or_group in filters:
if 'created_after' in or_group:
or_group['created_at.gte'] = or_group.pop('created_after')
elif 'created_before' in or_group:
or_group['created_at.lte'] = or_group.pop('created_before')
return filters
def _sanity_check_translated_filters(self) -> None:
"""
Perform a few sanity checks on translated filters.
Checks the following are all true:
1. 'did_type' filters use an equals operator,
2. 'name' filters use an equality operator,
3. 'length' filters are parsable as an int type,
4. wildcard expressions use an equality operator,
5. 'created_at' value adheres to one of the date formats <VALID_DATE_FORMATS>,
6. there are no duplicate key+operator criteria.
:raises: ValueError, DIDFilterSyntaxError, DuplicateCriteriaInDIDFilter
"""
for or_group in self._filters:
or_group_test_duplicates = []
for and_group in or_group:
key, oper, value = and_group
if key == 'did_type': # (1)
if oper != operator.eq:
raise ValueError("Type operator must be equals.")
if key == 'name': # (2)
if oper not in (operator.eq, operator.ne):
raise ValueError("Name operator must be an equality operator.")
if key == 'length': # (3)
try:
int(value) # type: ignore
except ValueError:
raise ValueError('Length has to be an integer value.')
if isinstance(value, str): # (4)
if any([char in value for char in ['*', '%']]):
if oper not in [operator.eq, operator.ne]:
raise exception.DIDFilterSyntaxError("Wildcards can only be used with equality operators")
if key == 'created_at': # (5)
if not isinstance(value, datetime):
raise exception.DIDFilterSyntaxError("Couldn't parse date '{}'. Valid formats are: {}".format(value, VALID_DATE_FORMATS))
or_group_test_duplicates.append((key, oper))
if len(set(or_group_test_duplicates)) != len(or_group_test_duplicates): # (6)
raise exception.DuplicateCriteriaInDIDFilter()
def _translate_filters(
self,
filters: "Iterable[dict[str, Any]]",
model_class: Optional[type["ModelBase"]],
strict_coerce: bool = True
) -> tuple[list[list["FilterTuple"]], list[InstrumentedAttribute[Any]]]:
"""
Reformats filters from:
[{or_group_1->key_1.or_group_1->operator_1: or_group_1->value_1,
{or_group_1->key_m.or_group_1->operator_m: or_group_1->value_m}
...
{or_group_n->key_1.or_group_n->operator_1: or_group_n->value_1,
{or_group_n->key_m.or_group_n->operator_m: or_group_n->value_m}
]
to the format used by the engine:
[[[or_group_1->key_1, or_group_1->operator_1, or_group_1->value_1],
...
[or_group_1->key_m, or_group_1->operator_m, or_group_1->value_m]
],
...
[[or_group_n->key_1, or_group_n->operator_1, or_group_n->value_1],
...
[or_group_n->key_m, or_group_n->operator_m, or_group_n->value_m]
]
]
replacing all filter operator suffixes with python equivalents using the LUT, <OPERATORS_CONVERSION_LUT>, and
coercing all filter words to their corresponding <model_class> attribute.
Typecasting of values is also attempted.
:param filters: The filters to translate.
:param model_class: The SQL model class.
:param strict_coerce: Enforce that keywords must be coercable to a model attribute.
:returns: The list of translated filters, and the set of mandatory model attributes to be used in the filter query.
:raises: MissingModuleException, DIDFilterSyntaxError
"""
if model_class:
try:
import_module(model_class.__module__)
except ModuleNotFoundError:
raise exception.MissingModuleException("Model class module not found.")
mandatory_model_attributes = set()
filters_translated = []
for or_group in filters:
and_group_parsed = []
for key, value in or_group.items():
# KEY
# Separate key for key name and possible operator.
key_tokenised = key.split('.')
if len(key_tokenised) == 1: # no operator suffix found, assume eq
try:
key_no_suffix = ast.literal_eval(key)
except ValueError:
key_no_suffix = key
oper = ''
elif len(key_tokenised) == 2: # operator suffix found
try:
key_no_suffix = ast.literal_eval(key_tokenised[0])
except ValueError:
key_no_suffix = key_tokenised[0]
oper = key_tokenised[1]
else:
raise exception.DIDFilterSyntaxError
key_no_suffix = self._coerce_filter_word_to_model_attribute(key_no_suffix, model_class, strict=strict_coerce)
if not isinstance(key_no_suffix, str):
mandatory_model_attributes.add(key_no_suffix)
# VALUE
# Typecasting is required when the entry point is the CLI as values will always be string.
if isinstance(value, str):
value = self._try_typecast_string(value)
# Convert string operator to pythonic operator.
and_group_parsed.append(
(key_no_suffix, OPERATORS_CONVERSION_LUT.get(oper), value))
filters_translated.append(and_group_parsed)
return filters_translated, list(mandatory_model_attributes)
def _try_typecast_string(self, value: str) -> Union[bool, datetime, float, str]:
"""
Check if string can be typecasted to bool, datetime or float.
:param value: The value to be typecasted.
:returns: The typecasted value.
"""
value = value.replace('true', 'True').replace('TRUE', 'True')
value = value.replace('false', 'False').replace('FALSE', 'False')
for format in VALID_DATE_FORMATS: # try parsing multiple date formats.
try:
typecasted_value = datetime.strptime(value, format)
except ValueError:
continue
else:
return typecasted_value
try:
operators = ('+', '-', '*', '/')
if not any(operator in value for operator in operators): # fix for lax ast literal_eval in earlier python versions
value = ast.literal_eval(value) # will catch float, int and bool
except (ValueError, SyntaxError):
pass
return value
def create_mongo_query(self, additional_filters: "Iterable[FilterTuple]" = []) -> dict[str, Any]:
"""
Returns a single mongo query describing the filters expression.
:param additional_filters: additional filters to be applied to all clauses.
:returns: a mongo query string describing the filters expression.
"""
# Add additional filters, applied as AND clauses to each OR group.
for or_group in self._filters:
for filter in additional_filters:
or_group.append(list(filter)) # type: ignore
or_expressions: list[dict[str, Any]] = []
for or_group in self._filters:
and_expressions: list[dict[str, dict[str, Any]]] = []
for and_group in or_group:
key, oper, value = and_group
if isinstance(value, str) and any([char in value for char in ['*', '%']]): # wildcards
if value in ('*', '%', '*', '%'): # match wildcard exactly == no filtering on key
continue
else: # partial match with wildcard == like || notlike
if oper == operator.eq:
expression = {
key: {
'$regex': fnmatch.translate(value) # translate partial wildcard expression to regex
}
}
elif oper == operator.ne:
expression = {
key: {
'$not': {
'$regex': fnmatch.translate(value) # translate partial wildcard expression to regex
}
}
}
else:
# mongodb operator keywords follow the same function names as operator package but prefixed with $
expression = {
key: {
'${}'.format(oper.__name__): value
}
}
and_expressions.append(expression)
if len(and_expressions) > 1: # $and key must have array as value...
or_expressions.append({'$and': and_expressions})
else:
or_expressions.append(and_expressions[0]) # ...otherwise just use the first, and only, entry.
if len(or_expressions) > 1:
query_str = {'$or': or_expressions} # $or key must have array as value...
else:
query_str = or_expressions[0] # ...otherwise just use the first, and only, entry.
return query_str
def create_postgres_query(
self,
additional_filters: "Iterable[FilterTuple]" = [],
fixed_table_columns: tuple[str, ...] | dict[str, str] = ('scope', 'name', 'vo'),
jsonb_column: str = 'data'
) -> str:
"""
Returns a single postgres query describing the filters expression.
:param additional_filters: additional filters to be applied to all clauses.
:param fixed_table_columns: the table columns
:returns: a postgres query string describing the filters expression.
"""
# Add additional filters, applied as AND clauses to each OR group.
for or_group in self._filters:
for _filter in additional_filters:
or_group.append(list(_filter)) # type: ignore
or_expressions: list[str] = []
for or_group in self._filters:
and_expressions: list[str] = []
for and_group in or_group:
key, oper, value = and_group
if key in fixed_table_columns: # is this key filtering on a column or in the jsonb?
is_in_json_column = False
else:
is_in_json_column = True
if isinstance(value, str) and any([char in value for char in ['*', '%']]): # wildcards
if value in ('*', '%', '*', '%'): # match wildcard exactly == no filtering on key
continue
else: # partial match with wildcard == like || notlike
if oper == operator.eq:
if is_in_json_column:
expression = "{}->>'{}' LIKE '{}' ".format(jsonb_column, key, value.replace('*', '%').replace('_', '\_')) # NOQA: W605
else:
expression = "{} LIKE '{}' ".format(key, value.replace('*', '%').replace('_', '\_')) # NOQA: W605
elif oper == operator.ne:
if is_in_json_column:
expression = "{}->>'{}' NOT LIKE '{}' ".format(jsonb_column, key, value.replace('*', '%').replace('_', '\_')) # NOQA: W605
else:
expression = "{} NOT LIKE '{}' ".format(key, value.replace('*', '%').replace('_', '\_')) # NOQA: W605
else:
# Infer what type key should be cast to from typecasting the value in the expression.
try:
if isinstance(value, int): # this could be bool or int (as bool subclass of int)
if isinstance(value, bool):
if is_in_json_column:
expression = "({}->>'{}')::boolean {} {}".format(jsonb_column, key, POSTGRES_OP_MAP[oper], str(value).lower())
else:
expression = "{}::boolean {} {}".format(key, POSTGRES_OP_MAP[oper], str(value).lower())
else:
# cast as float, not integer, to avoid potentially losing precision in key
if is_in_json_column:
expression = "({}->>'{}')::float {} {}".format(jsonb_column, key, POSTGRES_OP_MAP[oper], value)
else:
expression = "{}::float {} {}".format(key, POSTGRES_OP_MAP[oper], value)
elif isinstance(value, float):
if is_in_json_column:
expression = "({}->>'{}')::float {} {}".format(jsonb_column, key, POSTGRES_OP_MAP[oper], value)
else:
expression = "{}::float {} {}".format(key, POSTGRES_OP_MAP[oper], value)
elif isinstance(value, datetime):
if is_in_json_column:
expression = "({}->>'{}')::timestamp {} '{}'".format(jsonb_column, key, POSTGRES_OP_MAP[oper], value)
else:
expression = "{}::timestamp {} '{}'".format(key, POSTGRES_OP_MAP[oper], value)
else:
if is_in_json_column:
expression = "{}->>'{}' {} '{}'".format(jsonb_column, key, POSTGRES_OP_MAP[oper], value)
else:
expression = "{} {} '{}'".format(key, POSTGRES_OP_MAP[oper], value)
except Exception as e:
raise exception.FilterEngineGenericError(e)
and_expressions.append(expression)
or_expressions.append(' AND '.join(and_expressions))
return ' OR '.join(or_expressions)
@read_session
def create_sqla_query(
self,
*,
session: "Session",
additional_model_attributes: list[InstrumentedAttribute[Any]] = [],
additional_filters: "Iterable[FilterTuple]" = [],
json_column: Optional[Any] = None
) -> Any:
"""
Returns a database query that fully describes the filters.
The logic for construction of syntax describing a filter for key is dependent on whether the key has been previously coerced to a model attribute (i.e. key
is a table column).
:param session: The database session.
:param additional_model_attributes: Additional model attributes to retrieve.
:param additional_filters: Additional filters to be applied to all clauses.
:param json_column: Column to be checked if filter key has not been coerced to a model attribute. Only valid if engine instantiated with strict_coerce=False.
:returns: A database query.
:raises: FilterEngineGenericError
"""
all_model_attributes = set(self.mandatory_model_attributes + additional_model_attributes)
# Add additional filters, applied as AND clauses to each OR group.
for or_group in self._filters:
for _filter in additional_filters:
or_group.append(list(_filter)) # type: ignore
or_expressions: list = []
for or_group in self._filters:
and_expressions = []
for and_group in or_group:
key, oper, value = and_group
if isinstance(key, InstrumentedAttribute): # -> this key filters on a table column.
if isinstance(value, str) and any([char in value for char in ['*', '%']]): # wildcards
if value in ('*', '%', '*', '%'): # match wildcard exactly == no filtering on key
continue
else: # partial match with wildcard == like || notlike
if oper == operator.eq:
expression = key.like(value.replace('*', '%').replace('_', '\_'), escape='\\') # NOQA: W605
elif oper == operator.ne:
expression = key.notlike(value.replace('*', '%').replace('_', '\_'), escape='\\') # NOQA: W605
else:
expression = oper(key, value)
if oper == operator.ne: # set .ne operator to include NULLs.
expression = or_(expression, key.is_(None))
elif json_column: # -> this key filters on the content of a json column
if session.bind.dialect.name == 'oracle':
if isinstance(value, str) and any([char in value for char in ['*', '%']]): # wildcards
if value in ('*', '%', '*', '%'): # match wildcard exactly == no filtering on key
continue
else: # partial match with wildcard == like || notlike
if oper == operator.eq:
expression = text("json_exists({},'$?(@.{} like \"{}\")')".format(json_column.key, key, value.replace('*', '%')))
elif oper == operator.ne:
raise exception.FilterEngineGenericError("Oracle implementation does not support this operator.")
else:
try:
if isinstance(value, (bool)): # bool must be checked first (as bool subclass of int)
expression = text("json_exists({},'$?(@.{}.boolean() {} \"{}\")')".format(json_column.key, key, ORACLE_OP_MAP[oper], value))
elif isinstance(value, (int, float)):
expression = text("json_exists({},'$?(@.{} {} {})')".format(json_column.key, key, ORACLE_OP_MAP[oper], value))
else:
expression = text("json_exists({},'$?(@.{} {} \"{}\")')".format(json_column.key, key, ORACLE_OP_MAP[oper], value))
except Exception as e:
raise exception.FilterEngineGenericError(e)
else:
if isinstance(value, str) and any([char in value for char in ['*', '%']]): # wildcards
if value in ('*', '%', '*', '%'): # match wildcard exactly == no filtering on key
continue
else: # partial match with wildcard == like || notlike
if oper == operator.eq:
expression = json_column[key].as_string().like(value.replace('*', '%').replace('_', '\_'), escape='\\') # NOQA: W605
elif oper == operator.ne:
expression = json_column[key].as_string().notlike(value.replace('*', '%').replace('_', '\_'), escape='\\') # NOQA: W605
else:
# Infer what type key should be cast to from typecasting the value in the expression.
try:
if isinstance(value, int): # this could be bool or int (as bool subclass of int)
if isinstance(value, bool):
expression = oper(json_column[key].as_boolean(), value)
else:
expression = oper(json_column[key].as_float(), value) # cast as float, not integer, to avoid potentially losing precision in key
elif isinstance(value, float):
expression = oper(json_column[key].as_float(), value)
elif isinstance(value, datetime):
expression = oper(cast(cast(json_column[key], sqlalchemy.types.Text), sqlalchemy.types.DateTime), value)
else:
expression = oper(json_column[key].as_string(), value)
except Exception as e:
raise exception.FilterEngineGenericError(e)
else:
raise exception.FilterEngineGenericError("Requested filter on key without model attribute, but [json_column] not set.")
and_expressions.append(expression)
or_expressions.append(and_(*and_expressions))
return session.query(*all_model_attributes).filter(or_(*or_expressions))
def evaluate(self) -> bool:
"""
Evaluates an expression and returns a boolean result.
:returns: boolean output
"""
or_group_evaluations = []
for or_group in self._filters:
and_group_evaluations = []
for and_group in or_group:
key, oper, value = and_group
and_group_evaluations.append(oper(key, value))
or_group_evaluations.append(all(and_group_evaluations))
return any(or_group_evaluations)
def print_filters(self) -> str:
"""
A (more) human readable format of <filters>.
"""
operators_conversion_LUT_inv = {op2: op1 for op1, op2 in OPERATORS_CONVERSION_LUT.items()}
filters = '\n'
for or_group in self._filters:
for and_group in or_group:
key, oper, value = and_group
if isinstance(key, InstrumentedAttribute):
key = and_group[0].key
if operators_conversion_LUT_inv[oper] == "":
oper = "eq"
else:
oper = operators_conversion_LUT_inv[oper]
if isinstance(value, InstrumentedAttribute):
value = and_group[2].key # type: ignore
elif isinstance(value, DIDType):
value = and_group[2].name # type: ignore
filters = "{}{} {} {}".format(filters, key, oper, value)
if and_group != or_group[-1]:
filters += ' AND '
if or_group != self._filters[-1]:
filters += ' OR\n'
return filters
@staticmethod
def print_query(statement, dialect=sqlalchemy.dialects.postgresql.dialect()):
"""
Generates SQL expression from SQLA expression with parameters rendered inline.
For debugging ONLY.
:param dialect: the sql dialect.
:returns: The query statement in the chosen dialect.
"""
if isinstance(statement, sqlalchemy.orm.Query):
if dialect is None:
dialect = statement.session.bind.dialect
statement = statement.statement
elif dialect is None:
dialect = statement.bind.dialect
class LiteralCompiler(dialect.statement_compiler):
def visit_bindparam(self, bindparam, within_columns_clause=False,
literal_binds=False, **kwargs):
return self.render_literal_value(bindparam.value, bindparam.type)
def render_array_value(self, val, item_type):
if isinstance(val, list):
return "{%s}" % ",".join([self.render_array_value(x, item_type) for x in val])
return self.render_literal_value(val, item_type)
def render_literal_value(self, value, type_):
if isinstance(value, int):
return str(value)
elif isinstance(value, (str, date, datetime, timedelta)):
return "'%s'" % str(value).replace("'", "''")
elif isinstance(value, list):
return "'{%s}'" % (",".join([self.render_array_value(x, type_.item_type) for x in value]))
return super(LiteralCompiler, self).render_literal_value(value, type_)
return LiteralCompiler(dialect, statement).process(statement)