Skip to content

Commit 4df83f5

Browse files
authored
Derive Debug for SessionStateBuilder, adding Debug requirements to fields (#12632)
* Require Debug for PhysicalOptimizerRule * Add reference to meet &JoinType type required * Revert "Add reference to meet &JoinType type required" as clippy lint informs this is unnecessary This reverts commit f69d73c. * Require `Debug` for `CatalogProvider`, `CatalogProviderList`, UrlTableFactory * Add derive Debug to meet api-change * Add derive Debug in datafusion-cli to support api-change of CatalogProviderList * Require Debug for ExprPlanner * Require Debug for QueryPlanner * Require Debug for TableFunctionImpl * Require Debug for SerializerRegistry * Require Debug for FunctionFactory * Derive `Debug` on `SessionStateBuilder` * Implement `Debug` for `SessionStateBuilder` to reorder output fields, keep consistent Debug field order with `SessionState` * Settle TODO for displaying `Debug` of `InformationSchemaConfig` after `CatalogProviderList` requires `Debug`
1 parent 0abae43 commit 4df83f5

File tree

24 files changed

+91
-35
lines changed

24 files changed

+91
-35
lines changed

datafusion-cli/src/catalog.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use dirs::home_dir;
3434
use parking_lot::RwLock;
3535

3636
/// Wraps another catalog, automatically register require object stores for the file locations
37+
#[derive(Debug)]
3738
pub struct DynamicObjectStoreCatalog {
3839
inner: Arc<dyn CatalogProviderList>,
3940
state: Weak<RwLock<SessionState>>,
@@ -74,6 +75,7 @@ impl CatalogProviderList for DynamicObjectStoreCatalog {
7475
}
7576

7677
/// Wraps another catalog provider
78+
#[derive(Debug)]
7779
struct DynamicObjectStoreCatalogProvider {
7880
inner: Arc<dyn CatalogProvider>,
7981
state: Weak<RwLock<SessionState>>,
@@ -115,6 +117,7 @@ impl CatalogProvider for DynamicObjectStoreCatalogProvider {
115117

116118
/// Wraps another schema provider. [DynamicObjectStoreSchemaProvider] is responsible for registering the required
117119
/// object stores for the file locations.
120+
#[derive(Debug)]
118121
struct DynamicObjectStoreSchemaProvider {
119122
inner: Arc<dyn SchemaProvider>,
120123
state: Weak<RwLock<SessionState>>,

datafusion-cli/src/functions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ fn fixed_len_byte_array_to_string(val: Option<&FixedLenByteArray>) -> Option<Str
315315
})
316316
}
317317

318+
#[derive(Debug)]
318319
pub struct ParquetMetadataFunc {}
319320

320321
impl TableFunctionImpl for ParquetMetadataFunc {

datafusion-examples/examples/catalog.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct DirSchemaOpts<'a> {
135135
format: Arc<dyn FileFormat>,
136136
}
137137
/// Schema where every file with extension `ext` in a given `dir` is a table.
138+
#[derive(Debug)]
138139
struct DirSchema {
139140
ext: String,
140141
tables: RwLock<HashMap<String, Arc<dyn TableProvider>>>,
@@ -218,6 +219,7 @@ impl SchemaProvider for DirSchema {
218219
}
219220
}
220221
/// Catalog holds multiple schemas
222+
#[derive(Debug)]
221223
struct DirCatalog {
222224
schemas: RwLock<HashMap<String, Arc<dyn SchemaProvider>>>,
223225
}
@@ -259,6 +261,7 @@ impl CatalogProvider for DirCatalog {
259261
}
260262
}
261263
/// Catalog lists holds multiple catalog providers. Each context has a single catalog list.
264+
#[derive(Debug)]
262265
struct CustomCatalogProviderList {
263266
catalogs: RwLock<HashMap<String, Arc<dyn CatalogProvider>>>,
264267
}

datafusion-examples/examples/simple_udtf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ impl TableProvider for LocalCsvTable {
128128
}
129129
}
130130

131+
#[derive(Debug)]
131132
struct LocalCsvTableFunc {}
132133

133134
impl TableFunctionImpl for LocalCsvTableFunc {

datafusion/catalog/src/catalog.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
use std::any::Any;
19+
use std::fmt::Debug;
1920
use std::sync::Arc;
2021

2122
pub use crate::schema::SchemaProvider;
@@ -101,7 +102,7 @@ use datafusion_common::Result;
101102
///
102103
/// [`TableProvider`]: crate::TableProvider
103104
104-
pub trait CatalogProvider: Sync + Send {
105+
pub trait CatalogProvider: Debug + Sync + Send {
105106
/// Returns the catalog provider as [`Any`]
106107
/// so that it can be downcast to a specific implementation.
107108
fn as_any(&self) -> &dyn Any;
@@ -152,7 +153,7 @@ pub trait CatalogProvider: Sync + Send {
152153
///
153154
/// Please see the documentation on `CatalogProvider` for details of
154155
/// implementing a custom catalog.
155-
pub trait CatalogProviderList: Sync + Send {
156+
pub trait CatalogProviderList: Debug + Sync + Send {
156157
/// Returns the catalog list as [`Any`]
157158
/// so that it can be downcast to a specific implementation.
158159
fn as_any(&self) -> &dyn Any;

datafusion/catalog/src/dynamic_file/catalog.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
use crate::{CatalogProvider, CatalogProviderList, SchemaProvider, TableProvider};
2121
use async_trait::async_trait;
2222
use std::any::Any;
23+
use std::fmt::Debug;
2324
use std::sync::Arc;
2425

2526
/// Wrap another catalog provider list
27+
#[derive(Debug)]
2628
pub struct DynamicFileCatalog {
2729
/// The inner catalog provider list
2830
inner: Arc<dyn CatalogProviderList>,
@@ -67,6 +69,7 @@ impl CatalogProviderList for DynamicFileCatalog {
6769
}
6870

6971
/// Wraps another catalog provider
72+
#[derive(Debug)]
7073
struct DynamicFileCatalogProvider {
7174
/// The inner catalog provider
7275
inner: Arc<dyn CatalogProvider>,
@@ -114,6 +117,7 @@ impl CatalogProvider for DynamicFileCatalogProvider {
114117
///
115118
/// The provider will try to create a table provider from the file path if the table provider
116119
/// isn't exist in the inner schema provider.
120+
#[derive(Debug)]
117121
pub struct DynamicFileSchemaProvider {
118122
/// The inner schema provider
119123
inner: Arc<dyn SchemaProvider>,
@@ -174,7 +178,7 @@ impl SchemaProvider for DynamicFileSchemaProvider {
174178

175179
/// [UrlTableFactory] is a factory that can create a table provider from the given url.
176180
#[async_trait]
177-
pub trait UrlTableFactory: Sync + Send {
181+
pub trait UrlTableFactory: Debug + Sync + Send {
178182
/// create a new table provider from the provided url
179183
async fn try_new(
180184
&self,

datafusion/catalog/src/schema.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use async_trait::async_trait;
2222
use datafusion_common::{exec_err, DataFusionError};
2323
use std::any::Any;
24+
use std::fmt::Debug;
2425
use std::sync::Arc;
2526

2627
use crate::table::TableProvider;
@@ -32,7 +33,7 @@ use datafusion_common::Result;
3233
///
3334
/// [`CatalogProvider`]: super::CatalogProvider
3435
#[async_trait]
35-
pub trait SchemaProvider: Sync + Send {
36+
pub trait SchemaProvider: Debug + Sync + Send {
3637
/// Returns the owner of the Schema, default is None. This value is reported
3738
/// as part of `information_tables.schemata
3839
fn owner_name(&self) -> Option<&str> {

datafusion/catalog/src/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl From<&dyn Session> for TaskContext {
139139
}
140140
type SessionRefLock = Arc<Mutex<Option<Weak<RwLock<dyn Session>>>>>;
141141
/// The state store that stores the reference of the runtime session state.
142+
#[derive(Debug)]
142143
pub struct SessionStore {
143144
session: SessionRefLock,
144145
}

datafusion/core/src/catalog_common/information_schema.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use arrow::{
2626
};
2727
use async_trait::async_trait;
2828
use datafusion_common::DataFusionError;
29-
use std::fmt::{Debug, Formatter};
29+
use std::fmt::Debug;
3030
use std::{any::Any, sync::Arc};
3131

3232
use crate::catalog::{CatalogProviderList, SchemaProvider, TableProvider};
@@ -57,6 +57,7 @@ pub const INFORMATION_SCHEMA_TABLES: &[&str] =
5757
/// demand. This means that if more tables are added to the underlying
5858
/// providers, they will appear the next time the `information_schema`
5959
/// table is queried.
60+
#[derive(Debug)]
6061
pub struct InformationSchemaProvider {
6162
config: InformationSchemaConfig,
6263
}
@@ -70,20 +71,11 @@ impl InformationSchemaProvider {
7071
}
7172
}
7273

73-
#[derive(Clone)]
74+
#[derive(Clone, Debug)]
7475
struct InformationSchemaConfig {
7576
catalog_list: Arc<dyn CatalogProviderList>,
7677
}
7778

78-
impl Debug for InformationSchemaConfig {
79-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
80-
f.debug_struct("InformationSchemaConfig")
81-
// TODO it would be great to print the catalog list here
82-
// but that would require CatalogProviderList to implement Debug
83-
.finish_non_exhaustive()
84-
}
85-
}
86-
8779
impl InformationSchemaConfig {
8880
/// Construct the `information_schema.tables` virtual table
8981
async fn make_tables(

datafusion/core/src/catalog_common/listing_schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use object_store::ObjectStore;
4848
/// - `s3://host.example.com:3000/data/tpch/customer/_delta_log/`
4949
///
5050
/// [`ObjectStore`]: object_store::ObjectStore
51+
#[derive(Debug)]
5152
pub struct ListingSchemaProvider {
5253
authority: String,
5354
path: object_store::path::Path,

0 commit comments

Comments
 (0)