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

Rename NodeRelation.schema_name -> NodeRelation.schema #107

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dbt_semantic_interfaces/implementations/semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NodeRelation(HashableBaseModel):
"""Path object to where the data should be."""

alias: str
schema_name: str
schema: str
database: Optional[str] = None
relation_name: str = ""

Expand All @@ -41,7 +41,7 @@ def __create_default_relation_name(cls, value: Any, values: Any) -> str: # type
# Only build the relation_name if it was not present in config.
return value

alias, schema, database = values.get("alias"), values.get("schema_name"), values.get("database")
alias, schema, database = values.get("alias"), values.get("schema"), values.get("database")
if alias is None or schema is None:
raise ValueError(
f"Failed to build relation_name because alias and/or schema was None. schema: {schema}, alias: {alias}"
Expand All @@ -57,9 +57,9 @@ def __create_default_relation_name(cls, value: Any, values: Any) -> str: # type
def from_string(sql_str: str) -> NodeRelation: # noqa: D
sql_str_split = sql_str.split(".")
if len(sql_str_split) == 2:
return NodeRelation(schema_name=sql_str_split[0], alias=sql_str_split[1])
return NodeRelation(schema=sql_str_split[0], alias=sql_str_split[1])
elif len(sql_str_split) == 3:
return NodeRelation(database=sql_str_split[0], schema_name=sql_str_split[1], alias=sql_str_split[2])
return NodeRelation(database=sql_str_split[0], schema=sql_str_split[1], alias=sql_str_split[2])
raise RuntimeError(
f"Invalid input for a SQL table, expected form '<schema>.<table>' or '<db>.<schema>.<table>' "
f"but got: {sql_str}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@
"relation_name": {
"type": "string"
},
"schema_name": {
"schema": {
"type": "string"
}
},
"required": [
"alias",
"schema_name"
"schema"
],
"type": "object"
},
Expand Down
4 changes: 2 additions & 2 deletions dbt_semantic_interfaces/parsing/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@
"type": "object",
"properties": {
"alias": {"type": "string"},
"schema_name": {"type": "string"},
"schema": {"type": "string"},
"database": {"type": "string"},
"relation_name": {"type": "string"},
},
"additionalProperties": False,
"required": ["alias", "schema_name"],
"required": ["alias", "schema"],
}


Expand Down
2 changes: 1 addition & 1 deletion dbt_semantic_interfaces/protocols/semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def alias(self) -> str: # noqa: D

@property
@abstractmethod
def schema_name(self) -> str: # noqa: D
def schema(self) -> str: # noqa: D
pass

@property
Expand Down
4 changes: 2 additions & 2 deletions dbt_semantic_interfaces/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def base_semantic_manifest_file() -> YamlConfigFile:
semantic_model:
name: sample_semantic_model
node_relation:
schema_name: some_schema
schema: some_schema
alias: source_table
entities:
- name: example_entity
Expand Down Expand Up @@ -158,7 +158,7 @@ def semantic_model_with_guaranteed_meta(
created_node_relation = node_relation
if created_node_relation is None:
created_node_relation = NodeRelation(
schema_name="schema",
schema="schema",
alias="table",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: accounts_source

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: fct_accounts

defaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: bookings_source

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: fct_bookings

defaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: If a user is a company / business, this defines the mapping.

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: dim_companies

dimensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: id_verifications

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: fct_id_verifications

defaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: listings_latest

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: dim_listings_latest

defaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: lux_listing_mapping

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: dim_lux_listing_id_mapping

entities:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: revenue

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: fct_revenue

defaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: users_ds_source

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: dim_users

defaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: users_latest

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: dim_users_latest

dimensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ semantic_model:
description: views_source

node_relation:
schema_name: $source_schema
schema: $source_schema
alias: fct_views

defaults:
Expand Down
28 changes: 14 additions & 14 deletions tests/parsing/test_semantic_model_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_semantic_model_metadata_parsing() -> None:
name: metadata_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
"""
)
file = YamlConfigFile(filepath="test_dir/inline_for_test", contents=yaml_contents)
Expand All @@ -40,7 +40,7 @@ def test_semantic_model_metadata_parsing() -> None:
name: metadata_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
"""
)
assert semantic_model.metadata.file_slice.content == expected_metadata_content
Expand All @@ -54,7 +54,7 @@ def test_semantic_model_node_relation_parsing() -> None:
name: sql_table_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
"""
)
file = YamlConfigFile(filepath="inline_for_test", contents=yaml_contents)
Expand All @@ -74,7 +74,7 @@ def test_semantic_model_entity_parsing() -> None:
name: entity_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
entities:
- name: example_entity
type: primary
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_semantic_model_entity_metadata_parsing() -> None:
name: entity_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
entities:
- name: example_entity
type: primary
Expand Down Expand Up @@ -140,7 +140,7 @@ def test_semantic_model_measure_parsing() -> None:
name: measure_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
measures:
- name: example_measure
agg: count_distinct
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_semantic_model_measure_metadata_parsing() -> None:
name: measure_metadata_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
measures:
- name: example_measure_with_metadata
agg: count_distinct
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_semantic_model_create_metric_measure_parsing() -> None:
name: measure_parsing_create_metric_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
measures:
- name: example_measure
agg: count_distinct
Expand All @@ -231,7 +231,7 @@ def test_semantic_model_categorical_dimension_parsing() -> None:
name: dimension_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
dimensions:
- name: example_categorical_dimension
type: categorical
Expand Down Expand Up @@ -259,7 +259,7 @@ def test_semantic_model_partition_dimension_parsing() -> None:
name: dimension_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
dimensions:
- name: example_categorical_dimension
type: categorical
Expand All @@ -285,7 +285,7 @@ def test_semantic_model_time_dimension_parsing() -> None:
name: dimension_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
dimensions:
- name: example_time_dimension
type: time
Expand Down Expand Up @@ -314,7 +314,7 @@ def test_semantic_model_primary_time_dimension_parsing() -> None:
name: dimension_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
dimensions:
- name: example_time_dimension
type: time
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_semantic_model_dimension_metadata_parsing() -> None:
name: dimension_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
dimensions:
- name: example_categorical_dimension
type: categorical
Expand Down Expand Up @@ -378,7 +378,7 @@ def test_semantic_model_dimension_validity_params_parsing() -> None:
name: scd_parsing_test
node_relation:
alias: source_table
schema_name: some_schema
schema: some_schema
dimensions:
- name: start_time_dimension
type: time
Expand Down
4 changes: 2 additions & 2 deletions tests/test_implements_satisfy_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_semantic_manifest_protocol() -> None: # noqa: D
name="test_semantic_model",
node_relation=NodeRelation(
alias="test_alias",
schema_name="test_schema_name",
schema="test_schema_name",
),
entities=[],
measures=[],
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_semantic_model_protocol() -> None: # noqa: D
name="test_semantic_model",
node_relation=NodeRelation(
alias="test_alias",
schema_name="test_schema_name",
schema="test_schema_name",
),
entities=[],
measures=[],
Expand Down
4 changes: 2 additions & 2 deletions tests/validations/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_multiple_natural_entities() -> None:
semantic_model:
name: too_many_natural_entities
node_relation:
schema_name: some_schema
schema: some_schema
alias: natural_entity_table
entities:
- name: natural_key_one
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_natural_entity_used_in_wrong_context() -> None:
semantic_model:
name: random_natural_entity
node_relation:
schema_name: some_schema
schema: some_schema
alias: random_natural_entity_table
entities:
- name: natural_key
Expand Down
Loading