diff --git a/spanner/tests/_fixtures.py b/spanner/tests/_fixtures.py index d2345750b821..fe7e038b8846 100644 --- a/spanner/tests/_fixtures.py +++ b/spanner/tests/_fixtures.py @@ -42,6 +42,11 @@ name STRING(1024), value INT64 ) PRIMARY KEY (name); +CREATE TABLE string_plus_array_of_string ( + id INT64, + name STRING(16), + tags ARRAY ) + PRIMARY KEY (id); """ DDL_STATEMENTS = [stmt.strip() for stmt in DDL.split(';') if stmt.strip()] diff --git a/spanner/tests/system/test_system.py b/spanner/tests/system/test_system.py index 1626f3ed5b8e..f5b5a4ac059a 100644 --- a/spanner/tests/system/test_system.py +++ b/spanner/tests/system/test_system.py @@ -450,6 +450,30 @@ def test_batch_insert_then_read(self): rows = list(snapshot.read(self.TABLE, self.COLUMNS, self.ALL)) self._check_row_data(rows) + def test_batch_insert_then_read_string_array_of_string(self): + TABLE = 'string_plus_array_of_string' + COLUMNS = ['id', 'name', 'tags'] + ROWDATA = [ + (0, None, None), + (1, 'phred', ['yabba', 'dabba', 'do']), + (2, 'bharney', []), + (3, 'wylma', ['oh', None, 'phred']), + ] + retry = RetryInstanceState(_has_all_ddl) + retry(self._db.reload)() + + session = self._db.session() + session.create() + self.to_delete.append(session) + + with session.batch() as batch: + batch.delete(TABLE, self.ALL) + batch.insert(TABLE, COLUMNS, ROWDATA) + + snapshot = session.snapshot(read_timestamp=batch.committed) + rows = list(snapshot.read(TABLE, COLUMNS, self.ALL)) + self._check_row_data(rows, expected=ROWDATA) + def test_batch_insert_then_read_all_datatypes(self): retry = RetryInstanceState(_has_all_ddl) retry(self._db.reload)()