From 17875c184286a4608889ffd04ac0429c732cf1a8 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 20 Mar 2017 13:45:45 -0400 Subject: [PATCH] Add BigQuery system test for nested-nested records. Closes #2951. --- system_tests/bigquery.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/system_tests/bigquery.py b/system_tests/bigquery.py index db2376753a7f..d78e8e35f16e 100644 --- a/system_tests/bigquery.py +++ b/system_tests/bigquery.py @@ -664,6 +664,45 @@ def test_dump_table_w_public_data(self): table = dataset.table(TABLE_NAME) self._fetch_single_page(table) + def test_insert_nested_nested(self): + # See #2951 + SF = bigquery.SchemaField + schema = [ + SF('string_col', 'STRING', mode='NULLABLE'), + SF('record_col', 'RECORD', mode='NULLABLE', fields=[ + SF('nested_string', 'STRING', mode='NULLABLE'), + SF('nested_repeated', 'INTEGER', mode='REPEATED'), + SF('nested_record', 'RECORD', mode='NULLABLE', fields=[ + SF('nested_nested_string', 'STRING', mode='NULLABLE'), + ]), + ]), + ] + record = { + 'nested_string': 'another string value', + 'nested_repeated': [0, 1, 2], + 'nested_record': {'nested_nested_string': 'some deep insight'}, + } + to_insert = [ + ('Some value', record) + ] + table_name = 'test_table' + dataset = Config.CLIENT.dataset( + _make_dataset_name('issue_2951')) + + retry_403(dataset.create)() + self.to_delete.append(dataset) + + table = dataset.table(table_name, schema=schema) + table.create() + self.to_delete.insert(0, table) + + table.insert_data(to_insert) + + retry = RetryResult(_has_rows, max_tries=8) + rows = retry(self._fetch_single_page)(table) + + self.assertEqual(rows, to_insert) + def test_create_table_nested_schema(self): table_name = 'test_table' dataset = Config.CLIENT.dataset(