-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add exports config to YAML spec for saved queries
- Loading branch information
1 parent
a00ee84
commit 69f077b
Showing
6 changed files
with
93 additions
and
1 deletion.
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 exports configuration to YAML spec. | ||
time: 2023-10-24T16:28:42.013032-07:00 | ||
custom: | ||
Author: courtneyholcomb | ||
Issue: "189" |
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,29 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from typing_extensions import override | ||
|
||
from dbt_semantic_interfaces.implementations.base import HashableBaseModel | ||
from dbt_semantic_interfaces.protocols import ProtocolHint | ||
from dbt_semantic_interfaces.protocols.export import Export, ExportConfig | ||
from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType | ||
|
||
|
||
class PydanticExport(HashableBaseModel, ProtocolHint[Export]): | ||
"""Pydantic implementation of Export.""" | ||
|
||
@override | ||
def _implements_protocol(self) -> Export: | ||
return self | ||
|
||
name: str | ||
config: PydanticExportConfig | ||
|
||
|
||
class PydanticExportConfig(HashableBaseModel, ProtocolHint[ExportConfig]): | ||
"""Pydantic implementation of ExportConfig.""" | ||
|
||
export_as: ExportDestinationType | ||
schema: Optional[str] = None | ||
alias: Optional[str] = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from __future__ import annotations | ||
from typing import Protocol, Optional | ||
from abc import abstractmethod | ||
from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType | ||
|
||
|
||
class Export(Protocol): | ||
"""Configuration for writing query results to a table.""" | ||
|
||
@property | ||
@abstractmethod | ||
def name(self) -> str: # noqa: D | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def config(self) -> ExportConfig: # noqa: D | ||
pass | ||
|
||
|
||
class ExportConfig(Protocol): | ||
"""Nested configuration attributes for exports.""" | ||
|
||
@property | ||
@abstractmethod | ||
def export_as(self) -> ExportDestinationType: | ||
"""Type of destination to write export to.""" | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def schema(self) -> Optional[str]: | ||
"""Schema to write export to. Defaults to deployment schema.""" | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def alias(self) -> Optional[str]: | ||
"""Name for table/filte export is written to. Defaults to export name.""" | ||
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
8 changes: 8 additions & 0 deletions
8
dbt_semantic_interfaces/type_enums/export_destination_type.py
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,8 @@ | ||
from dbt_semantic_interfaces.enum_extension import ExtendedEnum | ||
|
||
|
||
class ExportDestinationType(ExtendedEnum): | ||
"""Types of destinations that exports can be written to.""" | ||
|
||
TABLE = "table" | ||
VIEW = "view" |