alamb commented on issue #10559:
URL: https://github.com/apache/datafusion/issues/10559#issuecomment-2127695450

   > @alamb - Thanks for responding. This sounds interesting. Could you 
elaborate on how this can be achieved?
   
   > What information gets passed down to SchemaProvider that I can use to 
determine which TableProvider instance to pass?
   
   According to 
https://docs.rs/datafusion/latest/datafusion/catalog/schema/trait.SchemaProvider.html
 it gets a table name.
   
   > Using a simple example request, "ctx.sql('SELECT * FROM table_a')", how 
can SchemaProvider return the right TableProvider based on this user request?
   
   I don't fully understand your usecase
   
   > a generic web service that fetches data through multiple tables/databases 
depending on the GraphQL request
   
   
    Perhaps you could make something like 
   
   ```rust
   let request = ...; // request with graphql context
   // register a table provider that has access to the context
   let table = MyTableProvider::new(request)
   // register `table_` for sql
   ctx.register_table("table_a", Arc::new(table))
   // now accessing table_a from SQL will access a `MyTableProvider` that has 
access to the request
   ctx.sql('SELECT * FROM table_a')...
   ```
   
   You could potentially use a schema provider to avoid having to register all 
tables for each request, and only instantiate the table providers when they are 
required


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

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