Skip to content

Commit b09cb1b

Browse files
authored
Merge 6670f58 into d4e572d
2 parents d4e572d + 6670f58 commit b09cb1b

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

ydb/tests/library/harness/kikimr_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def __init__(
157157
generic_connector_config=None, # typing.Optional[TGenericConnectorConfig]
158158
kafka_api_port=None,
159159
metadata_section=None,
160+
column_shard_config=None,
160161
):
161162
if extra_feature_flags is None:
162163
extra_feature_flags = []
@@ -282,11 +283,12 @@ def __init__(
282283
self.yaml_config['pqconfig']['require_credentials_in_new_protocol'] = False
283284
self.yaml_config['pqconfig']['root'] = '/Root/PQ'
284285
self.yaml_config['pqconfig']['quoting_config']['enable_quoting'] = False
285-
286286
if pq_client_service_types:
287287
self.yaml_config['pqconfig']['client_service_type'] = []
288288
for service_type in pq_client_service_types:
289289
self.yaml_config['pqconfig']['client_service_type'].append({'name': service_type})
290+
if column_shard_config:
291+
self.yaml_config["column_shard_config"] = column_shard_config
290292

291293
self.yaml_config['grpc_config']['services'].extend(extra_grpc_services)
292294

ydb/tests/workloads/olap_workload/__main__.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ def join(self):
137137

138138

139139
class WorkloadTablesCreateDrop(WorkloadBase):
140-
def __init__(self, client, prefix, stop):
140+
def __init__(self, client, prefix, stop, allow_nullables_in_pk):
141141
super().__init__(client, prefix, "create_drop", stop)
142+
self.allow_nullables_in_pk = allow_nullables_in_pk
142143
self.created = 0
143144
self.deleted = 0
144145
self.tables = set()
@@ -166,11 +167,21 @@ def create_table(self, table):
166167
column_n = random.randint(1, 10000)
167168
primary_key_column_n = random.randint(1, column_n)
168169
partition_key_column_n = random.randint(1, primary_key_column_n)
169-
columns = [random.choice(supported_pk_types) for _ in range(primary_key_column_n)] + [random.choice(supported_types) for _ in range(column_n - primary_key_column_n)]
170+
column_defs = []
171+
for i in range(column_n):
172+
if i < primary_key_column_n:
173+
c = random.choice(supported_pk_types)
174+
if not self.allow_nullables_in_pk or random.choice([False, True]):
175+
c += " NOT NULL"
176+
else:
177+
c = random.choice(supported_types)
178+
if random.choice([False, True]):
179+
c += " NOT NULL"
180+
column_defs.append(c)
170181

171182
stmt = f"""
172183
CREATE TABLE `{path}` (
173-
{", ".join(["c" + str(i) + " " + columns[i] + " NOT NULL" for i in range(column_n)])},
184+
{", ".join(["c" + str(i) + " " + column_defs[i] for i in range(column_n)])},
174185
PRIMARY KEY({", ".join(["c" + str(i) for i in range(primary_key_column_n)])})
175186
)
176187
PARTITION BY HASH({", ".join(["c" + str(i) for i in range(partition_key_column_n)])})
@@ -273,11 +284,12 @@ def get_workload_thread_funcs(self):
273284

274285

275286
class WorkloadRunner:
276-
def __init__(self, client, name, duration):
287+
def __init__(self, client, name, duration, allow_nullables_in_pk):
277288
self.client = client
278-
self.name = name
289+
self.name = args.path
279290
self.tables_prefix = "/".join([self.client.database, self.name])
280-
self.duration = duration
291+
self.duration = args.duration
292+
self.allow_nullables_in_pk = allow_nullables_in_pk
281293

282294
def __enter__(self):
283295
self._cleanup()
@@ -294,7 +306,7 @@ def _cleanup(self):
294306
def run(self):
295307
stop = threading.Event()
296308
workloads = [
297-
WorkloadTablesCreateDrop(self.client, self.name, stop),
309+
WorkloadTablesCreateDrop(self.client, self.name, stop, self.allow_nullables_in_pk),
298310
# WorkloadInsertDelete(self.client, self.name, stop), TODO fix https://github.com/ydb-platform/ydb/issues/12871
299311
]
300312
for w in workloads:
@@ -320,8 +332,9 @@ def run(self):
320332
parser.add_argument("--database", default="Root/test", help="A database to connect")
321333
parser.add_argument("--path", default="olap_workload", help="A path prefix for tables")
322334
parser.add_argument("--duration", default=10 ** 9, type=lambda x: int(x), help="A duration of workload in seconds.")
335+
parser.add_argument("--allow-nullables-in-pk", default=False, help="Allow nullable types for columns in a Primary Key.")
323336
args = parser.parse_args()
324337
client = YdbClient(args.endpoint, args.database, True)
325338
client.wait_connection()
326-
with WorkloadRunner(client, args.path, args.duration) as runner:
339+
with WorkloadRunner(client, args.path, args.duration, args.allow_nullables_in_pk) as runner:
327340
runner.run()

ydb/tests/workloads/olap_workload/tests/test_workload.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
class TestYdbWorkload(object):
1010
@classmethod
1111
def setup_class(cls):
12-
cls.cluster = KiKiMR(KikimrConfigGenerator(erasure=Erasure.MIRROR_3_DC))
12+
cls.cluster = KiKiMR(KikimrConfigGenerator(
13+
erasure=Erasure.MIRROR_3_DC,
14+
column_shard_config={
15+
"allow_nullable_columns_in_pk": True,
16+
}
17+
))
1318
cls.cluster.start()
1419

1520
@classmethod
@@ -24,6 +29,7 @@ def test(self):
2429
"--endpoint", f"grpc://localhost:{self.cluster.nodes[1].grpc_port}",
2530
"--database=/Root",
2631
"--duration", "120",
32+
"--allow-nullables-in-pk", "1",
2733
],
2834
wait=True
2935
)

0 commit comments

Comments
 (0)