-
Notifications
You must be signed in to change notification settings - Fork 14
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 New SavedQuery Protocol #148
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cde4a7d
Fix type error in the PrimaryEntityRule.
plypaul a408679
Configure ruff in pre-commit to auto-fix unused import errors.
plypaul 0d4b70f
Add saved query protocol and implementation.
plypaul 50d0418
Update JSON schema to include saved queries.
plypaul c5b5d73
Update YAML parsing code to handle saved queries.
plypaul 53bfb33
Add validation for saved queries.
plypaul 776fb67
Add tests for the saved query validation rule.
plypaul 37c96f2
Add change log for #144
plypaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Add New SavedQuery Protocol | ||
time: 2023-09-13T17:27:54.018355-07:00 | ||
custom: | ||
Author: plypaul | ||
Issue: "144" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
from typing import List, Optional | ||
|
||
from typing_extensions import override | ||
|
||
from dbt_semantic_interfaces.implementations.base import ( | ||
HashableBaseModel, | ||
ModelWithMetadataParsing, | ||
) | ||
from dbt_semantic_interfaces.implementations.filters.where_filter import ( | ||
PydanticWhereFilter, | ||
) | ||
from dbt_semantic_interfaces.implementations.metadata import PydanticMetadata | ||
from dbt_semantic_interfaces.protocols import ProtocolHint | ||
from dbt_semantic_interfaces.protocols.saved_query import SavedQuery | ||
|
||
|
||
class PydanticSavedQuery(HashableBaseModel, ModelWithMetadataParsing, ProtocolHint[SavedQuery]): | ||
"""Pydantic implementation of SavedQuery.""" | ||
|
||
@override | ||
def _implements_protocol(self) -> SavedQuery: | ||
return self | ||
|
||
name: str | ||
metrics: List[str] | ||
group_bys: List[str] = [] | ||
where: List[PydanticWhereFilter] = [] | ||
|
||
description: Optional[str] = None | ||
metadata: Optional[PydanticMetadata] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from abc import abstractmethod | ||
from typing import Optional, Protocol, Sequence | ||
|
||
from dbt_semantic_interfaces.protocols.metadata import Metadata | ||
from dbt_semantic_interfaces.protocols.where_filter import WhereFilter | ||
|
||
|
||
class SavedQuery(Protocol): | ||
QMalcolm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Represents a query that the user wants to run repeatedly.""" | ||
|
||
@property | ||
@abstractmethod | ||
def metadata(self) -> Optional[Metadata]: # noqa: D | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def name(self) -> str: # noqa: D | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def description(self) -> Optional[str]: # noqa: D | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def metrics(self) -> Sequence[str]: # noqa: D | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def group_bys(self) -> Sequence[str]: # noqa: D | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def where(self) -> Sequence[WhereFilter]: # noqa: D | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't think we have to, but we should probably mark the properties
name
andmetrics
to be required. I think parsing will error out either way if its not specified, as the creation of the object will fail. But specifying them in the jsonschema spec will give better errors I believe.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.