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

   ### Is your feature request related to a problem or challenge?
   
   In `datafusion-variant` 
https://github.com/datafusion-contrib/datafusion-variant/pull/149 I am trying 
to replace the schema adapter of an existing `ListingTable`.
   
   At the moment, I have to recreate an equivalent `ListingTableConfig` like 
this:
   
   ```rust
           // Create a ListingTable config from the existing ListingTable 
`table`
           let partition_cols: Vec<&String> = table
               .options()
               .table_partition_cols
               .iter()
               .map(|(name, _)| name)
               .collect();
           let file_fields: Vec<FieldRef> = table
               .schema()
               .fields()
               .iter()
               .filter(|f| !partition_cols.contains(&f.name()))
               .cloned()
               .collect();
           let file_schema = Arc::new(Schema::new_with_metadata(
               file_fields,
               table.schema().metadata().clone(),
           ));
   
           let config = 
ListingTableConfig::new_with_multi_paths(table.table_paths().clone())
               .with_listing_options(table.options().clone())
               .with_schema(file_schema)
               
.with_expr_adapter_factory(Arc::new(VariantExprAdapterFactory::default()));
           let table = ListingTable::try_new(config)?
               
.with_cache(state.runtime_env().cache_manager.get_file_statistic_cache())
               .with_definition(cmd.definition.clone())
               .with_constraints(cmd.constraints.clone())
               .with_column_defaults(cmd.column_defaults.clone());
           Ok(Arc::new(table))
   ```
   
   This is both verbose and brittle if new fields are added to ListingTable 
config they won't automatically be added here
   
   
   
   
   ### Describe the solution you'd like
   
   I would like some easier way to go from an existing ListingTable to another 
ListingTable with a different expr adapter
   
   
   ### Describe alternatives you've considered
   
   
   For example, make we could add a ListingTable::into_config() to convert into 
a ListingTableConfig:
   
   ```rust
           // Create a ListingTable config from the existing ListingTable 
`table`
           let config = table.into_config()
               
.with_expr_adapter_factory(Arc::new(VariantExprAdapterFactory::default()));
           let table = ListingTable::try_new(config)?
               
.with_cache(state.runtime_env().cache_manager.get_file_statistic_cache())
               .with_definition(cmd.definition.clone())
               .with_constraints(cmd.constraints.clone())
               .with_column_defaults(cmd.column_defaults.clone());
           Ok(Arc::new(table))
   ```
   
   Or perhaps we could just add a method to get/set the ExprAdapterFactory the 
best:
   
   ```rust
           // Create a ListingTable config from the existing ListingTable 
`table`
           let existing_adapter = table.expr_adapter_factor();
           let new_adapter = 
Arc::new(VariantExprAdapterFactory::new(existing_adapter));
           let table = table
               .clone()
               .with_expr_adapter_factory(new_adapter);
           Ok(Arc::new(table))
   ```
   
   ### Additional context
   
   _No response_
   
   ### Willingness to contribute
   
   None


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