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

Alias NodeRelation.schema_name to simply 'schema' #108

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230711-103558.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Alias NodeRelation.schema_name to simply 'schema'
time: 2023-07-11T10:35:58.001941-04:00
custom:
Author: peterallenwebb
Issue: "106"
5 changes: 3 additions & 2 deletions dbt_semantic_interfaces/implementations/semantic_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from dataclasses import Field
from typing import Any, List, Optional, Sequence

from pydantic import validator
Expand Down Expand Up @@ -29,7 +30,7 @@ class NodeRelation(HashableBaseModel):
"""Path object to where the data should be."""

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

Expand All @@ -41,7 +42,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 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/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
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/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
14 changes: 7 additions & 7 deletions tests/validations/test_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_measures_only_exist_in_one_semantic_model() -> None: # noqa: D
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 @@ -111,7 +111,7 @@ def test_measures_only_exist_in_one_semantic_model() -> None: # noqa: D
semantic_model:
name: sample_semantic_model_2
node_relation:
schema_name: some_schema
schema: some_schema
alias: source_table
entities:
- name: example_entity_2
Expand Down Expand Up @@ -157,7 +157,7 @@ def test_invalid_non_additive_dimension_properties() -> None:
semantic_model:
name: sample_semantic_model_2
node_relation:
schema_name: some_schema
schema: some_schema
alias: source_table
entities:
- name: example_entity
Expand Down Expand Up @@ -238,7 +238,7 @@ def test_count_measure_missing_expr() -> None:
semantic_model:
name: sample_semantic_model_2
node_relation:
schema_name: some_schema
schema: some_schema
alias: source_table
entities:
- name: example_entity
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_count_measure_with_distinct_expr() -> None:
semantic_model:
name: sample_semantic_model_2
node_relation:
schema_name: some_schema
schema: some_schema
alias: source_table
entities:
- name: example_entity
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_percentile_measure_missing_agg_params() -> None:
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 @@ -411,7 +411,7 @@ def test_percentile_measure_bad_percentile_values() -> None:
semantic_model:
name: sample_semantic_model
node_relation:
schema_name: some_schema
schema: some_schema
alias: source_table
entities:
- name: example_entity
Expand Down
2 changes: 1 addition & 1 deletion tests/validations/test_semantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_semantic_model_defaults_invalid() -> None: # noqa: D
semantic_model:
name: semantic_model_name
node_relation:
schema_name: some_schema
schema: some_schema
alias: some_alias
defaults:
agg_time_dimension: doesnotexist
Expand Down
Loading