@@ -259,6 +259,51 @@ def test_csv_to_json(self):
259259 lines = True ).sort_values ('rank' ).reindex ()
260260 pd .testing .assert_frame_equal (data , result )
261261
262+ def test_circular_reference_validation (self ):
263+ with beam .Pipeline (options = beam .options .pipeline_options .PipelineOptions (
264+ pickle_library = 'cloudpickle' )) as p :
265+ # pylint: disable=expression-not-assigned
266+ with self .assertRaisesRegex (ValueError , r'Circular reference detected.*' ):
267+ p | YamlTransform (
268+ '''
269+ type: composite
270+ transforms:
271+ - type: Create
272+ name: Create
273+ config:
274+ elements: [0, 1, 3, 4]
275+ input: Create
276+ - type: PyMap
277+ name: PyMap
278+ config:
279+ fn: "lambda row: row.element * row.element"
280+ input: Create
281+ output: PyMap
282+ ''' ,
283+ providers = TEST_PROVIDERS )
284+
285+ def test_circular_reference_multi_inputs_validation (self ):
286+ with beam .Pipeline (options = beam .options .pipeline_options .PipelineOptions (
287+ pickle_library = 'cloudpickle' )) as p :
288+ # pylint: disable=expression-not-assigned
289+ with self .assertRaisesRegex (ValueError , r'Circular reference detected.*' ):
290+ p | YamlTransform (
291+ '''
292+ type: composite
293+ transforms:
294+ - type: Create
295+ name: Create
296+ config:
297+ elements: [0, 1, 3, 4]
298+ - type: PyMap
299+ name: PyMap
300+ config:
301+ fn: "lambda row: row.element * row.element"
302+ input: [Create, PyMap]
303+ output: PyMap
304+ ''' ,
305+ providers = TEST_PROVIDERS )
306+
262307 def test_name_is_not_ambiguous (self ):
263308 with beam .Pipeline (options = beam .options .pipeline_options .PipelineOptions (
264309 pickle_library = 'cloudpickle' )) as p :
@@ -285,7 +330,7 @@ def test_name_is_ambiguous(self):
285330 with beam .Pipeline (options = beam .options .pipeline_options .PipelineOptions (
286331 pickle_library = 'cloudpickle' )) as p :
287332 # pylint: disable=expression-not-assigned
288- with self .assertRaisesRegex (ValueError , r'Ambiguous .*' ):
333+ with self .assertRaisesRegex (ValueError , r'Circular reference detected .*' ):
289334 p | YamlTransform (
290335 '''
291336 type: composite
0 commit comments