From 966d70cf3c5332f37ccef8d7029d43fb8f97e2da Mon Sep 17 00:00:00 2001 From: Peter Allen Webb Date: Mon, 10 Jul 2023 18:51:39 -0400 Subject: [PATCH] Rename NodeRelation.schema_name -> NodeRelation.schema --- .../implementations/semantic_model.py | 8 +++--- .../default_explicit_schema.json | 4 +-- dbt_semantic_interfaces/parsing/schemas.py | 4 +-- .../protocols/semantic_model.py | 2 +- dbt_semantic_interfaces/test_utils.py | 4 +-- .../semantic_models/accounts_source.yaml | 2 +- .../semantic_models/bookings_source.yaml | 2 +- .../semantic_models/companies.yaml | 2 +- .../semantic_models/id_verifications.yaml | 2 +- .../semantic_models/listings_latest.yaml | 2 +- .../semantic_models/lux_listing_mapping.yaml | 2 +- .../semantic_models/revenue.yaml | 2 +- .../semantic_models/user_sm_source.yaml | 2 +- .../semantic_models/users_latest.yaml | 2 +- .../semantic_models/views_source.yaml | 2 +- tests/parsing/test_semantic_model_parsing.py | 28 +++++++++---------- tests/test_implements_satisfy_protocols.py | 4 +-- tests/validations/test_entities.py | 4 +-- tests/validations/test_measures.py | 14 +++++----- tests/validations/test_reserved_keywords.py | 2 +- tests/validations/test_semantic_models.py | 2 +- .../test_validity_param_definitions.py | 20 ++++++------- 22 files changed, 58 insertions(+), 58 deletions(-) diff --git a/dbt_semantic_interfaces/implementations/semantic_model.py b/dbt_semantic_interfaces/implementations/semantic_model.py index 94862ae9..bc989de9 100644 --- a/dbt_semantic_interfaces/implementations/semantic_model.py +++ b/dbt_semantic_interfaces/implementations/semantic_model.py @@ -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 = "" @@ -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}" @@ -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 '.' or '..
' " f"but got: {sql_str}" diff --git a/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json b/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json index 0a73a7df..3edc7bab 100644 --- a/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json +++ b/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json @@ -338,13 +338,13 @@ "relation_name": { "type": "string" }, - "schema_name": { + "schema": { "type": "string" } }, "required": [ "alias", - "schema_name" + "schema" ], "type": "object" }, diff --git a/dbt_semantic_interfaces/parsing/schemas.py b/dbt_semantic_interfaces/parsing/schemas.py index da07fdec..c18e5003 100644 --- a/dbt_semantic_interfaces/parsing/schemas.py +++ b/dbt_semantic_interfaces/parsing/schemas.py @@ -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"], } diff --git a/dbt_semantic_interfaces/protocols/semantic_model.py b/dbt_semantic_interfaces/protocols/semantic_model.py index 9bc4f133..f1e4d045 100644 --- a/dbt_semantic_interfaces/protocols/semantic_model.py +++ b/dbt_semantic_interfaces/protocols/semantic_model.py @@ -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 diff --git a/dbt_semantic_interfaces/test_utils.py b/dbt_semantic_interfaces/test_utils.py index 9051bcc2..d9467f22 100644 --- a/dbt_semantic_interfaces/test_utils.py +++ b/dbt_semantic_interfaces/test_utils.py @@ -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 @@ -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", ) diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/accounts_source.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/accounts_source.yaml index 35f40a3c..c375ec8b 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/accounts_source.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/accounts_source.yaml @@ -4,7 +4,7 @@ semantic_model: description: accounts_source node_relation: - schema_name: $source_schema + schema: $source_schema alias: fct_accounts defaults: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/bookings_source.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/bookings_source.yaml index 075b5ddc..21c8dd2d 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/bookings_source.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/bookings_source.yaml @@ -4,7 +4,7 @@ semantic_model: description: bookings_source node_relation: - schema_name: $source_schema + schema: $source_schema alias: fct_bookings defaults: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/companies.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/companies.yaml index 45c94111..0b7da7cd 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/companies.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/companies.yaml @@ -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: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/id_verifications.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/id_verifications.yaml index e6303afe..aa48fb7a 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/id_verifications.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/id_verifications.yaml @@ -4,7 +4,7 @@ semantic_model: description: id_verifications node_relation: - schema_name: $source_schema + schema: $source_schema alias: fct_id_verifications defaults: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/listings_latest.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/listings_latest.yaml index c1480005..2b76756a 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/listings_latest.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/listings_latest.yaml @@ -4,7 +4,7 @@ semantic_model: description: listings_latest node_relation: - schema_name: $source_schema + schema: $source_schema alias: dim_listings_latest defaults: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/lux_listing_mapping.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/lux_listing_mapping.yaml index 30dd2ab6..211d72e4 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/lux_listing_mapping.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/lux_listing_mapping.yaml @@ -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: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/revenue.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/revenue.yaml index b8dd0dd8..a8011559 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/revenue.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/revenue.yaml @@ -4,7 +4,7 @@ semantic_model: description: revenue node_relation: - schema_name: $source_schema + schema: $source_schema alias: fct_revenue defaults: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/user_sm_source.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/user_sm_source.yaml index e44f9bcd..a3eefef7 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/user_sm_source.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/user_sm_source.yaml @@ -4,7 +4,7 @@ semantic_model: description: users_ds_source node_relation: - schema_name: $source_schema + schema: $source_schema alias: dim_users defaults: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/users_latest.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/users_latest.yaml index d85c37b4..3591d5b6 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/users_latest.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/users_latest.yaml @@ -4,7 +4,7 @@ semantic_model: description: users_latest node_relation: - schema_name: $source_schema + schema: $source_schema alias: dim_users_latest dimensions: diff --git a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/views_source.yaml b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/views_source.yaml index a6cafa9a..29af12f0 100644 --- a/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/views_source.yaml +++ b/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/views_source.yaml @@ -4,7 +4,7 @@ semantic_model: description: views_source node_relation: - schema_name: $source_schema + schema: $source_schema alias: fct_views defaults: diff --git a/tests/parsing/test_semantic_model_parsing.py b/tests/parsing/test_semantic_model_parsing.py index 442e6444..0a47d25b 100644 --- a/tests/parsing/test_semantic_model_parsing.py +++ b/tests/parsing/test_semantic_model_parsing.py @@ -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) @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tests/test_implements_satisfy_protocols.py b/tests/test_implements_satisfy_protocols.py index d618867d..3b289063 100644 --- a/tests/test_implements_satisfy_protocols.py +++ b/tests/test_implements_satisfy_protocols.py @@ -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=[], @@ -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=[], diff --git a/tests/validations/test_entities.py b/tests/validations/test_entities.py index da4e2d97..e43736cc 100644 --- a/tests/validations/test_entities.py +++ b/tests/validations/test_entities.py @@ -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 @@ -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 diff --git a/tests/validations/test_measures.py b/tests/validations/test_measures.py index d01bf3fc..86028e0d 100644 --- a/tests/validations/test_measures.py +++ b/tests/validations/test_measures.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tests/validations/test_reserved_keywords.py b/tests/validations/test_reserved_keywords.py index e1d477d5..a1c87ae9 100644 --- a/tests/validations/test_reserved_keywords.py +++ b/tests/validations/test_reserved_keywords.py @@ -78,7 +78,7 @@ def test_reserved_keywords_in_node_relation( # noqa: D ) semantic_model_with_node_relation.node_relation = NodeRelation( alias=random_keyword(), - schema_name="some_schema", + schema="some_schema", ) issues = ReservedKeywordsRule.validate_manifest(model) assert len(issues) == 1 diff --git a/tests/validations/test_semantic_models.py b/tests/validations/test_semantic_models.py index 5a7783e4..8ad99f69 100644 --- a/tests/validations/test_semantic_models.py +++ b/tests/validations/test_semantic_models.py @@ -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 diff --git a/tests/validations/test_validity_param_definitions.py b/tests/validations/test_validity_param_definitions.py index 8ce82e7b..cd0d0439 100644 --- a/tests/validations/test_validity_param_definitions.py +++ b/tests/validations/test_validity_param_definitions.py @@ -31,7 +31,7 @@ def test_validity_window_configuration() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -75,7 +75,7 @@ def test_validity_window_must_have_a_start() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -109,7 +109,7 @@ def test_validity_window_must_have_an_end() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -146,7 +146,7 @@ def test_validity_window_uses_two_dimensions() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -183,7 +183,7 @@ def test_two_dimension_validity_windows_must_not_overload_start_and_end() -> Non semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -224,7 +224,7 @@ def test_multiple_validity_windows_are_invalid() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -276,7 +276,7 @@ def test_empty_validity_windows_are_invalid() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -320,7 +320,7 @@ def test_measures_are_prevented() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -367,7 +367,7 @@ def test_validity_window_must_have_a_natural_key() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_key @@ -412,7 +412,7 @@ def test_validity_window_does_not_use_primary_key() -> None: semantic_model: name: scd_semantic_model node_relation: - schema_name: some_schema + schema: some_schema alias: scd_table entities: - name: scd_primary_key