Skip to content

Commit b127491

Browse files
committed
Fix observations
1 parent f05232c commit b127491

File tree

5 files changed

+44
-17
lines changed

5 files changed

+44
-17
lines changed

pydough/metadata/collections/collection_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def __init__(
4848
PropertyMetadata,
4949
)
5050

51-
is_valid_name.verify(name, f"name {name!r}")
52-
HasType(GraphMetadata).verify(graph, f"graph {graph}")
51+
is_valid_name.verify(name, f"collection name {name!r}")
52+
HasType(GraphMetadata).verify(graph, f"graph {name!r}")
5353

5454
self._graph: GraphMetadata = graph
5555
self._name: str = name

pydough/metadata/graphs/graph_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def add_collection(self, collection: AbstractMetadata) -> None:
116116
from pydough.metadata.collections import CollectionMetadata
117117

118118
# Make sure the collection is actually a collection
119-
HasType(CollectionMetadata).verify(collection, f"collection {collection!r}")
119+
HasType(CollectionMetadata).verify(collection, "collection")
120120
assert isinstance(collection, CollectionMetadata)
121121

122122
# Verify sure the collection has not already been added to the graph

pydough/metadata/properties/property_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def __init__(
4545
synonyms: list[str] | None,
4646
extra_semantic_info: dict | None,
4747
):
48-
is_valid_name.verify(name, f"name {name!r}")
49-
HasType(CollectionMetadata).verify(collection, f"collection {collection!r}")
48+
is_valid_name.verify(name, f"property name {name!r}")
49+
HasType(CollectionMetadata).verify(collection, f"collection {name}")
5050
self._name: str = name
5151
self._collection: CollectionMetadata = collection
5252
super().__init__(description, synonyms, extra_semantic_info)

tests/test_metadata/invalid_graphs.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,28 @@
9393
],
9494
"relationships": []
9595
},
96+
{
97+
"name": "BAD_TABLE_NAME",
98+
"version": "V2",
99+
"collections": [
100+
{
101+
"name": "invalid table_name",
102+
"type": "simple table",
103+
"table path": "TableName",
104+
"unique properties": ["column_name"],
105+
"properties": [
106+
{
107+
"name": "column_name",
108+
"type": "table column",
109+
"column name": "column_name",
110+
"data type": "string",
111+
"description": "column description"
112+
}
113+
]
114+
}
115+
],
116+
"relationships": []
117+
},
96118
{
97119
"name": "BAD_COLUMN_NAME",
98120
"version": "V2",
@@ -116,17 +138,17 @@
116138
"relationships": []
117139
},
118140
{
119-
"name": "BAD_TABLE_NAME",
141+
"name": "BAD_UNIQUE_PROPERTY",
120142
"version": "V2",
121143
"collections": [
122144
{
123-
"name": "invalid table_name",
145+
"name": "collection",
124146
"type": "simple table",
125147
"table path": "TableName",
126-
"unique properties": ["key"],
148+
"unique properties": ["invalid column name"],
127149
"properties": [
128150
{
129-
"name": "column_name",
151+
"name": "invalid column name",
130152
"type": "table column",
131153
"column name": "column_name",
132154
"data type": "string",

tests/test_metadata_errors.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ def test_missing_property(get_sample_graph: graph_fetcher) -> None:
8585
),
8686
pytest.param(
8787
"BAD_COLLECTION_NAME_1",
88-
"name '0' must be a string that is a valid Python identifier",
88+
"collection name '0' must be a string that is a valid Python identifier",
8989
id="BAD_COLLECTION_NAME_1",
9090
),
9191
pytest.param(
9292
"BAD_COLLECTION_NAME_2",
93-
"name 'Invalid name' must be a string that is a valid Python identifier",
93+
"collection name 'Invalid name' must be a string that is a valid Python identifier",
9494
id="BAD_COLLECTION_NAME_2",
9595
),
9696
pytest.param(
@@ -100,18 +100,23 @@ def test_missing_property(get_sample_graph: graph_fetcher) -> None:
100100
),
101101
pytest.param(
102102
"BAD_PROPERTY_NAME_2",
103-
"name '0' must be a string that is a valid Python identifier",
103+
"collection name '0' must be a string that is a valid Python identifier",
104104
id="BAD_PROPERTY_NAME_2",
105105
),
106+
pytest.param(
107+
"BAD_TABLE_NAME",
108+
"collection name 'invalid table_name' must be a string that is a valid Python identifier",
109+
id="BAD_TABLE_NAME",
110+
),
106111
pytest.param(
107112
"BAD_COLUMN_NAME",
108-
"name 'invalid column name' must be a string that is a valid Python identifier",
109-
id="BAD_PROPERTY_NAME_2",
113+
"property name 'invalid column name' must be a string that is a valid Python identifier",
114+
id="BAD_COLUMN_NAME",
110115
),
111116
pytest.param(
112-
"BAD_TABLE_NAME",
113-
"name 'invalid table_name' must be a string that is a valid Python identifier",
114-
id="BAD_PROPERTY_NAME_2",
117+
"BAD_UNIQUE_PROPERTY",
118+
"property name 'invalid column name' must be a string that is a valid Python identifier",
119+
id="BAD_UNIQUE_PROPERTY",
115120
),
116121
pytest.param(
117122
"BAD_RELATIONSHIP_NAME",

0 commit comments

Comments
 (0)