Skip to content

Extract ExecutionContext to its own module and cli code to CliApp #131

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 1 commit into from
Sep 12, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Sep 12, 2024

Part of #132

This PR extracts the ExecutionContext into its own module, as a first step towards
adding additional features (e.g. other table formats)

Having it as its own module will allow us to test it more easily and keeps the boundaries of the software clearer.

Changes:

  1. Move ExecutionContext to its own module
  2. Make fields not pub
  3. Encapsulate the CLI code into its own module

Copy link
Contributor Author

@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.

FYI @matthewmturner this is step one of a few PRs I have planned. I filed #132 with my rough plan of attack

@@ -73,7 +73,7 @@ pub fn normal_mode_handler(app: &mut App, key: KeyEvent) {
let execution = Arc::clone(&app.execution);
let _event_tx = app.app_event_tx.clone();
tokio::spawn(async move {
let client = &execution.flightsql_client;
let client = execution.flightsql_client();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just made the fields non pub and made accessors so the API surface area was clearer

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup makes sense, i had started to use that approach for more recent work but i know theres some remaining pub stuff

"Cannot execute both files and commands at the same time"
)),
}
/// Encapsulates the command line interface
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored a bunch of free functions into a struct (which I plan to move to its own module soon)

pub struct ExecutionContext {
pub session_ctx: SessionContext,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

when I made these non pub it turned out much of it isn't used, so I removed the unused fields for now


/// Structure for executing queries either locally or remotely (via FlightSQL)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the core reason for this PR -- to move this structure to its own module

It still depends on app::AppEvent as well as printing to stdout. I plan to move the display of results code into different structures in the next PR

@alamb alamb changed the title Extract execution context to its own module Extract ExecutionContext to its own module Sep 12, 2024
@alamb alamb changed the title Extract ExecutionContext to its own module Extract ExecutionContext to its own module and cli code to CliApp Sep 12, 2024
@matthewmturner matthewmturner merged commit 652ac9a into datafusion-contrib:main Sep 12, 2024
3 checks passed
@alamb alamb deleted the alamb/split_execution branch September 12, 2024 12:46
matthewmturner pushed a commit that referenced this pull request Sep 12, 2024
Second part of
#132
Follow on to
#131

The rationale here is to split out the logic that handles display (e.g.
`println!` and `Query` from the actual execution, again so that we can
update / test the underying `ExecutionContext` without having the UI
affected

This PR moves the "display" releated logic out of the ExecutionContext
and into the app / CLI modules respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants