@@ -55,6 +55,13 @@ pub trait SessionConfigExt {
55
55
/// ballista configuration initialized
56
56
fn new_with_ballista ( ) -> SessionConfig ;
57
57
58
+ /// update [SessionConfig] with Ballista specific settings
59
+ fn upgrade_for_ballista ( self ) -> SessionConfig ;
60
+
61
+ /// return ballista specific configuration or
62
+ /// creates one if does not exist
63
+ fn ballista_config ( & self ) -> BallistaConfig ;
64
+
58
65
/// Overrides ballista's [LogicalExtensionCodec]
59
66
fn with_ballista_logical_extension_codec (
60
67
self ,
@@ -154,19 +161,9 @@ impl SessionStateExt for SessionState {
154
161
let codec_logical = self . config ( ) . ballista_logical_extension_codec ( ) ;
155
162
let planner_override = self . config ( ) . ballista_query_planner ( ) ;
156
163
157
- let new_config = self
158
- . config ( )
159
- . options ( )
160
- . extensions
161
- . get :: < BallistaConfig > ( )
162
- . cloned ( )
163
- . unwrap_or_else ( BallistaConfig :: default) ;
164
+ let session_config = self . config ( ) . clone ( ) . upgrade_for_ballista ( ) ;
164
165
165
- let session_config = self
166
- . config ( )
167
- . clone ( )
168
- . with_option_extension ( new_config. clone ( ) )
169
- . ballista_restricted_configuration ( ) ;
166
+ let ballista_config = session_config. ballista_config ( ) ;
170
167
171
168
let builder =
172
169
SessionStateBuilder :: new_from_existing ( self ) . with_config ( session_config) ;
@@ -176,7 +173,7 @@ impl SessionStateExt for SessionState {
176
173
None => {
177
174
let planner = BallistaQueryPlanner :: < LogicalPlanNode > :: with_extension (
178
175
scheduler_url,
179
- new_config ,
176
+ ballista_config ,
180
177
codec_logical,
181
178
) ;
182
179
builder. with_query_planner ( Arc :: new ( planner) )
@@ -195,6 +192,26 @@ impl SessionConfigExt for SessionConfig {
195
192
. with_target_partitions ( 16 )
196
193
. ballista_restricted_configuration ( )
197
194
}
195
+
196
+ fn upgrade_for_ballista ( self ) -> SessionConfig {
197
+ // if ballista config is not provided
198
+ // one is created and session state is updated
199
+ let ballista_config = self . ballista_config ( ) ;
200
+
201
+ // session config has ballista config extension and
202
+ // default datafusion configuration is altered
203
+ // to fit ballista execution
204
+ self . with_option_extension ( ballista_config)
205
+ . ballista_restricted_configuration ( )
206
+ }
207
+
208
+ fn ballista_config ( & self ) -> BallistaConfig {
209
+ self . options ( )
210
+ . extensions
211
+ . get :: < BallistaConfig > ( )
212
+ . cloned ( )
213
+ . unwrap_or_else ( BallistaConfig :: default)
214
+ }
198
215
fn with_ballista_logical_extension_codec (
199
216
self ,
200
217
codec : Arc < dyn LogicalExtensionCodec > ,
0 commit comments