in holo-e2e-performance-tool/src/main/java/com/alibaba/hologres/performace/client/SqlUtil.java [13:94]
public static void createTable(Connection conn, boolean partition, String tableName,
int columnCount, int shardCount, String orientation, boolean enableBinlog, int binlogTTL,
boolean enableBitmap, boolean additionTsColumn, boolean hasPk, boolean prefixPk , String dataColumnType) throws
SQLException {
StringBuilder sb = new StringBuilder();
sb.append("set hg_experimental_force_sync_replay = on;\n");
sb.append("begin;\ndrop table if exists ")
.append(tableName)
.append(";\ncreate table ")
.append(tableName)
.append("(id int");
if (prefixPk) {
sb.append(",id1 int");
}
for (int i = 0; i < columnCount; ++i) {
sb.append(",name").append(i).append(" ").append(dataColumnType);
}
if (additionTsColumn) {
sb.append(",ts").append(" timestamptz not null");
}
if (partition) {
sb.append(", ds int not null");
}
if (hasPk) {
sb.append(",primary key(id");
if (prefixPk) {
sb.append(",id1");
}
if (partition) {
sb.append(",ds");
}
sb.append(")");
}
sb.append(")");
if (partition) {
sb.append("partition by list(ds)");
}
sb.append(";\n");
if (!hasPk || (hasPk && prefixPk)) {
sb.append("call set_table_property('")
.append(tableName)
.append("','distribution_key','")
.append("id")
.append("');\n");
}
sb.append("call set_table_property('")
.append(tableName)
.append("','orientation','")
.append(orientation)
.append("');\n");
if (shardCount > 0) {
sb.append("call set_table_property('")
.append(tableName)
.append("','shard_count','")
.append(shardCount)
.append("');\n");
}
if (enableBinlog) {
sb.append("call set_table_property('")
.append(tableName)
.append("','clustering_key','id');\n");
sb.append("call set_table_property('")
.append(tableName)
.append("','binlog.level','replica');\n");
sb.append("call set_table_property('")
.append(tableName)
.append("','binlog.ttl','")
.append(binlogTTL)
.append("');\n");
}
if (!enableBitmap) {
sb.append("call set_table_property('")
.append(tableName)
.append("','bitmap_columns','');\n");
}
sb.append("end;");
String sql = sb.toString();
LOG.info("sql:{}", sql);
try (Statement stat = conn.createStatement()) {
stat.execute(sb.toString());
}
}