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

Rewrite #100

Merged
Merged

Conversation

matthewmturner
Copy link
Collaborator

@matthewmturner matthewmturner commented Aug 25, 2024

This PR is a complete rewrite of the app based on a different TUI I was working on that also had a datafusion query editor / results viewer. i think the architecture of this app is much better than the original datafusion tui. It didnt have all the other features like logs / viewing context info, query history yet so ive started to add those back and ill look to reconcile the cleanup vs what is in the README.

I might strip out some old features if i think it makes sense.

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.

I can't say I went through this code particularly carefully

I did try it manually

caro run

It built!

But then I typed in show all and it bombed out like this:

WID :dft::app          ││11:31:50:DEBUG:dft::app::state:src/app/state/mod.rs:55:Initializing state                                                                                       │
│EWID :dft::app::handlers││11:31:50:DEBUG:dft::app::state:src/app/state/mod.rs:78:No config, using default                                                                                 │
│EWID :dft::app::state   ││11:31:50:INFO :dft::app:Running app with state: AppState { config: AppConfig { datafusion: DataFusionConfig { stream_batch_size: 1 }, display: DisplayConfig { t│
│                        ││         ick_rate: 5.0, frame_rate: 5.0 }, interaction: InteractionConfig { mouse: false, paste: false } }, should_quit: false, data_dir: "/Users/andrewlamb/.co│
│                        ││         nfig/dft", explore_tab: ExploreTabState { editor: TextArea { lines: ["Enter a query here."], block: None, style: Style { fg: None, bg: None, underline_│
│                        ││         color: None, add_modifier: NONE, sub_modifier: NONE }, cursor: (0, 0), tab_len: 4, hard_tab_indent: false, history: History { index: 0, max_items: 50, │
│                        ││         edits: [] }, cursor_line_style: Style { fg: None, bg: None, underline_color: None, add_modifier: UNDERLINED, sub_modifier: NONE }, line_number_style: S│
│                        ││         ome(Style { fg: None, bg: Some(Rgb(156, 163, 175)), underline_color: None, add_modifier: NONE, sub_modifier: NONE }), viewport: Viewport(0), cursor_sty│
│                        ││         le: Style { fg: None, bg: None, underline_color: None, add_modifier: REVERSED, sub_modifier: NONE }, yank: Piece(""), alignment: Left, placeholder: "",│
│                        ││          placeholder_style: Style { fg: Some(DarkGray), bg: None, underline_color: None, add_modifier: NONE, sub_modifier: NONE }, mask: None, selection_start:│
│                        ││          None, select_style: Style { fg: None, bg: Some(LightBlue), underline_color: None, add_modifier: NONE, sub_modifier: NONE } }, editor_editable: false, │
│                        ││         query_results: None, query_results_state: None, query_error: None }, logs_tab: LogsTabState, tabs: Tabs { selected: Queries } }                        │
│                        ││11:31:50:ERROR:dft::app:src/app/mod.rs:231:Error reading DDL: Os { code: 2, kind: NotFound, message: "No such file or directory" }                              │
│                        ││11:31:50:DEBUG:dft::app:src/app/mod.rs:174:Render delay: 200ms                                                                                                  │
│                        ││11:31:50:DEBUG:dft::app:src/app/mod.rs:178:Tick delay: 200ms                                                                                                    │
│                        ││11:31:50:DEBUG:dft::app:src/app/mod.rs:187:Tick interval: Interval { delay: Sleep { inner: Inner, entry: TimerEntry { driver: MultiThread(multi_thread::Handle {│
│                        ││          ... }), inner: UnsafeCell { .. }, deadline: Instant { tv_sec: 3589732, tv_nsec: 972390833 }, registered: false, _m: PhantomPinned } }, period: 200ms, │
│                        ││         missed_tick_behavior: Burst }                                                                                                                          │
│                        ││11:31:50:DEBUG:dft::app:src/app/mod.rs:189:Render interval: Interval { delay: Sleep { inner: Inner, entry: TimerEntry { driver: MultiThread(multi_thread::Handle│
│                        ││          { ... }), inner: UnsafeCell { .. }, deadline: Instant { tv_sec: 3589732, tv_nsec: 972532166 }, registered: false, _m: PhantomPinned } }, period: 200ms│
│                        ││         , missed_tick_behavior: Burst }                                                                                                                        │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char('s'), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char('h'), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char('o'), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char('w'), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char(' '), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char('a'), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char('l'), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││11:31:52:DEBUG:dft::app::handlers:src/app/handlers/mod.rs:28:crossterm::event: Key(KeyEvent { code: Char('l'), modifiers: KeyModifiers(0x0), kind: Press, state:│
│                        ││          KeyEventState(0x0) })                                                                                                                                 │
│                        ││                                                                                                                                                                │
│                        ││

That being said, what I suggest is that you merge this PR and keep iterating on main.

What I'll try to do tomorrow (I swear!) is to add a command line support for -f <file> and then use that as a way to test out the DataFusion context / integration.

Once I have it so I can run stuff in scripted fashion, then I think I would like to start integrating things (first thing would be apache/datafusion#10792) and see how it goes

clap = { version = "4.5.1", features = ["derive"] }
color-eyre = "0.6.3"
crossterm = { version = "0.28.1", features = ["event-stream"] }
datafusion = "40.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

🚀

pub struct ExecutionContext {
pub session_ctx: SessionContext,
pub config: DataFusionConfig,
/// Sends WSMessages to DataFusion. We have a separate sender for this, rather than piggy
Copy link
Contributor

Choose a reason for hiding this comment

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

the ws message stuff may be out of date...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lol yes, i need to clean up some comments that were from other app

@matthewmturner
Copy link
Collaborator Author

@alamb appreciate you testing it out so quick. i will try out SHOW ALL. it currently executes the sql found in ~/.datafusion/datafusionrc on startup so you could just put something there. for example I have this right now while i am testing out results scrolling functionality:

CREATE TABLE wide AS VALUES (1,2,3,4,5,6,7,8,9,0);

CREATE TABLE long AS VALUES
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5),
    (1,2,3,4,5)
;

@matthewmturner
Copy link
Collaborator Author

@alamb fyi i ran SHOW ALL and the query worked well, but i agree the logs display needs improvement. i mainly focused on getting that functional again first and havent spent much time on the display.

image

@matthewmturner
Copy link
Collaborator Author

also, ive given zero attention to coming up with nice colors so far, i fully intend to give that proper attention at some point

@matthewmturner matthewmturner merged commit 44eeeeb into datafusion-contrib:main Aug 25, 2024
3 checks passed
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