@@ -2972,6 +2972,10 @@ pub struct SpillConfig {
2972
2972
#[ clap( long, value_name = "VALUE" , default_value = "18446744073709551615" ) ]
2973
2973
/// Allow space in bytes to spill to local disk.
2974
2974
pub spill_local_disk_max_bytes : u64 ,
2975
+
2976
+ // TODO: We need to fix StorageConfig so that it supports environment variables and command line injections.
2977
+ #[ clap( skip) ]
2978
+ pub storage : Option < StorageConfig > ,
2975
2979
}
2976
2980
2977
2981
impl Default for SpillConfig {
@@ -2981,8 +2985,6 @@ impl Default for SpillConfig {
2981
2985
}
2982
2986
2983
2987
mod cache_config_converters {
2984
- use std:: path:: PathBuf ;
2985
-
2986
2988
use log:: warn;
2987
2989
2988
2990
use super :: * ;
@@ -3024,7 +3026,7 @@ mod cache_config_converters {
3024
3026
storage,
3025
3027
catalog,
3026
3028
cache,
3027
- mut spill,
3029
+ spill,
3028
3030
background,
3029
3031
catalogs : input_catalogs,
3030
3032
..
@@ -3044,18 +3046,7 @@ mod cache_config_converters {
3044
3046
catalogs. insert ( CATALOG_HIVE . to_string ( ) , catalog) ;
3045
3047
}
3046
3048
3047
- // Trick for cloud, perhaps we should introduce a new configuration for the local writeable root.
3048
- if cache. disk_cache_config . path != inner:: DiskCacheConfig :: default ( ) . path
3049
- && spill. spill_local_disk_path == inner:: SpillConfig :: default ( ) . path
3050
- {
3051
- spill. spill_local_disk_path = PathBuf :: from ( & cache. disk_cache_config . path )
3052
- . join ( "temp/_query_spill" )
3053
- . into_os_string ( )
3054
- . into_string ( )
3055
- . map_err ( |s| {
3056
- ErrorCode :: Internal ( format ! ( "failed to convert os string to string: {s:?}" ) )
3057
- } ) ?
3058
- } ;
3049
+ let spill = convert_local_spill_config ( spill, & cache. disk_cache_config ) ?;
3059
3050
3060
3051
Ok ( InnerConfig {
3061
3052
subcommand,
@@ -3066,7 +3057,7 @@ mod cache_config_converters {
3066
3057
storage : storage. try_into ( ) ?,
3067
3058
catalogs,
3068
3059
cache : cache. try_into ( ) ?,
3069
- spill : spill . try_into ( ) ? ,
3060
+ spill,
3070
3061
background : background. try_into ( ) ?,
3071
3062
} )
3072
3063
}
@@ -3129,37 +3120,51 @@ mod cache_config_converters {
3129
3120
}
3130
3121
}
3131
3122
3132
- impl TryFrom < SpillConfig > for inner:: SpillConfig {
3133
- type Error = ErrorCode ;
3123
+ fn convert_local_spill_config (
3124
+ spill : SpillConfig ,
3125
+ cache : & DiskCacheConfig ,
3126
+ ) -> Result < inner:: SpillConfig > {
3127
+ // Trick for cloud, perhaps we should introduce a new configuration for the local writeable root.
3128
+ let local_writeable_root = if cache. path != DiskCacheConfig :: default ( ) . path
3129
+ && spill. spill_local_disk_path . is_empty ( )
3130
+ {
3131
+ Some ( cache. path . clone ( ) )
3132
+ } else {
3133
+ None
3134
+ } ;
3134
3135
3135
- fn try_from ( value : SpillConfig ) -> std:: result:: Result < Self , Self :: Error > {
3136
- let SpillConfig {
3137
- spill_local_disk_path,
3138
- spill_local_disk_reserved_space_percentage : reserved,
3139
- spill_local_disk_max_bytes,
3140
- } = value;
3141
- if !reserved. is_normal ( )
3142
- || reserved. is_sign_negative ( )
3143
- || reserved > OrderedFloat ( 100.0 )
3144
- {
3145
- Err ( ErrorCode :: InvalidArgument ( format ! (
3146
- "invalid spill_local_disk_reserved_space_percentage: {reserved}"
3147
- ) ) ) ?;
3148
- }
3149
- Ok ( Self {
3150
- path : spill_local_disk_path,
3151
- reserved_disk_ratio : reserved / 100.0 ,
3152
- global_bytes_limit : spill_local_disk_max_bytes,
3136
+ let storage_params = spill
3137
+ . storage
3138
+ . map ( |storage| {
3139
+ let storage: InnerStorageConfig = storage. try_into ( ) ?;
3140
+ Ok :: < _ , ErrorCode > ( storage. params )
3153
3141
} )
3154
- }
3142
+ . transpose ( ) ?;
3143
+
3144
+ Ok ( inner:: SpillConfig {
3145
+ local_writeable_root,
3146
+ path : spill. spill_local_disk_path ,
3147
+ reserved_disk_ratio : spill. spill_local_disk_reserved_space_percentage / 100.0 ,
3148
+ global_bytes_limit : spill. spill_local_disk_max_bytes ,
3149
+ storage_params,
3150
+ } )
3155
3151
}
3156
3152
3157
3153
impl From < inner:: SpillConfig > for SpillConfig {
3158
3154
fn from ( value : inner:: SpillConfig ) -> Self {
3155
+ let storage = value. storage_params . map ( |params| {
3156
+ InnerStorageConfig {
3157
+ params,
3158
+ ..Default :: default ( )
3159
+ }
3160
+ . into ( )
3161
+ } ) ;
3162
+
3159
3163
Self {
3160
3164
spill_local_disk_path : value. path ,
3161
3165
spill_local_disk_reserved_space_percentage : value. reserved_disk_ratio * 100.0 ,
3162
3166
spill_local_disk_max_bytes : value. global_bytes_limit ,
3167
+ storage,
3163
3168
}
3164
3169
}
3165
3170
}
0 commit comments