Skip to content

Commit

Permalink
feat: remove GetIndexField
Browse files Browse the repository at this point in the history
datafusion replaced Expr::GetIndexField with a FieldAccessor trait.

Ref apache/datafusion#10568
Ref apache/datafusion#10769
  • Loading branch information
Michael-J-Ward committed Jun 12, 2024
1 parent 3dfc379 commit b98378e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 0 additions & 2 deletions python/datafusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
ScalarVariable,
Sort,
TableScan,
GetIndexedField,
Not,
IsNotNull,
IsTrue,
Expand Down Expand Up @@ -116,7 +115,6 @@
"SimilarTo",
"ScalarVariable",
"Alias",
"GetIndexedField",
"Not",
"IsNotNull",
"IsTrue",
Expand Down
2 changes: 0 additions & 2 deletions python/datafusion/tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
SimilarTo,
ScalarVariable,
Alias,
GetIndexedField,
Not,
IsNotNull,
IsTrue,
Expand Down Expand Up @@ -126,7 +125,6 @@ def test_class_module_is_datafusion():
SimilarTo,
ScalarVariable,
Alias,
GetIndexedField,
Not,
IsNotNull,
IsTrue,
Expand Down
17 changes: 4 additions & 13 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ use std::sync::Arc;

use datafusion::arrow::datatypes::{DataType, Field};
use datafusion::arrow::pyarrow::PyArrowType;
use datafusion::functions::core::expr_ext::FieldAccessor;
use datafusion::scalar::ScalarValue;
use datafusion_expr::{
col,
expr::{AggregateFunction, InList, InSubquery, ScalarFunction, Sort, WindowFunction},
lit, Between, BinaryExpr, Case, Cast, Expr, GetFieldAccess, GetIndexedField, Like, Operator,
TryCast,
lit, Between, BinaryExpr, Case, Cast, Expr, GetFieldAccess, Like, Operator, TryCast,
};

use crate::common::data_type::{DataTypeMap, RexType};
Expand Down Expand Up @@ -71,7 +71,6 @@ pub mod filter;
pub mod grouping_set;
pub mod in_list;
pub mod in_subquery;
pub mod indexed_field;
pub mod join;
pub mod like;
pub mod limit;
Expand Down Expand Up @@ -216,13 +215,7 @@ impl PyExpr {
}

fn __getitem__(&self, key: &str) -> PyResult<PyExpr> {
Ok(Expr::GetIndexedField(GetIndexedField::new(
Box::new(self.expr.clone()),
GetFieldAccess::NamedStructField {
name: ScalarValue::Utf8(Some(key.to_string())),
},
))
.into())
Ok(self.expr.clone().field(key).into())
}

#[staticmethod]
Expand Down Expand Up @@ -263,7 +256,7 @@ impl PyExpr {
pub fn rex_type(&self) -> PyResult<RexType> {
Ok(match self.expr {
Expr::Alias(..) => RexType::Alias,
Expr::Column(..) | Expr::GetIndexedField { .. } => RexType::Reference,
Expr::Column(..) => RexType::Reference,
Expr::ScalarVariable(..) | Expr::Literal(..) => RexType::Literal,
Expr::BinaryExpr { .. }
| Expr::Not(..)
Expand Down Expand Up @@ -417,7 +410,6 @@ impl PyExpr {
| Expr::IsNotFalse(expr)
| Expr::IsNotUnknown(expr)
| Expr::Negative(expr)
| Expr::GetIndexedField(GetIndexedField { expr, .. })
| Expr::Cast(Cast { expr, .. })
| Expr::TryCast(TryCast { expr, .. })
| Expr::Sort(Sort { expr, .. })
Expand Down Expand Up @@ -674,7 +666,6 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
m.add_class::<cast::PyCast>()?;
m.add_class::<cast::PyTryCast>()?;
m.add_class::<between::PyBetween>()?;
m.add_class::<indexed_field::PyGetIndexedField>()?;
m.add_class::<explain::PyExplain>()?;
m.add_class::<limit::PyLimit>()?;
m.add_class::<aggregate::PyAggregate>()?;
Expand Down

0 comments on commit b98378e

Please sign in to comment.