apache / datafusion-python

Apache DataFusion Python Bindings
https://datafusion.apache.org/python
Apache License 2.0
356 stars 71 forks source link

Is it possible to pass query parameters? (`:param` or `?`) #513

Open shner-elmo opened 12 months ago

shner-elmo commented 12 months ago

Hey, I'm trying to port a query from duckdb to datafusion using the Python connector, the issue I'm facing, is adding query parameters. Is there currently a way that I can pass query parameters ?

import datafusion
import pyarrow.dataset as ds

dataset = ds.dataset(...)

ctx = datafusion.SessionContext()
ctx.register_dataset('dataset', dataset)
table = ctx.sql("SELECT * FROM dataset WHERE col BETWEEN ? AND ?", parameters=[1, 10]).to_arrow_table()
## TypeError: SessionContext.sql() got an unexpected keyword argument 'parameters'