bug fix on select into
This commit is contained in:
+12
-5
@@ -232,9 +232,9 @@ def ext (fx):
|
||||
|
||||
|
||||
# operator call behavior
|
||||
def binary_op_behavior(op:OperatorBase, c_code, x, y):
|
||||
def binary_op_behavior(op:OperatorBase, c_code, *xs):
|
||||
name = op.cname if c_code else op.sqlname
|
||||
return f'({x} {name} {y})'
|
||||
return f'({f" {name} ".join(xs)})'
|
||||
|
||||
def unary_op_behavior(op:OperatorBase, c_code, x):
|
||||
name = op.cname if c_code else op.sqlname
|
||||
@@ -248,10 +248,16 @@ def count_behavior(op:OperatorBase, c_code, x, distinct = False):
|
||||
if not c_code:
|
||||
return f'{op.sqlname}({"distinct " if distinct else ""}{x})'
|
||||
elif distinct:
|
||||
return '({x}).distinct_size()'
|
||||
return f'({x}).distinct_size()'
|
||||
else:
|
||||
return '{count()}'
|
||||
|
||||
|
||||
def distinct_behavior(op:OperatorBase, c_code, x):
|
||||
if not c_code:
|
||||
return f'{op.sqlname}({x})'
|
||||
else:
|
||||
return f'({x}).distinct()'
|
||||
|
||||
def windowed_fn_behavor(op: OperatorBase, c_code, *x):
|
||||
if not c_code:
|
||||
return f'{op.sqlname}({", ".join([f"{xx}" for xx in x])})'
|
||||
@@ -277,6 +283,7 @@ oplte = OperatorBase('lte', 2, logical, cname = '<=', sqlname = '<=', call = bin
|
||||
opneq = OperatorBase('neq', 2, logical, cname = '!=', sqlname = '!=', call = binary_op_behavior)
|
||||
opeq = OperatorBase('eq', 2, logical, cname = '==', sqlname = '=', call = binary_op_behavior)
|
||||
opnot = OperatorBase('not', 1, logical, cname = '!', sqlname = 'NOT', call = unary_op_behavior)
|
||||
opdistinct = OperatorBase('distinct', 1, as_is, cname = '.distinct()', sqlname = 'distinct', call = distinct_behavior)
|
||||
# functional
|
||||
fnmax = OperatorBase('max', 1, as_is, cname = 'max', sqlname = 'MAX', call = fn_behavior)
|
||||
fnmin = OperatorBase('min', 1, as_is, cname = 'min', sqlname = 'MIN', call = fn_behavior)
|
||||
@@ -315,7 +322,7 @@ builtin_binary_arith = _op_make_dict(opadd, opdiv, opmul, opsub, opmod)
|
||||
builtin_binary_logical = _op_make_dict(opand, opor, opxor, opgt, oplt, opge, oplte, opneq, opeq)
|
||||
builtin_unary_logical = _op_make_dict(opnot)
|
||||
builtin_unary_arith = _op_make_dict(opneg)
|
||||
builtin_unary_special = _op_make_dict(spnull)
|
||||
builtin_unary_special = _op_make_dict(spnull, opdistinct)
|
||||
builtin_cstdlib = _op_make_dict(fnsqrt, fnlog, fnsin, fncos, fntan, fnpow)
|
||||
builtin_func = _op_make_dict(fnmax, fnmin, fnsum, fnavg, fnmaxs, fnmins, fndeltas, fnlast, fnsums, fnavgs, fncnt)
|
||||
user_module_func = {}
|
||||
|
||||
+47
-1
@@ -1,3 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
from collections.abc import MutableMapping, Mapping
|
||||
import uuid
|
||||
|
||||
lower_alp = 'abcdefghijklmnopqrstuvwxyz'
|
||||
@@ -7,6 +9,50 @@ base62alp = nums + lower_alp + upper_alp
|
||||
|
||||
reserved_monet = ['month']
|
||||
|
||||
|
||||
class CaseInsensitiveDict(MutableMapping):
|
||||
def __init__(self, data=None, **kwargs):
|
||||
self._store = OrderedDict()
|
||||
if data is None:
|
||||
data = {}
|
||||
self.update(data, **kwargs)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
# Use the lowercased key for lookups, but store the actual
|
||||
# key alongside the value.
|
||||
self._store[key.lower()] = (key, value)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._store[key.lower()][1]
|
||||
|
||||
def __delitem__(self, key):
|
||||
del self._store[key.lower()]
|
||||
|
||||
def __iter__(self):
|
||||
return (casedkey for casedkey, mappedvalue in self._store.values())
|
||||
|
||||
def __len__(self):
|
||||
return len(self._store)
|
||||
|
||||
def lower_items(self):
|
||||
"""Like iteritems(), but with all lowercase keys."""
|
||||
return ((lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items())
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Mapping):
|
||||
other = CaseInsensitiveDict(other)
|
||||
else:
|
||||
return NotImplemented
|
||||
# Compare insensitively
|
||||
return dict(self.lower_items()) == dict(other.lower_items())
|
||||
|
||||
# Copy is required
|
||||
def copy(self):
|
||||
return CaseInsensitiveDict(self._store.values())
|
||||
|
||||
def __repr__(self):
|
||||
return str(dict(self.items()))
|
||||
|
||||
def base62uuid(crop=8):
|
||||
_id = uuid.uuid4().int
|
||||
ret = ''
|
||||
@@ -60,7 +106,7 @@ def defval(val, default):
|
||||
return default if val is None else val
|
||||
|
||||
# escape must be readonly
|
||||
from typing import Set
|
||||
from typing import Mapping, Set
|
||||
def remove_last(pattern : str, string : str, escape : Set[str] = set()) -> str:
|
||||
idx = string.rfind(pattern)
|
||||
if idx == -1:
|
||||
|
||||
Reference in New Issue
Block a user