-
Notifications
You must be signed in to change notification settings - Fork 8
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
Test DDL #161
Merged
matthewmturner
merged 4 commits into
datafusion-contrib:main
from
matthewmturner:feat/ddl-validation
Sep 24, 2024
Merged
Test DDL #161
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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 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 |
---|---|---|
|
@@ -16,93 +16,19 @@ | |
// under the License. | ||
|
||
use core::cell::RefCell; | ||
use std::time::Duration; | ||
|
||
use color_eyre::Result; | ||
use datafusion::arrow::array::RecordBatch; | ||
use datafusion::sql::sqlparser::keywords; | ||
use ratatui::crossterm::event::KeyEvent; | ||
use ratatui::style::palette::tailwind; | ||
use ratatui::style::{Modifier, Style}; | ||
use ratatui::widgets::TableState; | ||
use tokio::task::JoinHandle; | ||
use tui_textarea::TextArea; | ||
|
||
use crate::app::ExecutionError; | ||
use crate::config::AppConfig; | ||
use crate::execution::ExecutionStats; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Query { | ||
sql: String, | ||
results: Option<Vec<RecordBatch>>, | ||
num_rows: Option<usize>, | ||
error: Option<String>, | ||
execution_time: Duration, | ||
execution_stats: Option<ExecutionStats>, | ||
} | ||
|
||
impl Query { | ||
pub fn new( | ||
sql: String, | ||
results: Option<Vec<RecordBatch>>, | ||
num_rows: Option<usize>, | ||
error: Option<String>, | ||
execution_time: Duration, | ||
execution_stats: Option<ExecutionStats>, | ||
) -> Self { | ||
Self { | ||
sql, | ||
results, | ||
num_rows, | ||
error, | ||
execution_time, | ||
execution_stats, | ||
} | ||
} | ||
|
||
pub fn sql(&self) -> &String { | ||
&self.sql | ||
} | ||
|
||
pub fn execution_time(&self) -> &Duration { | ||
&self.execution_time | ||
} | ||
|
||
pub fn set_results(&mut self, results: Option<Vec<RecordBatch>>) { | ||
self.results = results; | ||
} | ||
|
||
pub fn results(&self) -> &Option<Vec<RecordBatch>> { | ||
&self.results | ||
} | ||
|
||
pub fn set_num_rows(&mut self, num_rows: Option<usize>) { | ||
self.num_rows = num_rows; | ||
} | ||
|
||
pub fn num_rows(&self) -> &Option<usize> { | ||
&self.num_rows | ||
} | ||
|
||
pub fn set_error(&mut self, error: Option<String>) { | ||
self.error = error; | ||
} | ||
|
||
pub fn error(&self) -> &Option<String> { | ||
&self.error | ||
} | ||
|
||
pub fn set_execution_time(&mut self, elapsed_time: Duration) { | ||
self.execution_time = elapsed_time; | ||
} | ||
|
||
pub fn execution_stats(&self) -> &Option<ExecutionStats> { | ||
&self.execution_stats | ||
} | ||
|
||
pub fn set_execution_stats(&mut self, stats: Option<ExecutionStats>) { | ||
self.execution_stats = stats; | ||
} | ||
} | ||
|
||
pub fn get_keywords() -> Vec<String> { | ||
keywords::ALL_KEYWORDS | ||
|
@@ -129,11 +55,11 @@ pub fn keyword_style() -> Style { | |
pub struct SQLTabState<'app> { | ||
editor: TextArea<'app>, | ||
editor_editable: bool, | ||
query: Option<Query>, | ||
query_results_state: Option<RefCell<TableState>>, | ||
result_batches: Option<Vec<RecordBatch>>, | ||
results_page: Option<usize>, | ||
execution_error: Option<ExecutionError>, | ||
execution_task: Option<JoinHandle<Result<()>>>, | ||
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. Playing with the test code made me realize this would be useful to have for long running queries. |
||
} | ||
|
||
impl<'app> SQLTabState<'app> { | ||
|
@@ -149,11 +75,11 @@ impl<'app> SQLTabState<'app> { | |
Self { | ||
editor: textarea, | ||
editor_editable: false, | ||
query: None, | ||
query_results_state: None, | ||
result_batches: None, | ||
results_page: None, | ||
execution_error: None, | ||
execution_task: None, | ||
} | ||
} | ||
|
||
|
@@ -215,14 +141,6 @@ impl<'app> SQLTabState<'app> { | |
self.editor_editable | ||
} | ||
|
||
pub fn set_query(&mut self, query: Query) { | ||
self.query = Some(query); | ||
} | ||
|
||
pub fn query(&self) -> &Option<Query> { | ||
&self.query | ||
} | ||
|
||
// TODO: Create Editor struct and move this there | ||
pub fn next_word(&mut self) { | ||
self.editor | ||
|
@@ -288,4 +206,12 @@ impl<'app> SQLTabState<'app> { | |
} | ||
} | ||
} | ||
|
||
pub fn execution_task(&mut self) -> &mut Option<JoinHandle<Result<()>>> { | ||
&mut self.execution_task | ||
} | ||
|
||
pub fn set_execution_task(&mut self, task: JoinHandle<Result<()>>) { | ||
self.execution_task = Some(task); | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query
was no longer used