You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/05/18 13:14:50 UTC

[arrow-datafusion] branch master updated: Introduce Expr.variant_name() function (#2564)

This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new 78207f509 Introduce Expr.variant_name() function (#2564)
78207f509 is described below

commit 78207f5092fc5204ecd791278d403dcb6f0ae683
Author: Jeremy Dyer <jd...@gmail.com>
AuthorDate: Wed May 18 09:14:44 2022 -0400

    Introduce Expr.variant_name() function (#2564)
    
    * Introduce Expr.variant_name() function
    
    * Change return type from Result<String> -> String
    
    * change return type from String -> &str
---
 datafusion/expr/src/expr.rs | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs
index c1c61d1ff..db6425a77 100644
--- a/datafusion/expr/src/expr.rs
+++ b/datafusion/expr/src/expr.rs
@@ -294,6 +294,40 @@ impl Expr {
         create_name(self, input_schema)
     }
 
+    /// Return String representation of the variant represented by `self`
+    /// Useful for non-rust based bindings
+    pub fn variant_name(&self) -> &str {
+        match self {
+            Expr::AggregateFunction { .. } => "AggregateFunction",
+            Expr::AggregateUDF { .. } => "AggregateUDF",
+            Expr::Alias(..) => "Alias",
+            Expr::Between { .. } => "Between",
+            Expr::BinaryExpr { .. } => "BinaryExpr",
+            Expr::Case { .. } => "Case",
+            Expr::Cast { .. } => "Cast",
+            Expr::Column(..) => "Column",
+            Expr::Exists { .. } => "Exists",
+            Expr::GetIndexedField { .. } => "GetIndexedField",
+            Expr::GroupingSet(..) => "GroupingSet",
+            Expr::InList { .. } => "InList",
+            Expr::InSubquery { .. } => "InSubquery",
+            Expr::IsNotNull(..) => "IsNotNull",
+            Expr::IsNull(..) => "IsNull",
+            Expr::Literal(..) => "Literal",
+            Expr::Negative(..) => "Negative",
+            Expr::Not(..) => "Not",
+            Expr::QualifiedWildcard { .. } => "QualifiedWildcard",
+            Expr::ScalarFunction { .. } => "ScalarFunction",
+            Expr::ScalarSubquery { .. } => "ScalarSubquery",
+            Expr::ScalarUDF { .. } => "ScalarUDF",
+            Expr::ScalarVariable(..) => "ScalarVariable",
+            Expr::Sort { .. } => "Sort",
+            Expr::TryCast { .. } => "TryCast",
+            Expr::WindowFunction { .. } => "WindowFunction",
+            Expr::Wildcard => "Wildcard",
+        }
+    }
+
     /// Return `self == other`
     pub fn eq(self, other: Expr) -> Expr {
         binary_expr(self, Operator::Eq, other)