Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hanfei1991/62fc3e6e8468f1346d610e94421100ab to your computer and use it in GitHub Desktop.
Save hanfei1991/62fc3e6e8468f1346d610e94421100ab to your computer and use it in GitHub Desktop.
generate_array.py
import random
import os
row_cnt = 100000
max_array_sz = 20
col_num = 2
for row in range(row_cnt):
array_sz = random.randint(0, max_array_sz);
insert = "insert into test values ("
for c in range (col_num):
array_str = "["
for i in range(array_sz):
num = random.randint(0,500)
array_str += str(num) + ","
if array_sz != 0:
array_str = array_str[:-1]
array_str += "]"
insert += array_str + ","
insert = insert[:-1] + ')'
command = './clickhouse/build/programs/clickhouse-client --query "%s "' % (insert)
os.system(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment