71
71
) PARTITIONED BY (version) CLUSTERED INTO 1 SHARDS
72
72
'''
73
73
74
+ CREATE_DYNAMIC_TABLE = '''
75
+ CREATE TABLE dynamic (
76
+ o object
77
+ ) WITH (column_policy = 'dynamic')
78
+ '''
74
79
75
80
CREATE_DOC_TABLE = '''
76
81
CREATE TABLE t1 (
@@ -240,6 +245,7 @@ def _do_upgrade(self,
240
245
c .execute (CREATE_ANALYZER )
241
246
c .execute (CREATE_DOC_TABLE )
242
247
c .execute (CREATE_PARTED_TABLE )
248
+ c .execute (CREATE_DYNAMIC_TABLE )
243
249
244
250
c .execute ("DROP USER IF EXISTS trillian" )
245
251
c .execute ("CREATE USER trillian" )
@@ -258,20 +264,22 @@ def _do_upgrade(self,
258
264
assert_busy (lambda : self .assert_green (conn , 'blob' , 'b1' ))
259
265
self .assertIsNotNone (container .get (digest ))
260
266
267
+ accumulated_dynamic_column_names : list [str ] = []
261
268
self ._process_on_stop ()
262
269
for version_def in versions [1 :]:
263
270
timestamp = datetime .utcnow ().isoformat (timespec = 'seconds' )
264
271
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 )
266
273
# restart with latest version
267
274
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 )
269
276
270
277
def assert_data_persistence (self ,
271
278
version_def : VersionDef ,
272
279
nodes : int ,
273
280
digest : str ,
274
- paths : Iterable [str ]):
281
+ paths : Iterable [str ],
282
+ accumulated_dynamic_column_names : list [str ]):
275
283
env = prepare_env (version_def .java_home )
276
284
version = version_def .version
277
285
cluster = self ._new_cluster (version , nodes , data_paths = paths , settings = self .CLUSTER_SETTINGS , env = env )
@@ -303,6 +311,20 @@ def assert_data_persistence(self,
303
311
cursor .execute (f'select * from versioned."{ table } "' )
304
312
cursor .execute (f'insert into versioned."{ table } " (id, col_int) values (?, ?)' , [str (uuid4 ()), 1 ])
305
313
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
+
306
328
# older versions had a bug that caused this to fail
307
329
if version in ('latest-nightly' , '3.2' ):
308
330
# Test that partition and dynamic columns can be created
0 commit comments