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: add support for comments in adhoc clauses #19248

Merged
merged 5 commits into from
Mar 18, 2022

Conversation

villebro
Copy link
Member

@villebro villebro commented Mar 18, 2022

SUMMARY

Add support for comments in adhoc clauses to make it easier to comment out sections of adhoc metrics/filters when developing charts. This is done by making sure that all freeform queries containing a single line comment -- are suffixed with a line change.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

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

@codecov
Copy link

codecov bot commented Mar 18, 2022

Codecov Report

Merging #19248 (5dadc5b) into master (50902d5) will increase coverage by 0.00%.
The diff coverage is 85.10%.

❗ Current head 5dadc5b differs from pull request most recent head 3aabb7c. Consider uploading reports for the commit 3aabb7c to get more accurate results

@@           Coverage Diff           @@
##           master   #19248   +/-   ##
=======================================
  Coverage   66.78%   66.79%           
=======================================
  Files        1670     1670           
  Lines       64401    64425   +24     
  Branches     6501     6502    +1     
=======================================
+ Hits        43009    43030   +21     
- Misses      19708    19711    +3     
  Partials     1684     1684           
Flag Coverage Δ
javascript 51.34% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/connectors/sqla/models.py 90.05% <71.42%> (-0.12%) ⬇️
superset/viz.py 58.29% <75.00%> (+0.03%) ⬆️
superset/sql_parse.py 98.30% <83.33%> (-0.65%) ⬇️
...kages/superset-ui-core/src/query/processFilters.ts 100.00% <100.00%> (ø)
superset/common/query_object.py 95.72% <100.00%> (+0.04%) ⬆️
superset/utils/core.py 90.28% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50902d5...3aabb7c. Read the comment docs.

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

This looks great!

@@ -23,6 +23,14 @@ import { QueryObjectFilterClause } from './types/Query';
import { isSimpleAdhocFilter } from './types/Filter';
import convertFilter from './convertFilter';

function sanitizeClause(clause: string): string {
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be done on backend, no?

if open_parens > 0:
raise QueryClauseValidationException("Unclosed parenthesis in filter clause")

if previous_token and previous_token.ttype in Comment:
if previous_token.value[-1] != "\n":
clause = f"{clause}\n"
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see it is done in the backend. But I still don't understand why we also do this in the frontend?

@suddjian suddjian merged commit f341025 into apache:master Mar 18, 2022
sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Mar 18, 2022
* feat: add support for comments in adhoc clauses

* sanitize remaining freeform clauses

* sanitize adhoc having in frontend

* address review comment

(cherry picked from commit f341025)
@sadpandajoe
Copy link
Member

🏷️ preset:2022.11

@villebro villebro deleted the villebro/adhoc-comment branch March 21, 2022 09:31
villebro added a commit that referenced this pull request Mar 21, 2022
* feat: add support for comments in adhoc clauses

* sanitize remaining freeform clauses

* sanitize adhoc having in frontend

* address review comment
yangfei4913438 pushed a commit to choice-form/superset that referenced this pull request Apr 2, 2022
* feat: add support for comments in adhoc clauses

* sanitize remaining freeform clauses

* sanitize adhoc having in frontend

* address review comment
villebro added a commit that referenced this pull request Apr 3, 2022
* feat: add support for comments in adhoc clauses

* sanitize remaining freeform clauses

* sanitize adhoc having in frontend

* address review comment

(cherry picked from commit f341025)
@mistercrunch mistercrunch added 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants