Skip to content

Commit c353f2b

Browse files
authored
Add spanner system tests: (googleapis#4372)
- Write / read back null string. - Write / read back empty array of string. - Write / read back null array of string. - Write / read back array of string with mixed null / non-null values. Toward googleapis#4364.
1 parent 85b190e commit c353f2b

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

spanner/tests/_fixtures.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
name STRING(1024),
4343
value INT64 )
4444
PRIMARY KEY (name);
45+
CREATE TABLE string_plus_array_of_string (
46+
id INT64,
47+
name STRING(16),
48+
tags ARRAY<STRING(16)> )
49+
PRIMARY KEY (id);
4550
"""
4651

4752
DDL_STATEMENTS = [stmt.strip() for stmt in DDL.split(';') if stmt.strip()]

spanner/tests/system/test_system.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,30 @@ def test_batch_insert_then_read(self):
450450
rows = list(snapshot.read(self.TABLE, self.COLUMNS, self.ALL))
451451
self._check_row_data(rows)
452452

453+
def test_batch_insert_then_read_string_array_of_string(self):
454+
TABLE = 'string_plus_array_of_string'
455+
COLUMNS = ['id', 'name', 'tags']
456+
ROWDATA = [
457+
(0, None, None),
458+
(1, 'phred', ['yabba', 'dabba', 'do']),
459+
(2, 'bharney', []),
460+
(3, 'wylma', ['oh', None, 'phred']),
461+
]
462+
retry = RetryInstanceState(_has_all_ddl)
463+
retry(self._db.reload)()
464+
465+
session = self._db.session()
466+
session.create()
467+
self.to_delete.append(session)
468+
469+
with session.batch() as batch:
470+
batch.delete(TABLE, self.ALL)
471+
batch.insert(TABLE, COLUMNS, ROWDATA)
472+
473+
snapshot = session.snapshot(read_timestamp=batch.committed)
474+
rows = list(snapshot.read(TABLE, COLUMNS, self.ALL))
475+
self._check_row_data(rows, expected=ROWDATA)
476+
453477
def test_batch_insert_then_read_all_datatypes(self):
454478
retry = RetryInstanceState(_has_all_ddl)
455479
retry(self._db.reload)()

0 commit comments

Comments
 (0)