1515// specific language governing permissions and limitations
1616// under the License.
1717
18+ use std:: collections:: HashMap ;
1819use std:: sync:: Arc ;
1920use std:: { path:: PathBuf , time:: Duration } ;
2021
@@ -38,29 +39,38 @@ pub struct DataFusion {
3839 relative_path : PathBuf ,
3940 pb : ProgressBar ,
4041 currently_executing_sql_tracker : CurrentlyExecutingSqlTracker ,
42+ default_config : HashMap < String , Option < String > > ,
4143}
4244
4345impl DataFusion {
4446 pub fn new ( ctx : SessionContext , relative_path : PathBuf , pb : ProgressBar ) -> Self {
47+ let default_config = SessionContext :: new ( )
48+ . state ( )
49+ . config ( )
50+ . options ( )
51+ . entries ( )
52+ . iter ( )
53+ . map ( |e| ( e. key . clone ( ) , e. value . clone ( ) ) )
54+ . collect ( ) ;
55+
4556 Self {
4657 ctx,
4758 relative_path,
4859 pb,
4960 currently_executing_sql_tracker : CurrentlyExecutingSqlTracker :: default ( ) ,
61+ default_config,
5062 }
5163 }
5264
5365 /// Add a tracker that will track the currently executed SQL statement.
5466 ///
5567 /// This is useful for logging and debugging purposes.
5668 pub fn with_currently_executing_sql_tracker (
57- self ,
69+ mut self ,
5870 currently_executing_sql_tracker : CurrentlyExecutingSqlTracker ,
5971 ) -> Self {
60- Self {
61- currently_executing_sql_tracker,
62- ..self
63- }
72+ self . currently_executing_sql_tracker = currently_executing_sql_tracker;
73+ self
6474 }
6575
6676 fn update_slow_count ( & self ) {
@@ -135,6 +145,34 @@ impl sqllogictest::AsyncDB for DataFusion {
135145 async fn shutdown ( & mut self ) { }
136146}
137147
148+ impl Drop for DataFusion {
149+ fn drop ( & mut self ) {
150+ let mut changed = false ;
151+
152+ for e in self . ctx . state ( ) . config ( ) . options ( ) . entries ( ) {
153+ if self . default_config . get ( & e. key ) != Some ( & e. value ) {
154+ if !changed {
155+ changed = true ;
156+ self . pb . println ( format ! (
157+ "SLT file {} left modified configuration" ,
158+ self . relative_path. display( )
159+ ) ) ;
160+ }
161+
162+ let old = self
163+ . default_config
164+ . get ( & e. key )
165+ . and_then ( |v| v. as_deref ( ) )
166+ . unwrap_or ( "NULL" ) ;
167+
168+ let new = e. value . as_deref ( ) . unwrap_or ( "NULL" ) ;
169+
170+ self . pb . println ( format ! ( " {}: {} -> {}" , e. key, old, new) ) ;
171+ }
172+ }
173+ }
174+ }
175+
138176async fn run_query (
139177 ctx : & SessionContext ,
140178 is_spark_path : bool ,
0 commit comments