milenkovicm opened a new issue, #14899:
URL: https://github.com/apache/datafusion/issues/14899

   ### Is your feature request related to a problem or challenge?
   
   Just a small note about ergonomics of `SessionStateBuilder`, as I spent some 
time to figure out why: 
   
   ```rust
       let session_state = SessionStateBuilder::new()
           .with_table_factory("DELTA_TABLE".to_string(), 
Arc::new(DeltaTableFactory {}))
           .with_default_features()
           .build();
       let ctx = SessionContext::new_with_state(session_state);
   
       ctx.sql("create external table dt stored as delta_table location 
'./data/append_table/'")
           .await
           .unwrap()
           .show()
           .await
           .unwrap();
   ```
   
   fails with ` Execution("Unable to find factory for DELTA_TABLE")`?
   
   Apparently ordering of with_ methods matters as 
   
   
   ```rust 
       let session_state = SessionStateBuilder::new()
           .with_default_features()
           .with_table_factory("DELTA_TABLE".to_string(), 
Arc::new(DeltaTableFactory {}))
           .build();
   ```
   
   will work as expected. 
   
   Apparently, `with_default_features` will override table factories, so if its 
called last (like I would usually do) previous state will be removed:
   
   ```rust
   pub fn with_default_features(self) -> Self {
           
self.with_table_factories(SessionStateDefaults::default_table_factories())
               .with_file_formats(SessionStateDefaults::default_file_formats())
               
.with_expr_planners(SessionStateDefaults::default_expr_planners())
               
.with_scalar_functions(SessionStateDefaults::default_scalar_functions())
               
.with_aggregate_functions(SessionStateDefaults::default_aggregate_functions())
               
.with_window_functions(SessionStateDefaults::default_window_functions())
               
.with_table_function_list(SessionStateDefaults::default_table_functions())
       }
   ```
   
   
   
   ### Describe the solution you'd like
   
   Would it make sense from ergonomic perspective to make 
`with_default_features()` rather than `with_default_features(self)` and force 
it to be first statement in the builder. 
   
   ### Describe alternatives you've considered
   
   It can stay as it is, I might be pedantic, but would make sense to document 
it (which I personally would probably miss) 
   
   ### Additional context
   
   _No response_


-- 
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: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to