cj-zhukov commented on code in PR #18946:
URL: https://github.com/apache/datafusion/pull/18946#discussion_r2567381833


##########
datafusion-examples/examples/proto/main.rs:
##########
@@ -50,19 +53,35 @@ impl FromStr for ExampleKind {
 
     fn from_str(s: &str) -> Result<Self> {
         match s {
+            "all" => Ok(Self::All),
             "composed_extension_codec" => Ok(Self::ComposedExtensionCodec),
             _ => Err(DataFusionError::Execution(format!("Unknown example: 
{s}"))),
         }
     }
 }
 
 impl ExampleKind {
-    const ALL: [Self; 1] = [Self::ComposedExtensionCodec];
+    const ALL_VARIANTS: [Self; 2] = [Self::All, Self::ComposedExtensionCodec];
+
+    const RUNNABLE_VARIANTS: [Self; 1] = [Self::ComposedExtensionCodec];
 
     const EXAMPLE_NAME: &str = "proto";
 
     fn variants() -> Vec<&'static str> {
-        Self::ALL.iter().map(|x| x.as_ref()).collect()
+        Self::ALL_VARIANTS
+            .iter()
+            .map(|example| example.as_ref())
+            .collect()
+    }
+
+    async fn run(&self) -> Result<()> {
+        match self {
+            ExampleKind::ComposedExtensionCodec => {
+                composed_extension_codec::composed_extension_codec().await?
+            }
+            ExampleKind::All => unreachable!("`All` should be handled in 
main"),

Review Comment:
   Thank you for the suggestion! 
   
   I used unreachable!() here because the `All` variant should never reach this 
branch under the current control flow -- it’s intended to be handled earlier in 
main with help of `RUNNABLE_VARIANTS`, so hitting this code path would indicate 
a logical bug rather than a runtime error. In that sense, it felt reasonable to 
treat it as an unreachable state.
   
   That said, I’m definitely open to discussing this further. If the community 
feels that returning a `DataFusionError` is more consistent with how similar 
cases are handled in the examples or elsewhere in the codebase, I’m happy to 
adjust the implementation. My main goal is to follow the established patterns 
and keep the code clear for future contributors.
   
   Would love to hear more thoughts from others on what the preferred approach 
is here!



-- 
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