/// Create a table provider for the named table
Create a table provider for the named table
Create a table provider for the named table
fn table(&self, table_name: &str) -> Option<Arc<dyn TableProvider>> {
        let mut builder = ProviderBuilder::new(table_name);
        builder.add_pruner(Arc::clone(&self.chunk_access) as Arc<dyn ChunkPruner<DbChunk>>);
        let predicate = PredicateBuilder::new().table(table_name).build();
        for chunk in self.chunk_access.candidate_chunks(&predicate) {
            // This should only fail if the table doesn't exist which isn't possible
            let schema = chunk.table_schema(Selection::All).expect("cannot fail");
            // This is unfortunate - a table with incompatible chunks ceases to
            // be visible to the query engine
            //
            // It is also potentially ill-formed as continuing to use the builder
            // after it has errored may not yield entirely sensible results
            builder
                .add_chunk(chunk, schema)
                .log_if_error("Adding chunks to table")
                .ok()?;
        }
        match builder.build() {
            Ok(provider) => Some(Arc::new(provider)),
            Err(provider::Error::InternalNoRowsInTable { .. }) => None,
            Err(e) => panic!("unexpected error: {:?}", e),
        }
    }
fn table ( & self , table_name : & str ) -> Option < Arc < dyn TableProvider > > { let mut builder = ProviderBuilder :: new ( table_name ) ; builder . add_pruner ( Arc :: clone ( & self . chunk_access ) as Arc < dyn ChunkPruner < DbChunk > > ) ; let predicate = PredicateBuilder :: new ( ) . table ( table_name ) . build ( ) ; for chunk in self . chunk_access . candidate_chunks ( & predicate ) { // This should only fail if the table doesn't exist which isn't possible let schema = chunk . table_schema ( Selection :: All ) . expect ( " " ) ; // This is unfortunate - a table with incompatible chunks ceases to // be visible to the query engine // // It is also potentially ill-formed as continuing to use the builder // after it has errored may not yield entirely sensible results builder . add_chunk ( chunk , schema ) . log_if_error ( " " ) . ok ( ) ? ; } match builder . build ( ) { Ok ( provider ) => Some ( Arc :: new ( provider ) ) , Err ( provider :: Error :: InternalNoRowsInTable { .. } ) => None , Err ( e ) => panic ! ( " " e ) , } }
Create a table provider for the named table
Create a table provider for the named table
&self
table_name
&str