You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2023/06/03 18:58:01 UTC
[arrow-datafusion] branch main updated: fix: ignore panics if racing against catalog/schema changes (#6536)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 815413c4a4 fix: ignore panics if racing against catalog/schema changes (#6536)
815413c4a4 is described below
commit 815413c4a4b473f996ccaa7deb650653430a5aba
Author: Alex Huang <hu...@gmail.com>
AuthorDate: Sat Jun 3 20:57:55 2023 +0200
fix: ignore panics if racing against catalog/schema changes (#6536)
* fix: ignore panics if racing against catalog/schema changes
* avoid race codition when table was removed
---
datafusion/core/src/catalog/information_schema.rs | 71 +++++++++++++----------
1 file changed, 40 insertions(+), 31 deletions(-)
diff --git a/datafusion/core/src/catalog/information_schema.rs b/datafusion/core/src/catalog/information_schema.rs
index 04de11dc6b..d30b490f28 100644
--- a/datafusion/core/src/catalog/information_schema.rs
+++ b/datafusion/core/src/catalog/information_schema.rs
@@ -81,15 +81,18 @@ impl InformationSchemaConfig {
for schema_name in catalog.schema_names() {
if schema_name != INFORMATION_SCHEMA {
- let schema = catalog.schema(&schema_name).unwrap();
- for table_name in schema.table_names() {
- let table = schema.table(&table_name).await.unwrap();
- builder.add_table(
- &catalog_name,
- &schema_name,
- &table_name,
- table.table_type(),
- );
+ // schema name may not exist in the catalog, so we need to check
+ if let Some(schema) = catalog.schema(&schema_name) {
+ for table_name in schema.table_names() {
+ if let Some(table) = schema.table(&table_name).await {
+ builder.add_table(
+ &catalog_name,
+ &schema_name,
+ &table_name,
+ table.table_type(),
+ );
+ }
+ }
}
}
}
@@ -118,15 +121,18 @@ impl InformationSchemaConfig {
for schema_name in catalog.schema_names() {
if schema_name != INFORMATION_SCHEMA {
- let schema = catalog.schema(&schema_name).unwrap();
- for table_name in schema.table_names() {
- let table = schema.table(&table_name).await.unwrap();
- builder.add_view(
- &catalog_name,
- &schema_name,
- &table_name,
- table.get_table_definition(),
- )
+ // schema name may not exist in the catalog, so we need to check
+ if let Some(schema) = catalog.schema(&schema_name) {
+ for table_name in schema.table_names() {
+ if let Some(table) = schema.table(&table_name).await {
+ builder.add_view(
+ &catalog_name,
+ &schema_name,
+ &table_name,
+ table.get_table_definition(),
+ )
+ }
+ }
}
}
}
@@ -140,19 +146,22 @@ impl InformationSchemaConfig {
for schema_name in catalog.schema_names() {
if schema_name != INFORMATION_SCHEMA {
- let schema = catalog.schema(&schema_name).unwrap();
- for table_name in schema.table_names() {
- let table = schema.table(&table_name).await.unwrap();
- for (field_position, field) in
- table.schema().fields().iter().enumerate()
- {
- builder.add_column(
- &catalog_name,
- &schema_name,
- &table_name,
- field_position,
- field,
- )
+ // schema name may not exist in the catalog, so we need to check
+ if let Some(schema) = catalog.schema(&schema_name) {
+ for table_name in schema.table_names() {
+ if let Some(table) = schema.table(&table_name).await {
+ for (field_position, field) in
+ table.schema().fields().iter().enumerate()
+ {
+ builder.add_column(
+ &catalog_name,
+ &schema_name,
+ &table_name,
+ field_position,
+ field,
+ )
+ }
+ }
}
}
}