Skip to content

Commit 7e2318e

Browse files
committed
Do not create more partitions
1 parent 5cb686d commit 7e2318e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

tests/bwc/test_upgrade.py

+25-3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
) PARTITIONED BY (version) CLUSTERED INTO 1 SHARDS
7272
'''
7373

74+
CREATE_DYNAMIC_TABLE = '''
75+
CREATE TABLE dynamic (
76+
o object
77+
) WITH (column_policy = 'dynamic')
78+
'''
7479

7580
CREATE_DOC_TABLE = '''
7681
CREATE TABLE t1 (
@@ -240,6 +245,7 @@ def _do_upgrade(self,
240245
c.execute(CREATE_ANALYZER)
241246
c.execute(CREATE_DOC_TABLE)
242247
c.execute(CREATE_PARTED_TABLE)
248+
c.execute(CREATE_DYNAMIC_TABLE)
243249

244250
c.execute("DROP USER IF EXISTS trillian")
245251
c.execute("CREATE USER trillian")
@@ -258,20 +264,22 @@ def _do_upgrade(self,
258264
assert_busy(lambda: self.assert_green(conn, 'blob', 'b1'))
259265
self.assertIsNotNone(container.get(digest))
260266

267+
accumulated_dynamic_column_names: list[str] = []
261268
self._process_on_stop()
262269
for version_def in versions[1:]:
263270
timestamp = datetime.utcnow().isoformat(timespec='seconds')
264271
print(f"{timestamp} Upgrade to: {version_def.version}")
265-
self.assert_data_persistence(version_def, nodes, digest, paths)
272+
self.assert_data_persistence(version_def, nodes, digest, paths, accumulated_dynamic_column_names)
266273
# restart with latest version
267274
version_def = versions[-1]
268-
self.assert_data_persistence(version_def, nodes, digest, paths)
275+
self.assert_data_persistence(version_def, nodes, digest, paths, accumulated_dynamic_column_names)
269276

270277
def assert_data_persistence(self,
271278
version_def: VersionDef,
272279
nodes: int,
273280
digest: str,
274-
paths: Iterable[str]):
281+
paths: Iterable[str],
282+
accumulated_dynamic_column_names: list[str]):
275283
env = prepare_env(version_def.java_home)
276284
version = version_def.version
277285
cluster = self._new_cluster(version, nodes, data_paths=paths, settings=self.CLUSTER_SETTINGS, env=env)
@@ -303,6 +311,20 @@ def assert_data_persistence(self,
303311
cursor.execute(f'select * from versioned."{table}"')
304312
cursor.execute(f'insert into versioned."{table}" (id, col_int) values (?, ?)', [str(uuid4()), 1])
305313

314+
# to trigger `alter` stmt bug(https://github.com/crate/crate/pull/17178) that falsely updated the table's
315+
# version created setting that resulted in oids instead of column names in resultsets
316+
cursor.execute('ALTER TABLE doc.dynamic SET ("refresh_interval" = 900)')
317+
key = "t_" + version.replace('.', '_')
318+
obj = {key: True}
319+
cursor.execute('INSERT INTO doc.dynamic (o) values (?)', obj)
320+
cursor.execute('REFRESH TABLE doc.dynamic')
321+
accumulated_dynamic_column_names.append(key)
322+
cursor.execute('SELECT cols FROM doc.dynamic')
323+
result = cursor.fetchall()
324+
for row in result:
325+
for name in row[0].keys():
326+
self.assertIn(name, accumulated_dynamic_column_names)
327+
306328
# older versions had a bug that caused this to fail
307329
if version in ('latest-nightly', '3.2'):
308330
# Test that partition and dynamic columns can be created

0 commit comments

Comments
 (0)