Skip to content

Commit b98378e

Browse files
feat: remove GetIndexField
datafusion replaced Expr::GetIndexField with a FieldAccessor trait. Ref apache/datafusion#10568 Ref apache/datafusion#10769
1 parent 3dfc379 commit b98378e

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

python/datafusion/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
ScalarVariable,
5454
Sort,
5555
TableScan,
56-
GetIndexedField,
5756
Not,
5857
IsNotNull,
5958
IsTrue,
@@ -116,7 +115,6 @@
116115
"SimilarTo",
117116
"ScalarVariable",
118117
"Alias",
119-
"GetIndexedField",
120118
"Not",
121119
"IsNotNull",
122120
"IsTrue",

python/datafusion/tests/test_imports.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
SimilarTo,
5454
ScalarVariable,
5555
Alias,
56-
GetIndexedField,
5756
Not,
5857
IsNotNull,
5958
IsTrue,
@@ -126,7 +125,6 @@ def test_class_module_is_datafusion():
126125
SimilarTo,
127126
ScalarVariable,
128127
Alias,
129-
GetIndexedField,
130128
Not,
131129
IsNotNull,
132130
IsTrue,

src/expr.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ use std::sync::Arc;
2323

2424
use datafusion::arrow::datatypes::{DataType, Field};
2525
use datafusion::arrow::pyarrow::PyArrowType;
26+
use datafusion::functions::core::expr_ext::FieldAccessor;
2627
use datafusion::scalar::ScalarValue;
2728
use datafusion_expr::{
2829
col,
2930
expr::{AggregateFunction, InList, InSubquery, ScalarFunction, Sort, WindowFunction},
30-
lit, Between, BinaryExpr, Case, Cast, Expr, GetFieldAccess, GetIndexedField, Like, Operator,
31-
TryCast,
31+
lit, Between, BinaryExpr, Case, Cast, Expr, GetFieldAccess, Like, Operator, TryCast,
3232
};
3333

3434
use crate::common::data_type::{DataTypeMap, RexType};
@@ -71,7 +71,6 @@ pub mod filter;
7171
pub mod grouping_set;
7272
pub mod in_list;
7373
pub mod in_subquery;
74-
pub mod indexed_field;
7574
pub mod join;
7675
pub mod like;
7776
pub mod limit;
@@ -216,13 +215,7 @@ impl PyExpr {
216215
}
217216

218217
fn __getitem__(&self, key: &str) -> PyResult<PyExpr> {
219-
Ok(Expr::GetIndexedField(GetIndexedField::new(
220-
Box::new(self.expr.clone()),
221-
GetFieldAccess::NamedStructField {
222-
name: ScalarValue::Utf8(Some(key.to_string())),
223-
},
224-
))
225-
.into())
218+
Ok(self.expr.clone().field(key).into())
226219
}
227220

228221
#[staticmethod]
@@ -263,7 +256,7 @@ impl PyExpr {
263256
pub fn rex_type(&self) -> PyResult<RexType> {
264257
Ok(match self.expr {
265258
Expr::Alias(..) => RexType::Alias,
266-
Expr::Column(..) | Expr::GetIndexedField { .. } => RexType::Reference,
259+
Expr::Column(..) => RexType::Reference,
267260
Expr::ScalarVariable(..) | Expr::Literal(..) => RexType::Literal,
268261
Expr::BinaryExpr { .. }
269262
| Expr::Not(..)
@@ -417,7 +410,6 @@ impl PyExpr {
417410
| Expr::IsNotFalse(expr)
418411
| Expr::IsNotUnknown(expr)
419412
| Expr::Negative(expr)
420-
| Expr::GetIndexedField(GetIndexedField { expr, .. })
421413
| Expr::Cast(Cast { expr, .. })
422414
| Expr::TryCast(TryCast { expr, .. })
423415
| Expr::Sort(Sort { expr, .. })
@@ -674,7 +666,6 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
674666
m.add_class::<cast::PyCast>()?;
675667
m.add_class::<cast::PyTryCast>()?;
676668
m.add_class::<between::PyBetween>()?;
677-
m.add_class::<indexed_field::PyGetIndexedField>()?;
678669
m.add_class::<explain::PyExplain>()?;
679670
m.add_class::<limit::PyLimit>()?;
680671
m.add_class::<aggregate::PyAggregate>()?;

0 commit comments

Comments
 (0)