Skip to content

Commit abe09a2

Browse files
remove PyDFField and related methods
DFField was removed upstream. Ref: apache/datafusion#9595
1 parent ddcd58f commit abe09a2

File tree

5 files changed

+4
-155
lines changed

5 files changed

+4
-155
lines changed

datafusion/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
)
3838

3939
from .common import (
40-
DFField,
4140
DFSchema,
4241
)
4342

datafusion/tests/test_imports.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
)
2828

2929
from datafusion.common import (
30-
DFField,
3130
DFSchema,
3231
)
3332

@@ -161,7 +160,7 @@ def test_class_module_is_datafusion():
161160
assert klass.__module__ == "datafusion.expr"
162161

163162
# schema
164-
for klass in [DFField, DFSchema]:
163+
for klass in [DFSchema]:
165164
assert klass.__module__ == "datafusion.common"
166165

167166

src/common.rs

-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
use pyo3::prelude::*;
1919

2020
pub mod data_type;
21-
pub mod df_field;
2221
pub mod df_schema;
2322
pub mod function;
2423
pub mod schema;
2524

2625
/// Initializes the `common` module to match the pattern of `datafusion-common` https://docs.rs/datafusion-common/18.0.0/datafusion_common/index.html
2726
pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
2827
m.add_class::<df_schema::PyDFSchema>()?;
29-
m.add_class::<df_field::PyDFField>()?;
3028
m.add_class::<data_type::PyDataType>()?;
3129
m.add_class::<data_type::DataTypeMap>()?;
3230
m.add_class::<data_type::PythonType>()?;

src/common/df_field.rs

-111
This file was deleted.

src/expr.rs

+3-39
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,19 @@ use std::convert::{From, Into};
2121
use datafusion::arrow::datatypes::DataType;
2222
use datafusion::arrow::pyarrow::PyArrowType;
2323
use datafusion::scalar::ScalarValue;
24-
use datafusion_common::DFField;
2524
use datafusion_expr::{
2625
col,
2726
expr::{AggregateFunction, InList, InSubquery, ScalarFunction, Sort, WindowFunction},
28-
lit,
29-
utils::exprlist_to_fields,
30-
Between, BinaryExpr, Case, Cast, Expr, GetFieldAccess, GetIndexedField, Like, LogicalPlan,
31-
Operator, TryCast,
27+
lit, Between, BinaryExpr, Case, Cast, Expr, GetFieldAccess, GetIndexedField, Like, Operator,
28+
TryCast,
3229
};
3330

3431
use crate::common::data_type::{DataTypeMap, RexType};
35-
use crate::errors::{py_datafusion_err, py_runtime_err, py_type_err, DataFusionError};
32+
use crate::errors::{py_datafusion_err, py_runtime_err, py_type_err};
3633
use crate::expr::aggregate_expr::PyAggregateFunction;
3734
use crate::expr::binary_expr::PyBinaryExpr;
3835
use crate::expr::column::PyColumn;
3936
use crate::expr::literal::PyLiteral;
40-
use crate::sql::logical::PyLogicalPlan;
4137

4238
use self::alias::PyAlias;
4339
use self::bool_expr::{
@@ -557,41 +553,9 @@ impl PyExpr {
557553
}
558554
})
559555
}
560-
561-
pub fn column_name(&self, plan: PyLogicalPlan) -> PyResult<String> {
562-
self._column_name(&plan.plan()).map_err(py_runtime_err)
563-
}
564556
}
565557

566558
impl PyExpr {
567-
pub fn _column_name(&self, plan: &LogicalPlan) -> Result<String, DataFusionError> {
568-
let field = Self::expr_to_field(&self.expr, plan)?;
569-
Ok(field.qualified_column().flat_name())
570-
}
571-
572-
/// Create a [DFField] representing an [Expr], given an input [LogicalPlan] to resolve against
573-
pub fn expr_to_field(
574-
expr: &Expr,
575-
input_plan: &LogicalPlan,
576-
) -> Result<DFField, DataFusionError> {
577-
match expr {
578-
Expr::Sort(Sort { expr, .. }) => {
579-
// DataFusion does not support create_name for sort expressions (since they never
580-
// appear in projections) so we just delegate to the contained expression instead
581-
Self::expr_to_field(expr, input_plan)
582-
}
583-
Expr::Wildcard { .. } => {
584-
// Since * could be any of the valid column names just return the first one
585-
Ok(input_plan.schema().field(0).clone())
586-
}
587-
_ => {
588-
let fields =
589-
exprlist_to_fields(&[expr.clone()], input_plan).map_err(PyErr::from)?;
590-
Ok(fields[0].clone())
591-
}
592-
}
593-
}
594-
595559
fn _types(expr: &Expr) -> PyResult<DataTypeMap> {
596560
match expr {
597561
Expr::BinaryExpr(BinaryExpr {

0 commit comments

Comments
 (0)