@@ -171,3 +171,124 @@ def test_invalid_get_table_or_column_fqn(entity_link, error):
171171)
172172def test_get_table_fqn (entity_link , expected ):
173173 assert get_table_fqn (entity_link ) == expected
174+
175+
176+ @pytest .mark .parametrize (
177+ "entity_link,expected_fqn" ,
178+ [
179+ # ENTITY_TYPE keywords as column names
180+ pytest .param (
181+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::topic>" ,
182+ "rds.dev.dbt_jaffle.customers.topic" ,
183+ id = "entity_type_keyword_topic" ,
184+ ),
185+ pytest .param (
186+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::user>" ,
187+ "rds.dev.dbt_jaffle.customers.user" ,
188+ id = "entity_type_keyword_user" ,
189+ ),
190+ pytest .param (
191+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::database>" ,
192+ "rds.dev.dbt_jaffle.customers.database" ,
193+ id = "entity_type_keyword_database" ,
194+ ),
195+ pytest .param (
196+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::role>" ,
197+ "rds.dev.dbt_jaffle.customers.role" ,
198+ id = "entity_type_keyword_role" ,
199+ ),
200+ pytest .param (
201+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::chart>" ,
202+ "rds.dev.dbt_jaffle.customers.chart" ,
203+ id = "entity_type_keyword_chart" ,
204+ ),
205+ pytest .param (
206+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::dashboard>" ,
207+ "rds.dev.dbt_jaffle.customers.dashboard" ,
208+ id = "entity_type_keyword_dashboard" ,
209+ ),
210+ pytest .param (
211+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::pipeline>" ,
212+ "rds.dev.dbt_jaffle.customers.pipeline" ,
213+ id = "entity_type_keyword_pipeline" ,
214+ ),
215+ pytest .param (
216+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::team>" ,
217+ "rds.dev.dbt_jaffle.customers.team" ,
218+ id = "entity_type_keyword_team" ,
219+ ),
220+ # ENTITY_FIELD keywords as column names
221+ pytest .param (
222+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::description>" ,
223+ "rds.dev.dbt_jaffle.customers.description" ,
224+ id = "entity_field_keyword_description" ,
225+ ),
226+ pytest .param (
227+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::owner>" ,
228+ "rds.dev.dbt_jaffle.customers.owner" ,
229+ id = "entity_field_keyword_owner" ,
230+ ),
231+ pytest .param (
232+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::tags>" ,
233+ "rds.dev.dbt_jaffle.customers.tags" ,
234+ id = "entity_field_keyword_tags" ,
235+ ),
236+ pytest .param (
237+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::name>" ,
238+ "rds.dev.dbt_jaffle.customers.name" ,
239+ id = "entity_field_keyword_name" ,
240+ ),
241+ pytest .param (
242+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::tests>" ,
243+ "rds.dev.dbt_jaffle.customers.tests" ,
244+ id = "entity_field_keyword_tests" ,
245+ ),
246+ pytest .param (
247+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::displayName>" ,
248+ "rds.dev.dbt_jaffle.customers.displayName" ,
249+ id = "entity_field_keyword_displayName" ,
250+ ),
251+ ],
252+ )
253+ def test_reserved_keywords_get_table_or_column_fqn (entity_link , expected_fqn ):
254+ """Test that reserved keywords (ENTITY_TYPE and ENTITY_FIELD) can be used as column names.
255+
256+ This verifies that the EntityLink grammar correctly allows reserved keywords to be used
257+ as column names in entity links, which is important for real-world scenarios where
258+ column names might coincidentally match reserved words.
259+
260+ Args:
261+ entity_link (str): Entity link with reserved keyword as column name
262+ expected_fqn (str): Expected fully qualified name
263+ """
264+ assert get_table_or_column_fqn (entity_link ) == expected_fqn
265+
266+
267+ @pytest .mark .parametrize (
268+ "entity_link,expected_decoded_column" ,
269+ [
270+ pytest .param (
271+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::topic>" ,
272+ "topic" ,
273+ id = "decode_entity_type_keyword_topic" ,
274+ ),
275+ pytest .param (
276+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::description>" ,
277+ "description" ,
278+ id = "decode_entity_field_keyword_description" ,
279+ ),
280+ pytest .param (
281+ "<#E::table::rds.dev.dbt_jaffle.customers::columns::owner>" ,
282+ "owner" ,
283+ id = "decode_entity_field_keyword_owner" ,
284+ ),
285+ ],
286+ )
287+ def test_reserved_keywords_get_decoded_column (entity_link , expected_decoded_column ):
288+ """Test that reserved keywords can be decoded as column names.
289+
290+ Args:
291+ entity_link: Entity link with reserved keyword as column name
292+ expected_decoded_column: Expected decoded column name
293+ """
294+ assert get_decoded_column (entity_link ) == expected_decoded_column
0 commit comments