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

Add support for getting freshness from DBMS metadata #8795

Merged
merged 13 commits into from
Oct 11, 2023

Conversation

peterallenwebb
Copy link
Contributor

@peterallenwebb peterallenwebb commented Oct 8, 2023

resolves #8704

Problem

Solution

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label Oct 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2023

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@codecov
Copy link

codecov bot commented Oct 8, 2023

Codecov Report

Attention: 26 lines in your changes are missing coverage. Please review.

Comparison is base (a7e2d9b) 86.44% compared to head (09260d4) 83.30%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8795      +/-   ##
==========================================
- Coverage   86.44%   83.30%   -3.15%     
==========================================
  Files         176      177       +1     
  Lines       26046    26130      +84     
==========================================
- Hits        22516    21767     -749     
- Misses       3530     4363     +833     
Flag Coverage Δ
integration 83.30% <74.00%> (+0.05%) ⬆️
unit ?

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

Files Coverage Δ
core/dbt/adapters/capability.py 100.00% <100.00%> (ø)
core/dbt/contracts/graph/nodes.py 91.03% <100.00%> (-4.07%) ⬇️
core/dbt/events/types.py 86.45% <100.00%> (-12.22%) ⬇️
core/dbt/events/types_pb2.py 1.29% <ø> (-0.12%) ⬇️
core/dbt/parser/sources.py 90.80% <100.00%> (+0.16%) ⬆️
core/dbt/clients/agate_helper.py 83.96% <20.00%> (-13.65%) ⬇️
core/dbt/task/freshness.py 86.17% <58.82%> (-5.30%) ⬇️
core/dbt/adapters/base/impl.py 79.39% <54.54%> (-2.40%) ⬇️

... and 63 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@peterallenwebb peterallenwebb marked this pull request as ready for review October 10, 2023 20:49
@peterallenwebb peterallenwebb requested review from a team as code owners October 10, 2023 20:49
core/dbt/adapters/base/impl.py Show resolved Hide resolved
tests/unit/test_contracts_graph_parsed.py Show resolved Hide resolved
plugins/postgres/dbt/adapters/postgres/impl.py Outdated Show resolved Hide resolved
core/dbt/adapters/base/impl.py Outdated Show resolved Hide resolved
core/dbt/adapters/base/impl.py Outdated Show resolved Hide resolved
core/dbt/adapters/base/impl.py Outdated Show resolved Hide resolved
core/dbt/adapters/base/impl.py Outdated Show resolved Hide resolved
core/dbt/task/freshness.py Show resolved Hide resolved
core/dbt/adapters/base/impl.py Outdated Show resolved Hide resolved
core/dbt/adapters/base/impl.py Outdated Show resolved Hide resolved
Copy link
Member

@aranke aranke left a comment

Choose a reason for hiding this comment

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

LGTM, few nits

core/dbt/adapters/capability.py Outdated Show resolved Hide resolved
adapter_response, table = result.response, result.table # type: ignore[attr-defined]

try:
row = table[0]
Copy link
Member

Choose a reason for hiding this comment

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

Can you just load the first row as a dict then do a simple key lookup?
Might make it slightly easier to debug.

core/dbt/task/freshness.py Outdated Show resolved Hide resolved
Copy link
Contributor

@mikealfare mikealfare 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 good. The only issue I saw was that we're still pulling Capability stuff from base/impl.py in some spots and we should update that to pull from the new capability module. I noted it wherever I saw that. But aside from that (and the protobuf merge conflicts), I'm comfortable with this. I'll give it an approval from the Adapters side with the caveat of those import updates.

core/dbt/adapters/base/impl.py Show resolved Hide resolved
@@ -1203,7 +1213,7 @@ def calculate_freshness(
loaded_at_field: str,
filter: Optional[str],
manifest: Optional[Manifest] = None,
) -> Tuple[Optional[AdapterResponse], Dict[str, Any]]:
) -> Tuple[Optional[AdapterResponse], FreshnessResponse]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will cause mypy errors if it's overridden, but I don't think it breaks the functional code since the two types are almost the same; it should only break linting. The exception is if a maintainer is passing freshness information as a str or other data type in the value of the original dict, which is already problematic. Worth pointing out to @anders for the 1.7 upgrade guide for adapter maintainers.

core/dbt/adapters/capability.py Outdated Show resolved Hide resolved
core/dbt/parser/sources.py Outdated Show resolved Hide resolved
core/dbt/task/freshness.py Outdated Show resolved Hide resolved
plugins/postgres/dbt/adapters/postgres/impl.py Outdated Show resolved Hide resolved
@peterallenwebb peterallenwebb merged commit 2e35426 into main Oct 11, 2023
50 of 51 checks passed
@peterallenwebb peterallenwebb deleted the paw/metadata-freshness branch October 11, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants