(&self, ctx: Arc<SessionContext>)
| 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()); |
no test coverage detected