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 SQL validator support for measures #693

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

DylanBaker
Copy link
Collaborator

Change description

Adding support for measures in the SQL validator

Type of change

  • Bug fix (fixes an issue)
  • New feature (adds functionality)

Related issues

Closes #368

Checklists

Security

  • Security impact of change has been considered
  • Code follows security best practices and guidelines

Code review

  • Pull request has a descriptive title and context useful to a reviewer

@DylanBaker DylanBaker added the Enhancement New feature or request label Mar 1, 2023
@DylanBaker DylanBaker marked this pull request as ready for review March 2, 2023 15:55
@jschintz-windriver
Copy link

Thank you!

Copy link
Collaborator

@joshtemple joshtemple left a comment

Choose a reason for hiding this comment

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

A few high-level questions:

  1. Aside from allowing measures to flow through into the LookML tree, is there anything else special happening to test them?

  2. I'm not seeing any tests specifically for measures, just the refactored existing tests.

  3. Should we expect performance to be impacted by including aggregates in the Explore-level queries?

spectacles/client.py Outdated Show resolved Hide resolved
@@ -120,7 +120,7 @@ def __init__(
metadata = {
"line_number": line_number,
"lookml_url": lookml_url,
"dimension": field_name,
"field": field_name,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Noting that this is basically a breaking change as far as the API is concerned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, we would need to release this with a corresponding change in the app/UI. It will likely need to account for both dimension and field, given old runs will have the old key.

@@ -54,7 +53,7 @@ def __repr__(self):
)

def __eq__(self, other):
if not isinstance(other, Dimension):
if not isinstance(other, LookMlField):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If a dimension LookMlField and measure LookMlField are compared, how are they marked as different? Is it the type attribute?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, type should do it in most cases, but your question has made me realise that technically a dimension and a measure could both be of type number and have the same name. It's a very narrow case, but could happen.

There is a boolean measure field on the fields JSON payload, so we could easily add that to both the model and the eq function. Does that work for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that works!

@DylanBaker
Copy link
Collaborator Author

A few high-level questions:

1. Aside from allowing measures to flow through into the LookML tree, is there anything else special happening to test them?

2. I'm not seeing any tests specifically for measures, just the refactored existing tests.

3. Should we expect performance to be impacted by including aggregates in the Explore-level queries?
  1. No, all we are changing is adding them when building the LookML tree. Everything else is unchanged except for renaming and the excluding measures functionality.

  2. A number of the integration test results were changed to account for the new measures coming in. I also added new tests for excluding measures that have the original numbers. Happy to add more if desired.

  3. I don't believe so. The only warehouse I'd be concerned by is Snowflake, given the weirdness of their query planner, but we would need to test. I'd recommend having people opt in to testing in the app (by having exclude measures set to true by default).

@joshtemple
Copy link
Collaborator

As far as measure-specific tests go, we may want to make sure all measure types are supported, since we don't have all of them defined on our eye-exam project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL validation for measures
3 participants