Skip to content

Commit

Permalink
Merge branch 'speed-up-cli' of github.aaakk.us.kg-dwreeves:dwreeves/dbt-adapt…
Browse files Browse the repository at this point in the history
…ers into speed-up-cli
  • Loading branch information
dwreeves committed Mar 26, 2024
2 parents 84c4223 + 5fc6a12 commit f3f927c
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240226-224046.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Add field wrapper to BaseRelation members that were missing it.
time: 2024-02-26T22:40:46.271694-08:00
custom:
Author: versusfacit
Issue: "108"
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240229-163014.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Add "description" and "meta" fields to RelationConfig protocol
time: 2024-02-29T16:30:14.833301-08:00
custom:
Author: colin-rogers-dbt
Issue: "119"
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240312-170057.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: add BaseAdapater.MAX_SCHEMA_METADATA_RELATIONS
time: 2024-03-12T17:00:57.333545-04:00
custom:
Author: michelleark
Issue: "131"
2 changes: 1 addition & 1 deletion dbt/adapters/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.0.0a2"
version = "1.0.0b1"
4 changes: 3 additions & 1 deletion dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ class BaseAdapter(metaclass=AdapterMeta):
ConstraintType.foreign_key: ConstraintSupport.ENFORCED,
}

MAX_SCHEMA_METADATA_RELATIONS = 100

# This static member variable can be overriden in concrete adapter
# implementations to indicate adapter support for optional capabilities.
_capabilities = CapabilityDict({})
Expand Down Expand Up @@ -1161,7 +1163,7 @@ def get_filtered_catalog(
catalogs: "agate.Table"
if (
relations is None
or len(relations) > 100
or len(relations) > self.MAX_SCHEMA_METADATA_RELATIONS
or not self.supports(Capability.SchemaMetadataByRelations)
):
# Do it the traditional way. We get the full catalog.
Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/base/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ class BaseRelation(FakeAPIObject, Hashable):
# adding a relation type here also requires defining the associated rename macro
# e.g. adding RelationType.View in dbt-postgres requires that you define:
# include/postgres/macros/relations/view/rename.sql::postgres__get_rename_view_sql()
renameable_relations: SerializableIterable = ()
renameable_relations: SerializableIterable = field(default_factory=frozenset)

# register relation types that are atomically replaceable, e.g. they have "create or replace" syntax
# adding a relation type here also requires defining the associated replace macro
# e.g. adding RelationType.View in dbt-postgres requires that you define:
# include/postgres/macros/relations/view/replace.sql::postgres__get_replace_view_sql()
replaceable_relations: SerializableIterable = ()
replaceable_relations: SerializableIterable = field(default_factory=frozenset)

def _is_exactish_match(self, field: ComponentName, value: str) -> bool:
if self.dbt_created and self.quote_policy.get_part(field) is False:
Expand Down
10 changes: 8 additions & 2 deletions dbt/adapters/contracts/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,23 @@ class MaterializationConfig(Mapping, ABC):
contract: MaterializationContract
extra: Dict[str, Any]

def __contains__(self, item): ...
def __contains__(self, item):
...

def __delitem__(self, key): ...
def __delitem__(self, key):
...


class RelationConfig(Protocol):
resource_type: str
name: str
description: str
database: str
schema: str
identifier: str
compiled_code: Optional[str]
meta: Dict[str, Any]
tags: List[str]
quoting_dict: Dict[str, bool]
config: Optional[MaterializationConfig]

Expand Down
9 changes: 6 additions & 3 deletions dbt/adapters/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ class ColumnProtocol(Protocol):

class RelationProtocol(Protocol):
@classmethod
def get_default_quote_policy(cls) -> Policy: ...
def get_default_quote_policy(cls) -> Policy:
...

@classmethod
def create_from(
cls: Type[Self],
quoting: HasQuoting,
relation_config: RelationConfig,
**kwargs: Any,
) -> Self: ...
) -> Self:
...


AdapterConfig_T = TypeVar("AdapterConfig_T", bound=AdapterConfig)
Expand All @@ -71,7 +73,8 @@ def __call__(
config: AdapterRequiredConfig,
macro_resolver: MacroResolverProtocol,
package_name: Optional[str],
) -> Dict[str, Any]: ...
) -> Dict[str, Any]:
...


# TODO CT-211
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/sql/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def convert_text_type(cls, agate_table: "agate.Table", col_idx: int) -> str:
return "text"

@classmethod
def convert_number_type(cls, agate_table: agate.Table, col_idx: int) -> str:
def convert_number_type(cls, agate_table: "agate.Table", col_idx: int) -> str:
import agate

# TODO CT-211
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
*/ #}

{% macro drop_materialized_view(relation) -%}
{{ return(adapter.dispatch('drop_materialized_view', 'dbt')(relation)) }}
{{- adapter.dispatch('drop_materialized_view', 'dbt')(relation) -}}
{%- endmacro %}


Expand Down
2 changes: 1 addition & 1 deletion dbt/include/global_project/macros/relations/table/drop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
*/ #}

{% macro drop_table(relation) -%}
{{ return(adapter.dispatch('drop_table', 'dbt')(relation)) }}
{{- adapter.dispatch('drop_table', 'dbt')(relation) -}}
{%- endmacro %}


Expand Down
2 changes: 1 addition & 1 deletion dbt/include/global_project/macros/relations/view/drop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
*/ #}

{% macro drop_view(relation) -%}
{{ return(adapter.dispatch('drop_view', 'dbt')(relation)) }}
{{- adapter.dispatch('drop_view', 'dbt')(relation) -}}
{%- endmacro %}


Expand Down

0 comments on commit f3f927c

Please sign in to comment.