diff --git a/src/gateway/converter/conversion_options.py b/src/gateway/converter/conversion_options.py index 1ae902f..a44bc13 100644 --- a/src/gateway/converter/conversion_options.py +++ b/src/gateway/converter/conversion_options.py @@ -39,7 +39,9 @@ def arrow(): def datafusion(): """Return standard options to connect to a Datafusion backend.""" - return ConversionOptions(backend=BackendOptions(BackendEngine.DATAFUSION)) + options = ConversionOptions(backend=BackendOptions(BackendEngine.DATAFUSION)) + options.use_switch_expressions_where_possible = False + return options def duck_db(): diff --git a/src/gateway/converter/substrait_plan_visitor.py b/src/gateway/converter/substrait_plan_visitor.py index 561ef47..0b44594 100644 --- a/src/gateway/converter/substrait_plan_visitor.py +++ b/src/gateway/converter/substrait_plan_visitor.py @@ -178,7 +178,7 @@ def visit_record(self, record: algebra_pb2.Expression.MultiOrList.Record) -> Any def visit_if_value(self, if_clause: algebra_pb2.Expression.SwitchExpression.IfValue) -> Any: """Visits an if value.""" if if_clause.HasField('if'): - self.visit_expression(getattr(if_clause, 'if')) + self.visit_literal(getattr(if_clause, 'if')) if if_clause.HasField('then'): self.visit_expression(if_clause.then) @@ -239,10 +239,17 @@ def visit_window_rel_function( if function.HasField('output_type'): self.visit_type(function.output_type) + def visit_if_clause(self, if_clause: algebra_pb2.Expression.IfThen.IfClause) -> Any: + """Visits an if value.""" + if if_clause.HasField('if'): + self.visit_expression(getattr(if_clause, 'if')) + if if_clause.HasField('then'): + self.visit_expression(if_clause.then) + def visit_if_then(self, if_then: algebra_pb2.Expression.IfThen) -> Any: """Visits an if then.""" for if_then_if in if_then.ifs: - self.visit_if_value(if_then_if) + self.visit_if_clause(if_then_if) if if_then.HasField('else'): self.visit_expression(getattr(if_then, 'else'))