-
Notifications
You must be signed in to change notification settings - Fork 150
Cannot convert Expr to InList #781
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When a SQL query contains a InList Expr, I can't get the InList object through Expr.to_variant().
To Reproduce
from datafusion import SessionContext
from datafusion.expr import Filter
def traverse_logical_plan(plan):
cur_node = plan.to_variant()
if isinstance(cur_node, Filter):
predicate = cur_node.predicate().to_variant()
if hasattr(plan, 'inputs'):
for input_plan in plan.inputs():
traverse_logical_plan(input_plan)
if __name__ == "__main__":
ctx = SessionContext()
data = {'id': [1, 2, 3], 'name': ['Alice', 'Bob', 'Charlie']}
ctx.from_pydict(data, name='table1')
query = "SELECT * FROM table1 t1 WHERE t1.name IN ('dfa', 'ad', 'dfre', 'vsa')"
logical_plan = ctx.sql(query).optimized_logical_plan()
traverse_logical_plan(logical_plan)
It produces,
File "minimal_example.py", line 8, in traverse_logical_plan
predicate = cur_node.predicate().to_variant()
RuntimeError: "Cannot convert this Expr to a Python object: InList(InList { expr: Column(Column { relation: Some(Bare { table: \"table1\" }), name: \"name\" }), list: [Literal(Utf8(\"dfa\")), Literal(Utf8(\"ad\")), Literal(Utf8(\"dfre\")), Literal(Utf8(\"vsa\"))], negated: false })"
Is there any other method to get the InList object?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.