superset icon indicating copy to clipboard operation
superset copied to clipboard

feat: per-db add metrics

Open betodealmeida opened this issue 2 years ago • 1 comments

SUMMARY

This PR adds a method called get_metrics to the Database model and the base DB engine spec. It allows DB engine specs to return custom metrics for a given dataset, so that when a user adds a new dataset it can have more metrics than just COUNT(*) (the current behavior).

Currently no DB engine spec implements get_metrics, but in the future it could be leveraged by DB engine specs that have a semantic layer (like https://cube.dev/).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Added tests.

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

betodealmeida avatar Aug 05 '22 01:08 betodealmeida

Codecov Report

Merging #20990 (b07589d) into master (eec6e57) will decrease coverage by 0.82%. The diff coverage is 67.64%.

:exclamation: Current head b07589d differs from pull request most recent head 595e41d. Consider uploading reports for the commit 595e41d to get more accurate results

@@            Coverage Diff             @@
##           master   #20990      +/-   ##
==========================================
- Coverage   66.34%   65.51%   -0.83%     
==========================================
  Files        1767     1767              
  Lines       67284    67308      +24     
  Branches     7140     7144       +4     
==========================================
- Hits        44642    44100     -542     
- Misses      20815    21380     +565     
- Partials     1827     1828       +1     
Flag Coverage Δ
hive ?
mysql ?
postgres ?
presto 53.05% <85.71%> (+0.01%) :arrow_up:
python 79.77% <95.23%> (-1.70%) :arrow_down:
sqlite 79.59% <95.23%> (+<0.01%) :arrow_up:
unit 50.49% <85.71%> (+0.01%) :arrow_up:

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

Impacted Files Coverage Δ
...ntend/src/explore/components/ExploreChartPanel.jsx 67.60% <0.00%> (-1.41%) :arrow_down:
.../src/views/CRUD/data/dataset/DatasetPage/index.tsx 0.00% <0.00%> (ø)
.../explore/components/ExploreViewContainer/index.jsx 52.45% <75.00%> (+0.26%) :arrow_up:
superset/common/query_context_processor.py 89.28% <80.00%> (-0.36%) :arrow_down:
superset/connectors/sqla/models.py 89.79% <100.00%> (-0.54%) :arrow_down:
superset/db_engine_specs/base.py 87.94% <100.00%> (-0.26%) :arrow_down:
superset/models/core.py 88.03% <100.00%> (-0.67%) :arrow_down:
superset/db_engines/hive.py 0.00% <0.00%> (-85.19%) :arrow_down:
superset/datasets/commands/update.py 25.00% <0.00%> (-69.05%) :arrow_down:
superset/datasets/commands/create.py 29.41% <0.00%> (-68.63%) :arrow_down:
... and 36 more

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

codecov[bot] avatar Aug 05 '22 01:08 codecov[bot]