Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(sqllab): Allow running query without highlighting the code #27314

Closed

Conversation

soniagtm
Copy link
Contributor

@soniagtm soniagtm commented Mar 1, 2024

SUMMARY

When a user enters multiple queries in one tab and wants to execute each of them, they would have to highlight the SQL they want to execute (in previous versions), which would not be ideal for extremely long queries. To solve this problem, I created the getCurrentQuery function to allow executing each query without the need to highlight the specific query they wish to run. Instead, users can place the cursor at the intended query and press the RUN button.

It's important to note that queries must be separated by either at least one blank line or a semicolon, and no blank lines are allowed within the same query. When the cursor is placed at the blank lines between two queries, the upper query will be executed. This also handles the case when a semicolon is part of the query.

This function was actually created a long time ago, and I found that in newer versions, there already exists a shortcut key to execute the current query. I wanted to share this implementation in case it might be useful or maybe created as another shortcut key.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

Screen.Recording.2567-03-01.at.10.11.04.mov

After

Screen.Recording.2567-03-01.at.10.15.23.mov

TESTING INSTRUCTIONS

  1. Go to SQL Lab
  2. Enter multiple queries in one tab (separate with semicolon or with a line break)
  3. Move cursor to desired query to run
  4. Press Run button

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.39%. Comparing base (89d49e5) to head (f6ef7b6).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #27314      +/-   ##
==========================================
+ Coverage   67.37%   67.39%   +0.02%     
==========================================
  Files        1908     1908              
  Lines       74550    74609      +59     
  Branches     8317     8317              
==========================================
+ Hits        50225    50284      +59     
  Misses      22272    22272              
  Partials     2053     2053              
Flag Coverage Δ
javascript 57.31% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justinpark
Copy link
Member

justinpark commented Mar 1, 2024

@soniagtm Thank you for your suggestion. I appreciate your input, but I do have a few reservations regarding these changes.

Firstly, this modification will alter the behavior of the "Run" command. Users who employ multiple SQLs in a single run might experience some regression due to this change.

Secondly, investigating the query AST on the client side could potentially lead to critical bugs because it might execute unexpected SQL commands. To mitigate this risk, we should consider using a more stable solution like sqlglot, which is managed on the backend side.

Lastly, I have already introduced a similar feature that runs the current query using a shortcut(ctrl + shift + enter #24329). This means users wishing to run a query without highlighting can achieve the same results using this shortcut.
I hope this information helps clarify my approach.
I'm always open to further discussion.

Thanks,

@soniagtm
Copy link
Contributor Author

soniagtm commented Mar 5, 2024

Hi @justinpark,

Thank you for sharing your thoughts and concerns. Considering your reservations, I completely understand the importance of maintaining the current functionality and user experience.

Regarding the existing feature for running current query, it would indeed be beneficial if it could support executing queries without relying solely on semicolons, as is commonly seen in other tools. Additionally, it would be helpful to address cases where semicolons are part of the query. Perhaps these could be explored as potential areas for improvement in the future.

Thank you once again for your feedback. I'll close this PR.

@soniagtm soniagtm closed this Mar 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants