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

chore: Re-add inheritance of Presto macros for Trino et al. #22435

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Dec 16, 2022

SUMMARY

This PR re-addresses some of the issues #20729 tried to fix which was closed in favor of #21066 (which introduced a few regressions). Specifically it:

  1. Moves the Presto/Trino compatible latest_partition and latest_sub_partition functions (and their dependencies)—which are exposed as macros—from the PrestoEngineSpec to the PrestoBaseEngineSpec so they can be leveraged by the TrinoEngineSpec.
  2. Adds missing facets to the TrinoEngineSpec.extra_table_metadata return value to include the latest partition spec, thus ensuing that the latest partition information is rendered in the left-hand panel. See the attached screenshot for details as previously this simply stated latest partition:.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screenshot 2022-12-16 at 1 37 09 PM

TESTING INSTRUCTIONS

Added unit tests and end-to-end testing.

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

cc: @dungdm93

@john-bodley john-bodley changed the title chore: Re-add inheritance of Presto macros for Trino chore: Re-add inheritance of Presto macros for Trino et al. Dec 16, 2022
@john-bodley john-bodley marked this pull request as ready for review December 16, 2022 00:53
@codecov
Copy link

codecov bot commented Dec 16, 2022

Codecov Report

Merging #22435 (50b5547) into master (fa919f3) will decrease coverage by 11.17%.
The diff coverage is 13.58%.

❗ Current head 50b5547 differs from pull request most recent head 512cfd8. Consider uploading reports for the commit 512cfd8 to get more accurate results

@@             Coverage Diff             @@
##           master   #22435       +/-   ##
===========================================
- Coverage   66.90%   55.72%   -11.18%     
===========================================
  Files        1850     1850               
  Lines       70692    70687        -5     
  Branches     7752     7752               
===========================================
- Hits        47294    39388     -7906     
- Misses      21382    29283     +7901     
  Partials     2016     2016               
Flag Coverage Δ
hive 52.47% <13.58%> (+<0.01%) ⬆️
mysql ?
postgres ?
presto 52.37% <13.58%> (+<0.01%) ⬆️
python 57.77% <13.58%> (-23.47%) ⬇️
sqlite ?
unit 50.93% <13.58%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/db_engine_specs/hive.py 64.56% <0.00%> (-22.79%) ⬇️
superset/db_engine_specs/trino.py 38.58% <0.00%> (-31.73%) ⬇️
superset/db_engine_specs/presto.py 41.12% <14.66%> (-47.10%) ⬇️
superset/utils/dashboard_import_export.py 0.00% <0.00%> (-100.00%) ⬇️
superset/tags/core.py 4.54% <0.00%> (-95.46%) ⬇️
superset/key_value/commands/update.py 0.00% <0.00%> (-90.91%) ⬇️
superset/key_value/commands/delete.py 0.00% <0.00%> (-87.88%) ⬇️
superset/key_value/commands/delete_expired.py 0.00% <0.00%> (-84.00%) ⬇️
superset/dashboards/commands/importers/v0.py 15.62% <0.00%> (-76.25%) ⬇️
superset/datasets/commands/create.py 30.61% <0.00%> (-69.39%) ⬇️
... and 285 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rusackas rusackas requested a review from nytai December 16, 2022 05:36
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.

LGTM

Comment on lines +201 to +214

def test_extra_table_metadata(self):
db = mock.Mock()
db.get_indexes = mock.Mock(
return_value=[{"column_names": ["ds", "hour"], "name": "partition"}]
)
db.get_extra = mock.Mock(return_value={})
db.has_view_by_name = mock.Mock(return_value=None)
db.get_df = mock.Mock(
return_value=pd.DataFrame({"ds": ["01-01-19"], "hour": [1]})
)
result = TrinoEngineSpec.extra_table_metadata(db, "test_table", "test_schema")
assert result["partitions"]["cols"] == ["ds", "hour"]
assert result["partitions"]["latest"] == {"ds": "01-01-19", "hour": 1}
Copy link
Member

Choose a reason for hiding this comment

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

nit: we should add new db engine spec tests to tests/unit_tests/db_engine_specs/test_*.py. But I can port over this test once this PR is merged, as I'm going to be doing a few changes to the Trino spec to implement some recent features from the new Trino driver.

@@ -311,6 +311,203 @@ def get_function_names(cls, database: Database) -> List[str]:
"""
return database.get_df("SHOW FUNCTIONS")["Function"].tolist()

@classmethod
Copy link
Member Author

Choose a reason for hiding this comment

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

This entire block was simply moved from PrestoEngineSpec to PrestoBaseEngineSpec.

metadata["partitions"] = {
"cols": cols,
"cols": sorted(indexes[0].get("column_names", [])),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same logic as before, though now it's inlined. The sorted(...) is to aid with testing.

latest_parts = tuple([None] * len(col_names))

metadata["partitions"] = {
"cols": sorted(
Copy link
Member Author

Choose a reason for hiding this comment

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

Very similar logic to before except the list is deduped and then sorted to aid with testing.

@john-bodley john-bodley merged commit 71982ee into apache:master Dec 19, 2022
@john-bodley john-bodley deleted the john-bodley--fix-21066 branch December 19, 2022 19:27
john-bodley added a commit to airbnb/superset-fork that referenced this pull request Jan 18, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 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 size/L 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants