@@ -21,23 +21,19 @@ use std::convert::{From, Into};
2121use datafusion:: arrow:: datatypes:: DataType ;
2222use datafusion:: arrow:: pyarrow:: PyArrowType ;
2323use datafusion:: scalar:: ScalarValue ;
24- use datafusion_common:: DFField ;
2524use 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
3431use 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} ;
3633use crate :: expr:: aggregate_expr:: PyAggregateFunction ;
3734use crate :: expr:: binary_expr:: PyBinaryExpr ;
3835use crate :: expr:: column:: PyColumn ;
3936use crate :: expr:: literal:: PyLiteral ;
40- use crate :: sql:: logical:: PyLogicalPlan ;
4137
4238use self :: alias:: PyAlias ;
4339use 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
566558impl 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