-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DSI 0.4.0 and Saved Query Exports (#8950)
- Loading branch information
Showing
17 changed files
with
306 additions
and
78 deletions.
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: Dependencies | ||
body: Begin using DSI 0.4.x | ||
time: 2023-10-31T13:19:54.750009-07:00 | ||
custom: | ||
Author: QMalcolm peterallenwebb | ||
PR: "8892" |
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 exports to SavedQuery spec | ||
time: 2023-10-31T13:20:22.448158-07:00 | ||
custom: | ||
Author: QMalcolm peterallenwebb | ||
Issue: "8892" |
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,53 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from dbt.contracts.graph.semantic_layer_common import WhereFilterIntersection | ||
from dbt.dataclass_schema import dbtClassMixin | ||
from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType | ||
from typing import List, Optional | ||
|
||
|
||
@dataclass | ||
class ExportConfig(dbtClassMixin): | ||
"""Nested configuration attributes for exports.""" | ||
|
||
export_as: ExportDestinationType | ||
schema_name: Optional[str] = None | ||
alias: Optional[str] = None | ||
|
||
|
||
@dataclass | ||
class Export(dbtClassMixin): | ||
"""Configuration for writing query results to a table.""" | ||
|
||
name: str | ||
config: ExportConfig | ||
|
||
def same_name(self, old: Export) -> bool: | ||
return self.name == old.name | ||
|
||
def same_export_as(self, old: Export) -> bool: | ||
return self.config.export_as == old.config.export_as | ||
|
||
def same_schema_name(self, old: Export) -> bool: | ||
return self.config.schema_name == old.config.schema_name | ||
|
||
def same_alias(self, old: Export) -> bool: | ||
return self.config.alias == old.config.alias | ||
|
||
def same_contents(self, old: Export) -> bool: | ||
return ( | ||
self.same_name(old) | ||
and self.same_export_as(old) | ||
and self.same_schema_name(old) | ||
and self.same_alias(old) | ||
) | ||
|
||
|
||
@dataclass | ||
class QueryParams(dbtClassMixin): | ||
"""The query parameters for the saved query""" | ||
|
||
metrics: List[str] | ||
group_by: List[str] | ||
where: Optional[WhereFilterIntersection] |
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,23 @@ | ||
from dataclasses import dataclass | ||
from dbt.dataclass_schema import dbtClassMixin | ||
from dbt_semantic_interfaces.call_parameter_sets import FilterCallParameterSets | ||
from dbt_semantic_interfaces.parsing.where_filter.where_filter_parser import WhereFilterParser | ||
from typing import List, Sequence, Tuple | ||
|
||
|
||
@dataclass | ||
class WhereFilter(dbtClassMixin): | ||
where_sql_template: str | ||
|
||
@property | ||
def call_parameter_sets(self) -> FilterCallParameterSets: | ||
return WhereFilterParser.parse_call_parameter_sets(self.where_sql_template) | ||
|
||
|
||
@dataclass | ||
class WhereFilterIntersection(dbtClassMixin): | ||
where_filters: List[WhereFilter] | ||
|
||
@property | ||
def filter_expression_parameter_sets(self) -> Sequence[Tuple[str, FilterCallParameterSets]]: | ||
raise NotImplementedError |
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
Oops, something went wrong.