8000 upgrade to datafusion 11 (#42) · nirnayroy/datafusion-python@a4bf58e · GitHub
[go: up one dir, main page]

Skip to content

Commit a4bf58e

Browse files
authored
upgrade to datafusion 11 (apache#42)
1 parent abc6d54 commit a4bf58e

File tree

4 files changed

+51
-36
lines changed

4 files changed

+51
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ __pycache__/
1414
# For a library or package, you might want to ignore these files since the code is
1515
# intended to run in multiple environments; otherwise, check them in:
1616
.python-version
17+
venv

Cargo.lock

Lines changed: 36 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ default = ["mimalloc"]
3434
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync"] }
3535
rand = "0.7"
3636
pyo3 = { version = "~0.16.5", features = ["extension-module", "abi3", "abi3-py37"] }
37-
datafusion = { version = "^10.0.0", features = ["pyarrow"] }
38-
datafusion-expr = { version = "^10.0.0" }
39-
datafusion-common = { version = "^10.0.0", features = ["pyarrow"] }
37+
datafusion = { version = "^11.0.0", features = ["pyarrow"] }
38+
datafusion-expr = { version = "^11.0.0" }
39+
datafusion-common = { version = "^11.0.0", features = ["pyarrow"] }
4040
uuid = { version = "0.8", features = ["v4"] }
4141
mimalloc = { version = "*", optional = true, default-features = false }
4242
async-trait = "0.1"

src/udaf.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ use pyo3::{prelude::*, types::PyTuple};
2222
use datafusion::arrow::array::ArrayRef;
2323
use datafusion::arrow::datatypes::DataType;
2424
use datafusion::arrow::pyarrow::PyArrowConvert;
25+
use datafusion::common::ScalarValue;
2526
use datafusion::error::{DataFusionError, Result};
27+
use datafusion::logical_expr::{
28+
Accumulator, AccumulatorFunctionImplementation, AggregateState, AggregateUDF,
29+
};
2630
use datafusion::logical_plan;
27-
use datafusion_common::ScalarValue;
28-
use datafusion_expr::Accumulator;
29-
use datafusion_expr::AccumulatorFunctionImplementation;
30-
use datafusion_expr::AggregateUDF;
3131

3232
use crate::expression::PyExpr;
3333
use crate::utils::parse_volatility;
@@ -44,9 +44,13 @@ impl RustAccumulator {
4444
}
4545

4646
impl Accumulator for RustAccumulator {
47-
fn state(&self) -> Result<Vec<ScalarValue>> {
48-
Python::with_gil(|py| self.accum.as_ref(py).call_method0("state")?.extract())
49-
.map_err(|e| DataFusionError::Execution(format!("{}", e)))
47+
fn state(&self) -> Result<Vec<AggregateState>> {
48+
let py_result: PyResult<Vec<ScalarValue>> =
49+
Python::with_gil(|py| self.accum.as_ref(py).call_method0("state")?.extract());
50+
match py_result {
51+
Ok(r) => Ok(r.into_iter().map(AggregateState::Scalar).collect()),
52+
Err(e) => Err(DataFusionError::Execution(format!("{}", e))),
53+
}
5054
}
5155

5256
fn evaluate(&self) -> Result<ScalarValue> {

0 commit comments

Comments
 (0)
0