summaryrefslogtreecommitdiffstats
path: root/sqlglot/executor/env.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-15 16:46:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-15 16:46:17 +0000
commit28cc22419e32a65fea2d1678400265b8cabc3aff (patch)
treeff9ac1991fd48490b21ef6aa9015a347a165e2d9 /sqlglot/executor/env.py
parentInitial commit. (diff)
downloadsqlglot-upstream/6.0.4.tar.xz
sqlglot-upstream/6.0.4.zip
Adding upstream version 6.0.4.upstream/6.0.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/executor/env.py')
-rw-r--r--sqlglot/executor/env.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/sqlglot/executor/env.py b/sqlglot/executor/env.py
new file mode 100644
index 0000000..72b0558
--- /dev/null
+++ b/sqlglot/executor/env.py
@@ -0,0 +1,32 @@
+import datetime
+import re
+import statistics
+
+
+class reverse_key:
+ def __init__(self, obj):
+ self.obj = obj
+
+ def __eq__(self, other):
+ return other.obj == self.obj
+
+ def __lt__(self, other):
+ return other.obj < self.obj
+
+
+ENV = {
+ "__builtins__": {},
+ "datetime": datetime,
+ "locals": locals,
+ "re": re,
+ "float": float,
+ "int": int,
+ "str": str,
+ "desc": reverse_key,
+ "SUM": sum,
+ "AVG": statistics.fmean if hasattr(statistics, "fmean") else statistics.mean,
+ "COUNT": lambda acc: sum(1 for e in acc if e is not None),
+ "MAX": max,
+ "MIN": min,
+ "POW": pow,
+}