Skip to content
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

Push SessionState into FileFormat (#4349) #4699

Merged
merged 3 commits into from
Dec 22, 2022

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Part of #4349
Relates to #4617
Relates to #3909 #3886

Rationale for this change

#4427 pushed ConfigOptions into ParquetFormat, however, the resulting Arc<Mutex<ConfigOptions>> is tricky to work with (#3886) and has unclear mutation semantics (#4617).

What changes are included in this PR?

Pushes SessionState into FileFormat which in turn will allow removing ConfigOptions from ParquetFormat and instead just fetching the configuration from the passed in SessionState

Are these changes tested?

Are there any user-facing changes?

@tustvold tustvold added the api change Changes the API exposed to users of the crate label Dec 21, 2022
@tustvold tustvold requested a review from alamb December 21, 2022 18:12
@github-actions github-actions bot added the core Core DataFusion crate label Dec 21, 2022
@@ -254,7 +258,7 @@ mod tests {
projection: Some(vec![0, 1, 2]),
limit: None,
table_partition_cols: vec![],
config_options: ConfigOptions::new().into_shareable(),
config_options: ctx.config_options(),
Copy link
Contributor Author

@tustvold tustvold Dec 21, 2022

Choose a reason for hiding this comment

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

I fully intend to remove this in a future PR, this should be retrieved from the TaskContext not baked into FileScanConfig

@@ -84,7 +76,7 @@ async fn test_with_parquet_word_aligned() -> Result<()> {
}

async fn get_exec(
ctx: &SessionContext,
ctx: &SessionState,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taking SessionState here is more correct as it allows the query to be executed against the same state

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks -- looks good to me, thank you @tustvold

I have only a minor quibble about the name used for variables of SessionState type (ctx) being confusing. Otherwise 👍

cc @mingmwang @andygrove

@@ -47,6 +48,7 @@ impl FileFormat for AvroFormat {

async fn infer_schema(
&self,
_ctx: &SessionState,
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this makes much more sense 👍

@@ -124,9 +129,10 @@ mod tests {
#[tokio::test]
async fn read_limit() -> Result<()> {
let session_ctx = SessionContext::new();
let task_ctx = session_ctx.task_ctx();
let ctx = session_ctx.state();
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe state would be a better name than ctx as there is already session_ctx which is a Context 🤔

@@ -1257,13 +1265,13 @@ mod tests {
}

async fn get_exec(
ctx: &SessionContext,
ctx: &SessionState,
Copy link
Contributor

Choose a reason for hiding this comment

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

I find the ctx name confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was just copying the naming used in things like TableProvider - I don't disagree that it is confusing. Renamed

@tustvold
Copy link
Contributor Author

I plan to merge this once CI turns green, so that I can base some further changes off it

@tustvold tustvold merged commit c9d6118 into apache:master Dec 22, 2022
@ursabot
Copy link

ursabot commented Dec 22, 2022

Benchmark runs are scheduled for baseline = 4917235 and contender = c9d6118. c9d6118 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Changes the API exposed to users of the crate core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants