Skip to content

add extension system to SessionConfig - #2940

Merged
alamb merged 1 commit into
apache:masterfrom
crepererum:crepererum/session_config_ext
Jul 19, 2022
Merged

alamb merged 1 commit into
apache:masterfrom
crepererum:crepererum/session_config_ext

Conversation

@crepererum

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #2939.

Rationale for this change

This is helpful for application built on top of DataFusion that want to
pass certain query-scoped data structures around, e.g. for tracing or
caching.

What changes are included in this PR?

Allow SessionConfig to carry opaque extensions around.

This is loosely inspired by:
https://github.com/hyperium/http/blob/34a9d6bdab027948d6dea3b36d994f9cbaf96f75/src/extensions.rs#L6-L28

Are there any user-facing changes?

SessionConfig::{with,get}_extension. No breaking change.

@github-actions github-actions Bot added the core Core DataFusion crate label Jul 18, 2022

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @crepererum -- I like the code 👍 I have some documentation suggestions but otherwise looks good to go to me

map
}

/// Add extensions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you possibly add some documentation on what one might do with extensions (e.g. attach arbitrary data to nodes) and mention the system specific metric usecase?

Perhaps moving the test into a docstring comment would be the most helpful for future readers to discover this functionality

It is probably also good to document that only a single entry for at type is allowed (e.g. what happens if you register two extensions with the same type).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

self
}

/// Get extension.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Get extension.
/// Get extension, if any, for the specific Id

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"..for specific type". The ID is invisible to the user. I've heavily extended the docs to make that clearer.

This is helpful for application built on top of DataFusion that want to
pass certain query-scoped data structures around, e.g. for tracing or
caching.

This is loosely inspired by:
https://github.com/hyperium/http/blob/34a9d6bdab027948d6dea3b36d994f9cbaf96f75/src/extensions.rs#L6-L28

Closes apache#2939.
@crepererum
crepererum force-pushed the crepererum/session_config_ext branch from 2bc9267 to 3e7073a Compare July 19, 2022 08:22
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #2940 (39df2d6) into master (944ef3d) will decrease coverage by 0.02%.
The diff coverage is 7.69%.

❗ Current head 39df2d6 differs from pull request most recent head 3e7073a. Consider uploading reports for the commit 3e7073a to get more accurate results

@@            Coverage Diff             @@
##           master    #2940      +/-   ##
==========================================
- Coverage   85.44%   85.42%   -0.03%     
==========================================
  Files         275      275              
  Lines       49690    49703      +13     
==========================================
+ Hits        42458    42459       +1     
- Misses       7232     7244      +12     
Impacted Files Coverage Δ
datafusion/core/src/execution/context.rs 77.95% <7.69%> (-1.12%) ⬇️
datafusion/expr/src/window_frame.rs 92.43% <0.00%> (-0.85%) ⬇️
datafusion/expr/src/logical_plan/plan.rs 77.14% <0.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 944ef3d...3e7073a. Read the comment docs.

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@alamb
alamb merged commit 9aa38c3 into apache:master Jul 19, 2022
@ursabot

ursabot commented Jul 19, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 944ef3d and contender = 9aa38c3. 9aa38c3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@mingmwang

Copy link
Copy Markdown
Contributor

I'm not sure whether this extension points should be added to RuntimeEnv or RuntimeConfig or SessionConfig.
My original understanding is SessionConfig just hold the configuration entries to control the planer(logical/physical) and runtime behavior. Those configuration settings are session specific and can be changed on the fly in a distributed multi tenant system(Ballista). And RuntimeEnv and RuntimeConfig hold the the static configurations which are shared among multiple users and can not changed on the fly.

@crepererum

Copy link
Copy Markdown
Contributor Author

@mingmwang we can for sure have extension for RuntimeEnv and RuntimeConfig as well.

@alamb

alamb commented Aug 4, 2022

Copy link
Copy Markdown
Contributor

I agree that a similar system for RuntimeEnv would be a reasonable idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension mechanism for SessionConfig

6 participants