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

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


The following commit(s) were added to refs/heads/main by this push:
     new 9d35f41870 minor feat: impl FromStr for JoinType enum (#6033)
9d35f41870 is described below

commit 9d35f41870379e2b166231989788ac188fe14c17
Author: Nick Karpov <[email protected]>
AuthorDate: Thu Apr 20 05:39:40 2023 -0700

    minor feat: impl FromStr for JoinType enum (#6033)
    
    * added FromStr for JoinType
    
    * formatting: remove extra line
    
    * formatting: w/ `cargo fmt`
---
 datafusion/expr/src/logical_plan/plan.rs | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/datafusion/expr/src/logical_plan/plan.rs 
b/datafusion/expr/src/logical_plan/plan.rs
index 825a7b56e4..03ee55baa5 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -41,6 +41,7 @@ use datafusion_common::{
 use std::collections::{HashMap, HashSet};
 use std::fmt::{self, Debug, Display, Formatter};
 use std::hash::{Hash, Hasher};
+use std::str::FromStr;
 use std::sync::Arc;
 
 /// A LogicalPlan represents the different types of relational
@@ -1160,6 +1161,27 @@ impl Display for JoinType {
     }
 }
 
+impl FromStr for JoinType {
+    type Err = DataFusionError;
+
+    fn from_str(s: &str) -> Result<Self> {
+        let s = s.to_uppercase();
+        match s.as_str() {
+            "INNER" => Ok(JoinType::Inner),
+            "LEFT" => Ok(JoinType::Left),
+            "RIGHT" => Ok(JoinType::Right),
+            "FULL" => Ok(JoinType::Full),
+            "LEFTSEMI" => Ok(JoinType::LeftSemi),
+            "RIGHTSEMI" => Ok(JoinType::RightSemi),
+            "LEFTANTI" => Ok(JoinType::LeftAnti),
+            "RIGHTANTI" => Ok(JoinType::RightAnti),
+            _ => Err(DataFusionError::NotImplemented(format!(
+                "The join type {s} does not exist or is not implemented"
+            ))),
+        }
+    }
+}
+
 /// Join constraint
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
 pub enum JoinConstraint {

Reply via email to