File size: 1,016 Bytes
6bff5d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Whitelisted operators + aggregation functions for IR validation."""

ALLOWED_FILTER_OPS = frozenset({
    "=", "!=", "<", "<=", ">", ">=",
    "in", "not_in", "is_null", "is_not_null",
    "like", "between",
})

ALLOWED_AGG_FNS = frozenset({
    "count", "count_distinct", "sum", "avg", "min", "max",
})

LIMIT_HARD_CAP = 10_000

# Type compatibility: which value_types may appear in a FilterClause when the
# referenced column has the given data_type. Numeric types are mutually
# compatible (decimal literal against int column is fine). Date/datetime accept
# string so the planner can emit ISO-8601 literals without mode juggling.
TYPE_COMPATIBILITY: dict[str, frozenset[str]] = {
    "int":      frozenset({"int", "decimal"}),
    "decimal":  frozenset({"int", "decimal"}),
    "string":   frozenset({"string"}),
    "datetime": frozenset({"datetime", "date", "string"}),
    "date":     frozenset({"date", "datetime", "string"}),
    "bool":     frozenset({"bool"}),
    "json":     frozenset({"string"}),
}