jayzhan211 commented on code in PR #11940:
URL: https://github.com/apache/datafusion/pull/11940#discussion_r1713094141
##########
datafusion/sql/tests/common/mod.rs:
##########
@@ -50,36 +50,40 @@ impl Display for MockCsvType {
}
#[derive(Default)]
-pub(crate) struct MockContextProvider {
- options: ConfigOptions,
- udfs: HashMap<String, Arc<ScalarUDF>>,
- udafs: HashMap<String, Arc<AggregateUDF>>,
+pub(crate) struct MockSessionState {
+ scalar_functions: HashMap<String, Arc<ScalarUDF>>,
+ aggregate_functions: HashMap<String, Arc<AggregateUDF>>,
expr_planners: Vec<Arc<dyn ExprPlanner>>,
+ pub config_options: ConfigOptions,
}
-impl MockContextProvider {
- // Suppressing dead code warning, as this is used in integration test
crates
- #[allow(dead_code)]
- pub(crate) fn options_mut(&mut self) -> &mut ConfigOptions {
- &mut self.options
+impl MockSessionState {
+ pub fn with_expr_planner(mut self, expr_planner: Arc<dyn ExprPlanner>) ->
Self {
+ self.expr_planners.push(expr_planner);
+ self
}
- #[allow(dead_code)]
- pub(crate) fn with_udf(mut self, udf: ScalarUDF) -> Self {
- self.udfs.insert(udf.name().to_string(), Arc::new(udf));
+ pub fn with_scalar_functions(mut self, scalar_functions: Arc<ScalarUDF>)
-> Self {
Review Comment:
```suggestion
pub fn with_scalar_function(mut self, scalar_function: Arc<ScalarUDF>)
-> Self {
```
##########
datafusion/sql/tests/common/mod.rs:
##########
@@ -50,36 +50,40 @@ impl Display for MockCsvType {
}
#[derive(Default)]
-pub(crate) struct MockContextProvider {
- options: ConfigOptions,
- udfs: HashMap<String, Arc<ScalarUDF>>,
- udafs: HashMap<String, Arc<AggregateUDF>>,
+pub(crate) struct MockSessionState {
+ scalar_functions: HashMap<String, Arc<ScalarUDF>>,
+ aggregate_functions: HashMap<String, Arc<AggregateUDF>>,
expr_planners: Vec<Arc<dyn ExprPlanner>>,
+ pub config_options: ConfigOptions,
}
-impl MockContextProvider {
- // Suppressing dead code warning, as this is used in integration test
crates
- #[allow(dead_code)]
- pub(crate) fn options_mut(&mut self) -> &mut ConfigOptions {
- &mut self.options
+impl MockSessionState {
+ pub fn with_expr_planner(mut self, expr_planner: Arc<dyn ExprPlanner>) ->
Self {
+ self.expr_planners.push(expr_planner);
+ self
}
- #[allow(dead_code)]
- pub(crate) fn with_udf(mut self, udf: ScalarUDF) -> Self {
- self.udfs.insert(udf.name().to_string(), Arc::new(udf));
+ pub fn with_scalar_functions(mut self, scalar_functions: Arc<ScalarUDF>)
-> Self {
+ self.scalar_functions
+ .insert(scalar_functions.name().to_string(), scalar_functions);
self
}
- pub(crate) fn with_udaf(mut self, udaf: Arc<AggregateUDF>) -> Self {
+ pub fn with_aggregate_functions(
Review Comment:
```suggestion
pub fn with_aggregate_function(
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]