|
16 | 16 | // under the License. |
17 | 17 |
|
18 | 18 | use crate::config::{ |
19 | | - BALLISTA_GRPC_CLIENT_MAX_MESSAGE_SIZE, BALLISTA_IS_FINAL_STAGE, BALLISTA_JOB_NAME, |
20 | | - BALLISTA_SHUFFLE_FORMAT, BALLISTA_SHUFFLE_MEMORY_MODE, |
21 | | - BALLISTA_SHUFFLE_READER_FORCE_REMOTE_READ, BALLISTA_SHUFFLE_READER_MAX_REQUESTS, |
22 | | - BALLISTA_SHUFFLE_READER_REMOTE_PREFER_FLIGHT, BALLISTA_SHUFFLE_STORAGE_TYPE, |
23 | | - BALLISTA_SHUFFLE_STORAGE_URL, BALLISTA_STANDALONE_PARALLELISM, BallistaConfig, |
24 | | - ShuffleFormat, |
| 19 | + BALLISTA_GRPC_CLIENT_MAX_MESSAGE_SIZE, BALLISTA_JOB_NAME, BALLISTA_SHUFFLE_FORMAT, |
| 20 | + BALLISTA_SHUFFLE_MEMORY_MODE, BALLISTA_SHUFFLE_READER_FORCE_REMOTE_READ, |
| 21 | + BALLISTA_SHUFFLE_READER_MAX_REQUESTS, BALLISTA_SHUFFLE_READER_REMOTE_PREFER_FLIGHT, |
| 22 | + BALLISTA_SHUFFLE_STORAGE_TYPE, BALLISTA_SHUFFLE_STORAGE_URL, |
| 23 | + BALLISTA_STANDALONE_PARALLELISM, BallistaConfig, ShuffleFormat, |
25 | 24 | }; |
26 | 25 | use crate::planner::BallistaQueryPlanner; |
27 | 26 | use crate::serde::protobuf::KeyValuePair; |
@@ -513,16 +512,20 @@ impl SessionConfigExt for SessionConfig { |
513 | 512 | .extensions |
514 | 513 | .get::<BallistaConfig>() |
515 | 514 | .map(|c| c.is_final_stage()) |
516 | | - .unwrap_or_else(|| BallistaConfig::default().is_final_stage()) |
| 515 | + .unwrap_or(false) |
517 | 516 | } |
518 | 517 |
|
519 | 518 | fn with_ballista_is_final_stage(self, is_final: bool) -> Self { |
520 | | - if self.options().extensions.get::<BallistaConfig>().is_some() { |
521 | | - self.set_bool(BALLISTA_IS_FINAL_STAGE, is_final) |
522 | | - } else { |
523 | | - self.with_option_extension(BallistaConfig::default()) |
524 | | - .set_bool(BALLISTA_IS_FINAL_STAGE, is_final) |
525 | | - } |
| 519 | + // is_final_stage is an internal flag, not a user-configurable setting, |
| 520 | + // so we modify the BallistaConfig directly instead of using set_bool |
| 521 | + let ballista_config = self |
| 522 | + .options() |
| 523 | + .extensions |
| 524 | + .get::<BallistaConfig>() |
| 525 | + .cloned() |
| 526 | + .unwrap_or_default() |
| 527 | + .with_is_final_stage(is_final); |
| 528 | + self.with_option_extension(ballista_config) |
526 | 529 | } |
527 | 530 |
|
528 | 531 | fn with_ballista_grpc_metadata(self, metadata: HashMap<String, String>) -> Self { |
@@ -980,7 +983,7 @@ mod test { |
980 | 983 | }; |
981 | 984 |
|
982 | 985 | use crate::{ |
983 | | - config::BALLISTA_JOB_NAME, |
| 986 | + config::{BALLISTA_JOB_NAME, BallistaConfig}, |
984 | 987 | extension::{SessionConfigExt, SessionConfigHelperExt, SessionStateExt}, |
985 | 988 | }; |
986 | 989 |
|
@@ -1065,17 +1068,21 @@ mod test { |
1065 | 1068 | } |
1066 | 1069 |
|
1067 | 1070 | #[test] |
1068 | | - fn test_is_final_stage_serialization() { |
1069 | | - use crate::config::BALLISTA_IS_FINAL_STAGE; |
1070 | | - |
1071 | | - // Test that is_final_stage is included in key-value pairs |
| 1071 | + fn test_is_final_stage_internal_setting() { |
| 1072 | + // Test that is_final_stage is properly stored in BallistaConfig |
1072 | 1073 | let config = |
1073 | 1074 | SessionConfig::new_with_ballista().with_ballista_is_final_stage(true); |
1074 | | - let pairs = config.to_key_value_pairs(); |
1075 | 1075 |
|
1076 | | - let is_final_pair = pairs.iter().find(|p| p.key == BALLISTA_IS_FINAL_STAGE); |
1077 | | - assert!(is_final_pair.is_some()); |
1078 | | - assert_eq!(is_final_pair.unwrap().value, Some("true".to_string())); |
| 1076 | + // Verify via the getter |
| 1077 | + assert!(config.ballista_is_final_stage()); |
| 1078 | + |
| 1079 | + // Verify the internal BallistaConfig has the setting |
| 1080 | + let ballista_config = config |
| 1081 | + .options() |
| 1082 | + .extensions |
| 1083 | + .get::<BallistaConfig>() |
| 1084 | + .expect("BallistaConfig should exist"); |
| 1085 | + assert!(ballista_config.is_final_stage()); |
1079 | 1086 | } |
1080 | 1087 |
|
1081 | 1088 | #[test] |
|
0 commit comments