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

fix(sqla): apply jinja to metrics #19565

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

villebro
Copy link
Member

@villebro villebro commented Apr 6, 2022

SUMMARY

Currently template kwargs like from_dttm aren't available in metrics expressions. This fixes the issue and makes the expression processing code DRYer by calling the same code path in all places where the SQLA model handles adhoc expressions.

AFTER

Now the jinja in the adhoc metric that references from_dttm renders successfully:
image

BEFORE

Previously trying to reference the from_dttm value would cause rendering to fail:
image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #19565 (5026067) into master (e1ef2ba) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master   #19565   +/-   ##
=======================================
  Coverage   66.59%   66.59%           
=======================================
  Files        1682     1682           
  Lines       64321    64317    -4     
  Branches     6561     6561           
=======================================
- Hits        42837    42835    -2     
+ Misses      19783    19781    -2     
  Partials     1701     1701           
Flag Coverage Δ
hive 52.69% <100.00%> (-0.03%) ⬇️
mysql 81.91% <100.00%> (+<0.01%) ⬆️
postgres 81.95% <100.00%> (+<0.01%) ⬆️
presto 52.54% <100.00%> (-0.03%) ⬇️
python 82.39% <100.00%> (+<0.01%) ⬆️
sqlite 81.73% <100.00%> (+<0.01%) ⬆️
unit 47.22% <6.25%> (+<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 89.45% <100.00%> (+0.14%) ⬆️

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 e1ef2ba...5026067. Read the comment docs.

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

LGTM. Test in my local, and behavior is expected.

image

@villebro villebro merged commit 34b5576 into apache:master Apr 7, 2022
@villebro villebro deleted the villebro/metrics-tp branch April 7, 2022 11:05
villebro added a commit that referenced this pull request Apr 8, 2022
philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels lts-v1 preset-io size/M 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

{{ from_dttm }} and {{ to_dttm }} Jinja special variables are not rendered in Custom SQL metrics
4 participants