diff options
Diffstat (limited to 'sqlglot/executor/python.py')
-rw-r--r-- | sqlglot/executor/python.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sqlglot/executor/python.py b/sqlglot/executor/python.py index c0becbe..a2b23d4 100644 --- a/sqlglot/executor/python.py +++ b/sqlglot/executor/python.py @@ -142,7 +142,6 @@ class PythonExecutor: context = self.context({alias: table}) yield context types = [] - for row in reader: if not types: for v in row: @@ -150,7 +149,11 @@ class PythonExecutor: types.append(type(ast.literal_eval(v))) except (ValueError, SyntaxError): types.append(str) - context.set_row(tuple(t(v) for t, v in zip(types, row))) + + # We can't cast empty values ('') to non-string types, so we convert them to None instead + context.set_row( + tuple(None if (t is not str and v == "") else t(v) for t, v in zip(types, row)) + ) yield context.table.reader def join(self, step, context): |