-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Add Arc<ConfigOptions>
to ScalarFunctionArgs
, don't copy ConfigOptions
on each query
#16970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
27289fe
Add `ConfigOptions` to ExecutionProps when execution is started
alamb 2e0ffcd
Add ConfigOptions to ScalarFunctionArgs, refactor AsyncScalarUDF.invo…
Omega359 383e5a8
Updated OptimizerConfig.options() -> Arc<ConfigOptions> to eliminate …
Omega359 5bad5f7
Merge remote-tracking branch 'upstream/main' into udf_config_options
Omega359 7524758
Test update.
Omega359 55d3b73
Add note in upgrade guide
alamb 92af2d7
Use Arc all the way down
alamb 2fa1b82
Merge pull request #6 from alamb/alamb/just_use_arc
Omega359 14c90ed
start_execution -> mark_start_execution
Omega359 d7d2247
Update datafusion/expr/src/execution_props.rs
Omega359 7758028
Merge remote-tracking branch 'apache/main' into udf_config_options
alamb 6470b46
Update comments
alamb 436256e
Avoid API breakage via #deprecated
alamb f3fd77b
Update upgrade guide for Arc<ConfigOptions> change
alamb 238a7ed
Apply suggestions from code review
alamb d6588db
fmt
alamb 0442fa8
Merge remote-tracking branch 'apache/main' into udf_config_options
alamb ffbb331
Merge branch 'main' into udf_config_options
alamb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ use arrow::array::{ | |
use arrow::compute::kernels::numeric::add; | ||
use arrow::datatypes::{DataType, Field, Schema}; | ||
use arrow_schema::extension::{Bool8, CanonicalExtensionType, ExtensionType}; | ||
use arrow_schema::{ArrowError, FieldRef}; | ||
use arrow_schema::{ArrowError, FieldRef, SchemaRef}; | ||
use datafusion::common::test_util::batches_to_string; | ||
use datafusion::execution::context::{FunctionFactory, RegisterFunction, SessionState}; | ||
use datafusion::prelude::*; | ||
|
@@ -1786,3 +1786,58 @@ async fn test_extension_based_udf() -> Result<()> { | |
ctx.deregister_table("t")?; | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_config_options_work_for_scalar_func() -> Result<()> { | ||
#[derive(Debug)] | ||
struct TestScalarUDF { | ||
signature: Signature, | ||
} | ||
|
||
impl ScalarUDFImpl for TestScalarUDF { | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
fn name(&self) -> &str { | ||
"TestScalarUDF" | ||
} | ||
|
||
fn signature(&self) -> &Signature { | ||
&self.signature | ||
} | ||
|
||
fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> { | ||
Ok(DataType::Utf8) | ||
} | ||
|
||
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> { | ||
let tz = args.config_options.execution.time_zone.clone(); | ||
Ok(ColumnarValue::Scalar(ScalarValue::from(tz))) | ||
} | ||
} | ||
|
||
let udf = ScalarUDF::from(TestScalarUDF { | ||
signature: Signature::uniform(1, vec![DataType::Utf8], Volatility::Stable), | ||
}); | ||
|
||
let mut config = SessionConfig::new(); | ||
config.options_mut().execution.time_zone = "AEST".into(); | ||
|
||
let ctx = SessionContext::new_with_config(config); | ||
|
||
ctx.register_udf(udf.clone()); | ||
|
||
let df = ctx.read_empty()?; | ||
let df = df.select(vec![udf.call(vec![lit("a")]).alias("a")])?; | ||
let actual = df.collect().await?; | ||
|
||
let expected_schema = Schema::new(vec![Field::new("a", DataType::Utf8, false)]); | ||
let expected = RecordBatch::try_new( | ||
SchemaRef::from(expected_schema), | ||
vec![create_array!(Utf8, ["AEST"])], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
)?; | ||
|
||
assert_eq!(expected, actual[0]); | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.