fmguerreiro commented on code in PR #2316:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2316#discussion_r4021783510


##########
src/ast/mod.rs:
##########
@@ -10253,16 +10260,23 @@ pub enum FunctionParallel {
     Safe,
 }
 
-impl fmt::Display for FunctionParallel {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+impl FunctionParallel {
+    /// Returns the bare keyword for this parallel mode, without the 
`PARALLEL` prefix.
+    pub fn as_str(&self) -> &'static str {
         match self {
-            FunctionParallel::Unsafe => write!(f, "PARALLEL UNSAFE"),
-            FunctionParallel::Restricted => write!(f, "PARALLEL RESTRICTED"),
-            FunctionParallel::Safe => write!(f, "PARALLEL SAFE"),
+            FunctionParallel::Unsafe => "UNSAFE",
+            FunctionParallel::Restricted => "RESTRICTED",
+            FunctionParallel::Safe => "SAFE",
         }
     }
 }
 
+impl fmt::Display for FunctionParallel {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "PARALLEL {}", self.as_str())
+    }
+}
+

Review Comment:
   the aggregate option prints `PARALLEL = SAFE` while the function form prints 
`PARALLEL SAFE`, so as_str gives the bare keyword without duplicating the 
strings.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to