Repository navigation
Add a live view for streaming queries to the Beam SQL shell - #41408
ahmedabu98 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR adds a JLine 3 full-screen live terminal view (LiveResultView and LiveResultScreen) to the Beam SQL shell (BeamSqlLine) for displaying streaming (unbounded) SELECT results in real time with change-data-capture operation codes (+I, -U, +U, -D). The implementation is well-structured, cleanly separates rendering logic from terminal I/O, and includes thorough unit and integration tests.
🔍 General Feedback
- The separation of concerns between
LiveResultScreen(pure layout and state ring buffer) andLiveResultView(JLine 3 terminal management and key handling) makes the code easy to follow and test. - Consider handling array types for values in
MapandIterablecontainers (or top-levelFieldType.BYTESif ever stored differently) consistently, and guard against non-positivemaxRowsinLiveResultScreen.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
| bodyHeight = height - CHROME_LINES; | ||
|
|
||
| int tableWidth = tableWidth(); | ||
| offsetX = Math.max(0, Math.min(offsetX, tableWidth - width)); |
There was a problem hiding this comment.
🟡 Medium: When all columns in the result have already reached MAX_COLUMN_WIDTH while the user is scrolled to the right, or if the terminal is widened while scrolled, offsetX is clamped here during render. However, if the user presses right() multiple times when tableWidth <= width (or beyond tableWidth - width), right() unconditionally increments offsetX and triggers a redundant frame render even though offsetX will immediately be clamped back to the same value in render(). Clamping or bounding offsetX in right() (or storing the last maxOffsetX) would avoid unnecessary redraws when pressing the right arrow at the horizontal boundary.
| public void show(LiveResult result) throws IOException { | ||
| LiveResultScreen screen = new LiveResultScreen(TITLE, result.getSchema(), MAX_ROWS); | ||
| Runnable quit = () -> {}; | ||
| long start = System.currentTimeMillis(); |
There was a problem hiding this comment.
🟢 Low: System.currentTimeMillis() is subject to wall-clock adjustments (e.g., NTP syncs), which can cause now - lastFrame, now - lastSizeCheck, or elapsed to jump backward or stall redraws. Using TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) provides a monotonic clock for elapsed time and frame/resize throttling.
| long start = System.currentTimeMillis(); | |
| long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); |
|
assign set of reviewers |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #41408 +/- ##
============================================
+ Coverage 57.88% 57.93% +0.05%
- Complexity 2733 2831 +98
============================================
Files 1206 1208 +2
Lines 172522 172873 +351
Branches 2260 2320 +60
============================================
+ Hits 99861 100161 +300
- Misses 69974 70006 +32
- Partials 2687 2706 +19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @chamikaramj for label iceberg. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Fixes #41313
#41315 made unbounded SELECTs return rows while the pipeline runs. This PR adds a full-screen view on top of that, much like the changelog mode in Flink's SQL client.
When the shell runs in a terminal, a streaming (unbounded) SELECT opens the view:
opcolumn shows each row's change kind:+I,-U,+Uor-D. It comes from each element'sValueKind, so a Kafka or Pub/Sub read shows+Ifor every row.q, Esc or Ctrl+C closes the view and cancels the pipeline.The view draws with JLine 3 in its own terminal, while sqlline keeps its jline2 line editor. It leaves signal handling to the shell, so Ctrl+C still cancels the query. Without a terminal, for example when output is piped, the shell keeps printing rows the plain way.