summaryrefslogtreecommitdiffstats
path: root/sqlglot/executor
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-21 09:29:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-21 09:29:26 +0000
commit8b4272814fb4585be120f183eb7c26bb8acde974 (patch)
tree85d56a8f5ac4ac94ab924d5bbc578586eeb2a998 /sqlglot/executor
parentReleasing debian version 7.1.3-1. (diff)
downloadsqlglot-8b4272814fb4585be120f183eb7c26bb8acde974.tar.xz
sqlglot-8b4272814fb4585be120f183eb7c26bb8acde974.zip
Merging upstream version 9.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/executor')
-rw-r--r--sqlglot/executor/env.py1
-rw-r--r--sqlglot/executor/python.py8
2 files changed, 6 insertions, 3 deletions
diff --git a/sqlglot/executor/env.py b/sqlglot/executor/env.py
index 72b0558..9c49dd1 100644
--- a/sqlglot/executor/env.py
+++ b/sqlglot/executor/env.py
@@ -19,6 +19,7 @@ ENV = {
"datetime": datetime,
"locals": locals,
"re": re,
+ "bool": bool,
"float": float,
"int": int,
"str": str,
diff --git a/sqlglot/executor/python.py b/sqlglot/executor/python.py
index 8ef6cf0..fcb016b 100644
--- a/sqlglot/executor/python.py
+++ b/sqlglot/executor/python.py
@@ -80,9 +80,10 @@ class PythonExecutor:
source = step.source
if isinstance(source, exp.Expression):
- source = source.this.name or source.alias
+ source = source.name or source.alias
else:
source = step.name
+
condition = self.generate(step.condition)
projections = self.generate_tuple(step.projections)
@@ -121,7 +122,7 @@ class PythonExecutor:
source = step.source
alias = source.alias
- with csv_reader(source.this) as reader:
+ with csv_reader(source) as reader:
columns = next(reader)
table = Table(columns)
context = self.context({alias: table})
@@ -308,7 +309,7 @@ def _interval_py(self, expression):
def _like_py(self, expression):
this = self.sql(expression, "this")
expression = self.sql(expression, "expression")
- return f"""re.match({expression}.replace("_", ".").replace("%", ".*"), {this})"""
+ return f"""bool(re.match({expression}.replace("_", ".").replace("%", ".*"), {this}))"""
def _ordered_py(self, expression):
@@ -330,6 +331,7 @@ class Python(Dialect):
exp.Cast: _cast_py,
exp.Column: _column_py,
exp.EQ: lambda self, e: self.binary(e, "=="),
+ exp.In: lambda self, e: f"{self.sql(e, 'this')} in {self.expressions(e)}",
exp.Interval: _interval_py,
exp.Is: lambda self, e: self.binary(e, "is"),
exp.Like: _like_py,