diff options
Diffstat (limited to 'sqlglot/executor/python.py')
-rw-r--r-- | sqlglot/executor/python.py | 8 |
1 files changed, 5 insertions, 3 deletions
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, |