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

[Jinja] Make Presto template functions backwards compatible #7993

Conversation

etr2460
Copy link
Member

@etr2460 etr2460 commented Aug 6, 2019

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

#7782 changed the behavior of the presto.latest_partition Jinja template function to return an array instead of a string, breaking all sql metrics/slices that used it. This PR makes the latest_partition function behave the same as prior to this change, introduces a new function presto.latest_partitions that can be used with this new behavior, and provides documentation for the change in code.

It might be worth renaming these functions if we were ever to do a breaking release of superset, but i don't see that happening any time soon.

TEST PLAN

Tested locally, CI

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@michellethomas @john-bodley @betodealmeida @DiggidyDave @xtinec


return self._first_latest_partition(table_name)

def _first_latest_partition(self, table_name: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this function as it's only called once from above. Additionally the logic looks similar to latest_partitions and thus it seems line #253 could simply be,

return self.latest_partitions(table_name)[0]

Note for both latest_partition and latest_partitions an IndexError could be thrown and thus it's probably prudent to add mention in the docstring, i.e.,

:param table_name: table name in the format `schema.table`
:return: the first (or only) value in the latest partition array
:raises IndexError: If no partition exists

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@etr2460 etr2460 force-pushed the erik-ritter--fix-latest-partition-jinja branch from d5eb101 to 029ef2a Compare August 6, 2019 20:27
@codecov-io
Copy link

Codecov Report

Merging #7993 into master will increase coverage by 0.02%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #7993      +/-   ##
=========================================
+ Coverage   65.57%   65.6%   +0.02%     
=========================================
  Files         469     469              
  Lines       22414   22417       +3     
  Branches     2431    2431              
=========================================
+ Hits        14699   14707       +8     
+ Misses       7594    7589       -5     
  Partials      121     121
Impacted Files Coverage Δ
superset/jinja_context.py 76.69% <75%> (-0.31%) ⬇️
superset/utils/core.py 87.83% <0%> (+0.16%) ⬆️
superset/db_engine_specs/sqlite.py 66.66% <0%> (+20.83%) ⬆️

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 e455f1d...029ef2a. Read the comment docs.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Small change request: There's a reference to latest_partition('some_table') in docs/sqllab.rst; I'm assuming that method is deprecated in favour of first_latest_partition('first table')? I'm hoping to break out the template part into a page of it's own soon as templating isn't really a subset of SQLLab, but until then it would be good to keep the existing docs as up to date as possible.

@etr2460 etr2460 force-pushed the erik-ritter--fix-latest-partition-jinja branch from 029ef2a to e99df38 Compare August 7, 2019 16:00
@etr2460
Copy link
Member Author

etr2460 commented Aug 7, 2019

@villebro comment addressed!

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Hehe thanks @etr2460 sorry for being a pain! 😁

@etr2460
Copy link
Member Author

etr2460 commented Aug 7, 2019

Not a pain at all! it's important to keep documentation up to date :D

@michellethomas michellethomas merged commit cd6de3a into apache:master Aug 7, 2019
etr2460 pushed a commit to airbnb/superset-fork that referenced this pull request Aug 7, 2019
etr2460 pushed a commit to etr2460/incubator-superset that referenced this pull request Aug 8, 2019
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 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 size/M 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants