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

Basic check query tests for custom granularity #1416

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented Sep 20, 2024

Adds some check query tests for various custom granularity scenarios. I have some tasks up for other scenarios to test, but also open to more suggestions!

@cla-bot cla-bot bot added the cla:yes label Sep 20, 2024
@dbt-labs dbt-labs deleted a comment from github-actions bot Sep 20, 2024
@dbt-labs dbt-labs deleted a comment from github-actions bot Sep 20, 2024
@courtneyholcomb courtneyholcomb marked this pull request as ready for review September 20, 2024 22:34
@courtneyholcomb courtneyholcomb changed the title Check query tests for custom granularity Basic check query tests for custom granularity Sep 24, 2024
@tlento tlento added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Sep 24, 2024
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 24, 2024 19:59 — with GitHub Actions Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 24, 2024 19:59 — with GitHub Actions Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 24, 2024 19:59 — with GitHub Actions Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS September 24, 2024 19:59 — with GitHub Actions Inactive
@github-actions github-actions bot removed the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Sep 24, 2024
Base automatically changed from court/parse-custom-3 to main September 24, 2024 22:43
Copy link
Contributor

@theyostalservice theyostalservice left a comment

Choose a reason for hiding this comment

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

Would it be appropriate(*) to also include one or more no-metric queries?

(*) - I don't even know if you are able to pass '[]' for the metrics in this test set up, so this might be a very silly question.

Otherwise, I don't know the edge cases well enough to be sure we aren't skipping any, but the broad strokes of what the PR stack has been about seem to be covered - using custom granularities, joining on them, and connecting nodes based on date parts (plus some of the edge cases like cumulative metrics and offset metrics.). Accepting.

) subq_15
---
integration_test:
name: multiple_metrics_with_custom_granularity
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like I learned a bit just reading this. I really like the way our integration tests are set up here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice!! Yeah, these end to end tests are great because they actually check that the SQL can actually execute, too, unlike most of our other tests.

description: A derived metric queried with a custom granularity
model: SIMPLE_MODEL
metrics: [ "bookings", "listings"]
group_bys: ["metric_time__martian_day", "listing__ds__month"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is exercising the new datepart logic in the linker for custom granularities, right? (I'm just trying to confirm the things I'm learning.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the new datepart logic in the linker

Maybe! What do you mean by this?

Copy link
Contributor

Choose a reason for hiding this comment

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

hahaha uh oh sounds like I'm learning less than I thought.

I think this query exercises the changes in #1415 - we're able to groupBy DatePart on a derived metric with custom granularity because because of that PR, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh ok I get what you meant by the new datepart logic in the linker now!

we're able to groupBy DatePart on a derived metric with custom granularity because because of that PR

Not quite. Date part and custom granularity can't be used together. That PR does 2 things:

  • Bug fix: updates the LinkableSpecResolver to allow non-default granularity for cumulative metrics. By non-default I don't mean custom. The default granularity for a dimension is the one it's defined at in the YAML definition. For example, if a metric is defined with DAY granularity, the default is DAY and all other standard granularities (MONTH, YEAR, etc.) and custom granularities are considered non-default. Cumulative metrics can be queried with all granularities, which is a change we made this year, and the LinkableSpecResolver was out of date for that logic. Cumulative metrics still cannot be queried with date part, though. This change was all in the first commit.
  • Adds custom granularities to the LinkableSpecResolver for all metrics. This change is in all the later commits.
    There are a lot of different metric types and group by options to grasp all at once here 😅 So let me know if this makes sense or if you have questions about any of it!

As for this test - it is testing that we can use a custom granularity with multiple simple metrics, and that does rely on the logic from that PR!

Also, I realized just now that I didn't update the descriptions for these tests properly (good old copy/paste) and that probably contributed to the confusion. I'll update those before merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, i think it does make sense. I may need a reminder or two about some of these details in the future, but I'm definitely putting things together a bit more as I go. :)

Thank you, Courtney!

@courtneyholcomb
Copy link
Contributor Author

courtneyholcomb commented Sep 25, 2024

Would it be appropriate(*) to also include one or more no-metric queries?

(*) - I don't even know if you are able to pass '[]' for the metrics in this test set up, so this might be a very silly question.

Otherwise, I don't know the edge cases well enough to be sure we aren't skipping any, but the broad strokes of what the PR stack has been about seem to be covered - using custom granularities, joining on them, and connecting nodes based on date parts (plus some of the edge cases like cumulative metrics and offset metrics.). Accepting.

@theyostalservice 🤔 You're right! I'm pretty sure I added them at some point at then I must have lost them in the bad rebase I did on this PR 😅 I'll add some to the top of the stack.

@courtneyholcomb courtneyholcomb merged commit a104d73 into main Sep 26, 2024
15 checks passed
@courtneyholcomb courtneyholcomb deleted the court/parse-custom-4 branch September 26, 2024 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants