@@ -36,7 +36,7 @@ use crate::datasource::physical_plan::{
3636 FileGroupDisplay , FileSink , FileSinkConfig , JsonSource ,
3737} ;
3838use crate :: error:: Result ;
39- use crate :: execution:: context :: SessionState ;
39+ use crate :: execution:: SessionState ;
4040use crate :: physical_plan:: insert:: { DataSink , DataSinkExec } ;
4141use crate :: physical_plan:: {
4242 DisplayAs , DisplayFormatType , SendableRecordBatchStream , Statistics ,
@@ -48,6 +48,7 @@ use arrow::json;
4848use arrow:: json:: reader:: { infer_json_schema_from_iterator, ValueIter } ;
4949use arrow_array:: RecordBatch ;
5050use arrow_schema:: ArrowError ;
51+ use datafusion_catalog:: Session ;
5152use datafusion_common:: config:: { ConfigField , ConfigFileType , JsonOptions } ;
5253use datafusion_common:: file_options:: json_writer:: JsonWriterOptions ;
5354use datafusion_common:: { not_impl_err, GetExt , DEFAULT_JSON_EXTENSION } ;
@@ -87,9 +88,10 @@ impl JsonFormatFactory {
8788impl FileFormatFactory for JsonFormatFactory {
8889 fn create (
8990 & self ,
90- state : & SessionState ,
91+ state : & dyn Session ,
9192 format_options : & HashMap < String , String > ,
9293 ) -> Result < Arc < dyn FileFormat > > {
94+ let state = state. as_any ( ) . downcast_ref :: < SessionState > ( ) . unwrap ( ) ;
9395 let json_options = match & self . options {
9496 None => {
9597 let mut table_options = state. default_table_options ( ) ;
@@ -189,7 +191,7 @@ impl FileFormat for JsonFormat {
189191
190192 async fn infer_schema (
191193 & self ,
192- _state : & SessionState ,
194+ _state : & dyn Session ,
193195 store : & Arc < dyn ObjectStore > ,
194196 objects : & [ ObjectMeta ] ,
195197 ) -> Result < SchemaRef > {
@@ -237,7 +239,7 @@ impl FileFormat for JsonFormat {
237239
238240 async fn infer_stats (
239241 & self ,
240- _state : & SessionState ,
242+ _state : & dyn Session ,
241243 _store : & Arc < dyn ObjectStore > ,
242244 table_schema : SchemaRef ,
243245 _object : & ObjectMeta ,
@@ -247,7 +249,7 @@ impl FileFormat for JsonFormat {
247249
248250 async fn create_physical_plan (
249251 & self ,
250- _state : & SessionState ,
252+ _state : & dyn Session ,
251253 mut conf : FileScanConfig ,
252254 _filters : Option < & Arc < dyn PhysicalExpr > > ,
253255 ) -> Result < Arc < dyn ExecutionPlan > > {
@@ -261,7 +263,7 @@ impl FileFormat for JsonFormat {
261263 async fn create_writer_physical_plan (
262264 & self ,
263265 input : Arc < dyn ExecutionPlan > ,
264- _state : & SessionState ,
266+ _state : & dyn Session ,
265267 conf : FileSinkConfig ,
266268 order_requirements : Option < LexRequirement > ,
267269 ) -> Result < Arc < dyn ExecutionPlan > > {
@@ -538,7 +540,7 @@ mod tests {
538540 }
539541
540542 async fn get_exec (
541- state : & SessionState ,
543+ state : & dyn Session ,
542544 projection : Option < Vec < usize > > ,
543545 limit : Option < usize > ,
544546 ) -> Result < Arc < dyn ExecutionPlan > > {
0 commit comments