MCPcopy Create free account
hub / github.com/apache/datafusion / tables

Method tables

datafusion-examples/examples/flight/sql_server.rs:166–201  ·  view source on GitHub ↗
(&self, ctx: Arc<SessionContext>)

Source from the content-addressed store, hash-verified

164 }
165
166 async fn tables(&self, ctx: Arc<SessionContext>) -> RecordBatch {
167 let schema = Arc::new(Schema::new(vec![
168 Field::new("catalog_name", DataType::Utf8, true),
169 Field::new("db_schema_name", DataType::Utf8, true),
170 Field::new("table_name", DataType::Utf8, false),
171 Field::new("table_type", DataType::Utf8, false),
172 ]));
173
174 let mut catalogs = vec![];
175 let mut schemas = vec![];
176 let mut names = vec![];
177 let mut types = vec![];
178 for catalog in ctx.catalog_names() {
179 let catalog_provider = ctx.catalog(&catalog).unwrap();
180 for schema in catalog_provider.schema_names() {
181 let schema_provider = catalog_provider.schema(&schema).unwrap();
182 for table in schema_provider.table_names() {
183 let table_provider =
184 schema_provider.table(&table).await.unwrap().unwrap();
185 catalogs.push(catalog.clone());
186 schemas.push(schema.clone());
187 names.push(table.clone());
188 types.push(table_provider.table_type().to_string())
189 }
190 }
191 }
192
193 RecordBatch::try_new(
194 schema,
195 [catalogs, schemas, names, types]
196 .into_iter()
197 .map(|i| Arc::new(StringArray::from(i)) as ArrayRef)
198 .collect::<Vec<_>>(),
199 )
200 .unwrap()
201 }
202
203 fn remove_plan(&self, handle: &str) -> Result<(), Status> {
204 self.statements.remove(&handle.to_string());

Callers 1

Calls 13

newFunction · 0.85
catalog_namesMethod · 0.45
catalogMethod · 0.45
schema_namesMethod · 0.45
schemaMethod · 0.45
table_namesMethod · 0.45
tableMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
to_stringMethod · 0.45
table_typeMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected