xiaokang commented on code in PR #34089: URL: https://github.com/apache/doris/pull/34089#discussion_r1597773780
########## fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java: ########## @@ -273,6 +273,8 @@ public class SessionVariable implements Serializable, Writable { public static final String ENABLE_PROJECTION = "enable_projection"; + public static final String ENABLE_SHORT_CIRCUIT_QUERY = "enable_short_circuit_query"; Review Comment: What's the purpose of this variable? ########## regression-test/suites/point_query_p0/test_rowstore.groovy: ########## @@ -16,6 +16,260 @@ // under the License. suite("test_rowstore", "p0") { + // Parse url + String jdbcUrl = context.config.jdbcUrl + def user = context.config.jdbcUser + def password = context.config.jdbcPassword + String urlWithoutSchema = jdbcUrl.substring(jdbcUrl.indexOf("://") + 3) + def sql_ip = urlWithoutSchema.substring(0, urlWithoutSchema.indexOf(":")) + def realDb = "regression_test_point_query_p0" + def sql_port + if (urlWithoutSchema.indexOf("/") >= 0) { + // e.g: jdbc:mysql://locahost:8080/?a=b + sql_port = urlWithoutSchema.substring(urlWithoutSchema.indexOf(":") + 1, urlWithoutSchema.indexOf("/")) + } else { + // e.g: jdbc:mysql://locahost:8080 + sql_port = urlWithoutSchema.substring(urlWithoutSchema.indexOf(":") + 1) + } + def prepare_url = "jdbc:mysql://" + sql_ip + ":" + sql_port + "/" + realDb + "?&useServerPrepStmts=true" + + sql "DROP TABLE IF EXISTS table_with_column_group" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group ( + `k1` int(11) NULL COMMENT "", + `v1` text NULL COMMENT "", + `v2` bigint NULL COMMENT "", + `v3` double NULL COMMENT "", + `v4` datetime NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`k1`) + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "store_row_column" = "false", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "storage_format" = "V2", + "column_groups" = "group1:v1,v2,v3;group2:v2,v4" + ) + """ + sql """ + insert into table_with_column_group values (1, "11111111111111111111111111111111111111", 3, 4.0, '2021-02-01 11:11:11'), (2, "222222222222222222222222222222222", 3, 4, '2022-02-01 11:11:11'), (3, "33333333333333333333333333333333", 3, 4, '2023-02-01 11:11:11'); + """ + sql "set show_hidden_columns = true" + qt_sql """ + select length(__DORIS_ROW_STORE_COL__group1), length(__DORIS_ROW_STORE_COL__group2) from table_with_column_group order by k1; + """ + + sql "DROP TABLE IF EXISTS table_with_column_group2" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group2 ( + `k1` int(11) NULL COMMENT "", + `v1` text NULL COMMENT "", + `v2` bigint NULL COMMENT "", + `v3` double NULL COMMENT "", + `v4` datetime NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`k1`) + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "store_row_column" = "false", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "storage_format" = "V2", + "column_groups" = "group2:v2" + ) + """ + sql """ + insert into table_with_column_group2 values (1, "11111111111111111111111111111111111111", 3, 4.0, '2021-02-01 11:11:11'), (2, "222222222222222222222222222222222", 3, 4, '2022-02-01 11:11:11'), (3, "33333333333333333333333333333333", 3, 4, '2023-02-01 11:11:11'); + """ + qt_sql """ + select length(__DORIS_ROW_STORE_COL__group2) from table_with_column_group2 order by k1; + """ + + sql "DROP TABLE IF EXISTS table_with_column_group3" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group3 ( + `k1` int(11) NULL COMMENT "", + `v1` text NULL COMMENT "", + `v2` bigint NULL COMMENT "", + `v3` double NULL COMMENT "", + `v4` datetime NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`k1`) + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "store_row_column" = "false", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "storage_format" = "V2", + "column_groups" = "group1:v2,v4" + ) + """ + sql """ + insert into table_with_column_group3 values (1, "11111111111111111111111111111111111111", 3, 4.0, '2021-02-01 11:11:11'), (2, "222222222222222222222222222222222", 3, 4, '2022-02-01 11:11:11'), (3, "33333333333333333333333333333333", 3, 4, '2023-02-01 11:11:11'); + """ + qt_sql """ + select length(__DORIS_ROW_STORE_COL__group1) from table_with_column_group3 order by k1; + """ + sql "set show_hidden_columns = false" + + sql """DROP TABLE IF EXISTS table_with_column_group_xxx""" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group_xxx ( + `user_id` int NOT NULL COMMENT "用户id", + `date` DATE NOT NULL COMMENT "数据灌入日期时间", + `datev2` DATEV2 NOT NULL COMMENT "数据灌入日期时间", + `datetimev2_1` DATETIMEV2(3) NOT NULL COMMENT "数据灌入日期时间", + `datetimev2_2` DATETIMEV2(6) NOT NULL COMMENT "数据灌入日期时间", + `city` VARCHAR(20) COMMENT "用户所在城市", + `age` SMALLINT COMMENT "用户年龄", + `sex` TINYINT COMMENT "用户性别", + `last_visit_date` DATETIME DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", + `last_update_date` DATETIME DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次更新时间", + `datetime_val1` DATETIMEV2(3) DEFAULT "1970-01-01 00:00:00.111" COMMENT "用户最后一次访问时间", + `datetime_val2` DATETIME(6) DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次更新时间", + `last_visit_date_not_null` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", + `cost` BIGINT DEFAULT "0" COMMENT "用户总消费", + `max_dwell_time` INT DEFAULT "0" COMMENT "用户最大停留时间", + `min_dwell_time` INT DEFAULT "99999" COMMENT "用户最小停留时间") + UNIQUE KEY(`user_id`, `date`, `datev2`, `datetimev2_1`, `datetimev2_2`, `city`, `age`, `sex`) DISTRIBUTED BY HASH(`user_id`) + PROPERTIES ( "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "store_row_column" = "false", + "column_groups" = "group1:datetimev2_1,datetime_val1,datetime_val2,max_dwell_time" + ); + """ + sql """ INSERT INTO table_with_column_group_xxx values + (1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.021', '2017-10-01 11:11:11.011', 'Beijing', 10, 1, '2020-01-01', '2020-01-01', '2017-10-01 11:11:11.170000', '2017-10-01 11:11:11.110111', '2020-01-01', 1, 30, 20) + """ + sql """ INSERT INTO table_with_column_group_xxx VALUES + (1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.022', '2017-10-01 11:11:11.012', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', '2017-10-01 11:11:11.160000', '2017-10-01 11:11:11.100111', '2020-01-02', 1, 31, 19) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.023', '2017-10-01 11:11:11.013', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', '2017-10-01 11:11:11.150000', '2017-10-01 11:11:11.130111', '2020-01-02', 1, 31, 21) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.024', '2017-10-01 11:11:11.014', 'Beijing', 10, 1, '2020-01-03', '2020-01-03', '2017-10-01 11:11:11.140000', '2017-10-01 11:11:11.120111', '2020-01-03', 1, 32, 20) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.025', '2017-10-01 11:11:11.015', 'Beijing', 10, 1, '2020-01-03', '2020-01-03', '2017-10-01 11:11:11.100000', '2017-10-01 11:11:11.140111', '2020-01-03', 1, 32, 22) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.026', '2017-10-01 11:11:11.016', 'Beijing', 10, 1, '2020-01-04', '2020-01-04', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.150111', '2020-01-04', 1, 33, 21) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.027', '2017-10-01 11:11:11.017', 'Beijing', 10, 1, NULL, NULL, NULL, NULL, '2020-01-05', 1, 34, 20) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (4, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.028', '2017-10-01 11:11:11.018', 'Beijing', 10, 1, NULL, NULL, NULL, NULL, '2020-01-05', 1, 34, 20) + """ + + // set server side prepared statement url + connect(user = user, password = password, url = prepare_url) { + def prep_sql = { sql_str, k -> + def stmt = prepareStatement sql_str + stmt.setInt(1, k) + assertEquals(stmt.class, com.mysql.cj.jdbc.ServerPreparedStatement); + qe_point_select stmt + } + // group1 + def sql_str = "select v1, v2, v3 from table_with_column_group where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + // group 2 + sql_str = "select v2, v4 from table_with_column_group where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + // group 1 + sql_str = "select v2, v3 from table_with_column_group where k1 = ?" + prep_sql sql_str, 3 + sql_str = "select v2, v1 from table_with_column_group where k1 = ?" + prep_sql sql_str, 3 + + + // group 2 + sql_str = "select v2 from table_with_column_group where k1 = ?" + prep_sql sql_str, 1 + + sql_str = "select v2 from table_with_column_group2 where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + + sql_str = "select v4 from table_with_column_group3 where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + + def setPrepareStmtArgs = {stmt, user_id, date, datev2, datetimev2_1, datetimev2_2, city, age, sex -> + java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS"); + stmt.setInt(1, user_id) + stmt.setDate(2, java.sql.Date.valueOf(date)) + stmt.setDate(3, java.sql.Date.valueOf(datev2)) + stmt.setTimestamp(4, new java.sql.Timestamp(formater.parse(datetimev2_1).getTime())) + stmt.setTimestamp(5, new java.sql.Timestamp(formater.parse(datetimev2_2).getTime())) + stmt.setString(6, city) + stmt.setInt(7, age) + stmt.setInt(8, sex) + } + + def stmt = prepareStatement """ SELECT datetimev2_1,datetime_val1,datetime_val2,max_dwell_time FROM table_with_column_group_xxx t where user_id = ? and date = ? and datev2 = ? and datetimev2_1 = ? and datetimev2_2 = ? and city = ? and age = ? and sex = ?; """ + setPrepareStmtArgs stmt, 1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.21', '2017-10-01 11:11:11.11', 'Beijing', 10, 1 + qe_point_select stmt Review Comment: Why not execute SQL in setPrepareStmtArgs just like prep_sql? ########## fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java: ########## @@ -70,6 +73,9 @@ public class TableProperty implements Writable { private TStorageMedium storageMedium = null; + // group name-> column columns + private Map<String, List<String>> columnGroups; Review Comment: use rowStoreColumnGroups in code for better readbility ########## fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java: ########## @@ -468,6 +469,36 @@ public void analyze(Analyzer analyzer) throws UserException { columnDefs.add(ColumnDef.newVersionColumnDef(AggregateType.REPLACE)); } } + + if (properties != null) { + Map<String, List<String>> columnGroups = PropertyAnalyzer.analyzeColumnGroups(Maps.newHashMap(properties)); Review Comment: It's duplicate with CreateTableInfo. ########## regression-test/suites/point_query_p0/test_rowstore.groovy: ########## @@ -16,6 +16,260 @@ // under the License. suite("test_rowstore", "p0") { + // Parse url + String jdbcUrl = context.config.jdbcUrl + def user = context.config.jdbcUser + def password = context.config.jdbcPassword + String urlWithoutSchema = jdbcUrl.substring(jdbcUrl.indexOf("://") + 3) + def sql_ip = urlWithoutSchema.substring(0, urlWithoutSchema.indexOf(":")) + def realDb = "regression_test_point_query_p0" + def sql_port + if (urlWithoutSchema.indexOf("/") >= 0) { + // e.g: jdbc:mysql://locahost:8080/?a=b + sql_port = urlWithoutSchema.substring(urlWithoutSchema.indexOf(":") + 1, urlWithoutSchema.indexOf("/")) + } else { + // e.g: jdbc:mysql://locahost:8080 + sql_port = urlWithoutSchema.substring(urlWithoutSchema.indexOf(":") + 1) + } + def prepare_url = "jdbc:mysql://" + sql_ip + ":" + sql_port + "/" + realDb + "?&useServerPrepStmts=true" + + sql "DROP TABLE IF EXISTS table_with_column_group" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group ( + `k1` int(11) NULL COMMENT "", + `v1` text NULL COMMENT "", + `v2` bigint NULL COMMENT "", + `v3` double NULL COMMENT "", + `v4` datetime NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`k1`) + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "store_row_column" = "false", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "storage_format" = "V2", + "column_groups" = "group1:v1,v2,v3;group2:v2,v4" + ) + """ + sql """ + insert into table_with_column_group values (1, "11111111111111111111111111111111111111", 3, 4.0, '2021-02-01 11:11:11'), (2, "222222222222222222222222222222222", 3, 4, '2022-02-01 11:11:11'), (3, "33333333333333333333333333333333", 3, 4, '2023-02-01 11:11:11'); + """ + sql "set show_hidden_columns = true" + qt_sql """ + select length(__DORIS_ROW_STORE_COL__group1), length(__DORIS_ROW_STORE_COL__group2) from table_with_column_group order by k1; + """ + + sql "DROP TABLE IF EXISTS table_with_column_group2" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group2 ( + `k1` int(11) NULL COMMENT "", + `v1` text NULL COMMENT "", + `v2` bigint NULL COMMENT "", + `v3` double NULL COMMENT "", + `v4` datetime NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`k1`) + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "store_row_column" = "false", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "storage_format" = "V2", + "column_groups" = "group2:v2" + ) + """ + sql """ + insert into table_with_column_group2 values (1, "11111111111111111111111111111111111111", 3, 4.0, '2021-02-01 11:11:11'), (2, "222222222222222222222222222222222", 3, 4, '2022-02-01 11:11:11'), (3, "33333333333333333333333333333333", 3, 4, '2023-02-01 11:11:11'); + """ + qt_sql """ + select length(__DORIS_ROW_STORE_COL__group2) from table_with_column_group2 order by k1; + """ + + sql "DROP TABLE IF EXISTS table_with_column_group3" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group3 ( + `k1` int(11) NULL COMMENT "", + `v1` text NULL COMMENT "", + `v2` bigint NULL COMMENT "", + `v3` double NULL COMMENT "", + `v4` datetime NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`k1`) + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "store_row_column" = "false", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "storage_format" = "V2", + "column_groups" = "group1:v2,v4" + ) + """ + sql """ + insert into table_with_column_group3 values (1, "11111111111111111111111111111111111111", 3, 4.0, '2021-02-01 11:11:11'), (2, "222222222222222222222222222222222", 3, 4, '2022-02-01 11:11:11'), (3, "33333333333333333333333333333333", 3, 4, '2023-02-01 11:11:11'); + """ + qt_sql """ + select length(__DORIS_ROW_STORE_COL__group1) from table_with_column_group3 order by k1; + """ + sql "set show_hidden_columns = false" + + sql """DROP TABLE IF EXISTS table_with_column_group_xxx""" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group_xxx ( + `user_id` int NOT NULL COMMENT "用户id", + `date` DATE NOT NULL COMMENT "数据灌入日期时间", + `datev2` DATEV2 NOT NULL COMMENT "数据灌入日期时间", + `datetimev2_1` DATETIMEV2(3) NOT NULL COMMENT "数据灌入日期时间", + `datetimev2_2` DATETIMEV2(6) NOT NULL COMMENT "数据灌入日期时间", + `city` VARCHAR(20) COMMENT "用户所在城市", + `age` SMALLINT COMMENT "用户年龄", + `sex` TINYINT COMMENT "用户性别", + `last_visit_date` DATETIME DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", + `last_update_date` DATETIME DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次更新时间", + `datetime_val1` DATETIMEV2(3) DEFAULT "1970-01-01 00:00:00.111" COMMENT "用户最后一次访问时间", + `datetime_val2` DATETIME(6) DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次更新时间", + `last_visit_date_not_null` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", + `cost` BIGINT DEFAULT "0" COMMENT "用户总消费", + `max_dwell_time` INT DEFAULT "0" COMMENT "用户最大停留时间", + `min_dwell_time` INT DEFAULT "99999" COMMENT "用户最小停留时间") + UNIQUE KEY(`user_id`, `date`, `datev2`, `datetimev2_1`, `datetimev2_2`, `city`, `age`, `sex`) DISTRIBUTED BY HASH(`user_id`) + PROPERTIES ( "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "store_row_column" = "false", + "column_groups" = "group1:datetimev2_1,datetime_val1,datetime_val2,max_dwell_time" + ); + """ + sql """ INSERT INTO table_with_column_group_xxx values + (1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.021', '2017-10-01 11:11:11.011', 'Beijing', 10, 1, '2020-01-01', '2020-01-01', '2017-10-01 11:11:11.170000', '2017-10-01 11:11:11.110111', '2020-01-01', 1, 30, 20) + """ + sql """ INSERT INTO table_with_column_group_xxx VALUES + (1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.022', '2017-10-01 11:11:11.012', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', '2017-10-01 11:11:11.160000', '2017-10-01 11:11:11.100111', '2020-01-02', 1, 31, 19) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.023', '2017-10-01 11:11:11.013', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', '2017-10-01 11:11:11.150000', '2017-10-01 11:11:11.130111', '2020-01-02', 1, 31, 21) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.024', '2017-10-01 11:11:11.014', 'Beijing', 10, 1, '2020-01-03', '2020-01-03', '2017-10-01 11:11:11.140000', '2017-10-01 11:11:11.120111', '2020-01-03', 1, 32, 20) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.025', '2017-10-01 11:11:11.015', 'Beijing', 10, 1, '2020-01-03', '2020-01-03', '2017-10-01 11:11:11.100000', '2017-10-01 11:11:11.140111', '2020-01-03', 1, 32, 22) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.026', '2017-10-01 11:11:11.016', 'Beijing', 10, 1, '2020-01-04', '2020-01-04', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.150111', '2020-01-04', 1, 33, 21) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.027', '2017-10-01 11:11:11.017', 'Beijing', 10, 1, NULL, NULL, NULL, NULL, '2020-01-05', 1, 34, 20) + """ + + sql """ INSERT INTO table_with_column_group_xxx VALUES + (4, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.028', '2017-10-01 11:11:11.018', 'Beijing', 10, 1, NULL, NULL, NULL, NULL, '2020-01-05', 1, 34, 20) + """ + + // set server side prepared statement url + connect(user = user, password = password, url = prepare_url) { + def prep_sql = { sql_str, k -> + def stmt = prepareStatement sql_str + stmt.setInt(1, k) + assertEquals(stmt.class, com.mysql.cj.jdbc.ServerPreparedStatement); + qe_point_select stmt + } + // group1 + def sql_str = "select v1, v2, v3 from table_with_column_group where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + // group 2 + sql_str = "select v2, v4 from table_with_column_group where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + // group 1 + sql_str = "select v2, v3 from table_with_column_group where k1 = ?" + prep_sql sql_str, 3 + sql_str = "select v2, v1 from table_with_column_group where k1 = ?" + prep_sql sql_str, 3 + + + // group 2 + sql_str = "select v2 from table_with_column_group where k1 = ?" + prep_sql sql_str, 1 + + sql_str = "select v2 from table_with_column_group2 where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + + sql_str = "select v4 from table_with_column_group3 where k1 = ?" + prep_sql sql_str, 1 + prep_sql sql_str, 2 + prep_sql sql_str, 3 + + def setPrepareStmtArgs = {stmt, user_id, date, datev2, datetimev2_1, datetimev2_2, city, age, sex -> + java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS"); + stmt.setInt(1, user_id) + stmt.setDate(2, java.sql.Date.valueOf(date)) + stmt.setDate(3, java.sql.Date.valueOf(datev2)) + stmt.setTimestamp(4, new java.sql.Timestamp(formater.parse(datetimev2_1).getTime())) + stmt.setTimestamp(5, new java.sql.Timestamp(formater.parse(datetimev2_2).getTime())) + stmt.setString(6, city) + stmt.setInt(7, age) + stmt.setInt(8, sex) + } + + def stmt = prepareStatement """ SELECT datetimev2_1,datetime_val1,datetime_val2,max_dwell_time FROM table_with_column_group_xxx t where user_id = ? and date = ? and datev2 = ? and datetimev2_1 = ? and datetimev2_2 = ? and city = ? and age = ? and sex = ?; """ + setPrepareStmtArgs stmt, 1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.21', '2017-10-01 11:11:11.11', 'Beijing', 10, 1 + qe_point_select stmt + setPrepareStmtArgs stmt, 1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.22', '2017-10-01 11:11:11.12', 'Beijing', 10, 1 + qe_point_select stmt + setPrepareStmtArgs stmt, 2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.23', '2017-10-01 11:11:11.13', 'Beijing', 10, 1 + qe_point_select stmt + setPrepareStmtArgs stmt, 2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.24', '2017-10-01 11:11:11.14', 'Beijing', 10, 1 + qe_point_select stmt + setPrepareStmtArgs stmt, 3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.25', '2017-10-01 11:11:11.15', 'Beijing', 10, 1 + qe_point_select stmt + setPrepareStmtArgs stmt, 3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.26', '2017-10-01 11:11:11.16', 'Beijing', 10, 1 + qe_point_select stmt + setPrepareStmtArgs stmt, 3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.27', '2017-10-01 11:11:11.17', 'Beijing', 10, 1 + qe_point_select stmt + setPrepareStmtArgs stmt, 4, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.28', '2017-10-01 11:11:11.18', 'Beijing', 10, 1 + qe_point_select stmt + } + try { + sql "select /*+ SET_VAR(enable_nereids_planner=false)*/ * from table_with_column_group where k1 = 1" + } catch (Exception e) { + log.info("ecounter {}", e.getMessage()); + assertTrue(e.getMessage().contains("Not support column store")) + } + + sql "DROP TABLE IF EXISTS table_with_column_group4" + sql """ + CREATE TABLE IF NOT EXISTS table_with_column_group4 ( + `k1` int(11) NULL COMMENT "", + `v1` text NULL COMMENT "", + `v2` bigint NULL COMMENT "", + `v3` double NULL COMMENT "", + `v4` datetime NULL COMMENT "" + ) ENGINE=OLAP + UNIQUE KEY(`k1`) + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "storage_format" = "V2", + "column_groups" = "group2:" Review Comment: What's the purpose and result of this testcase? ########## fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java: ########## @@ -592,6 +598,38 @@ public static Long analyzeVisibleVersion(Map<String, String> properties) throws return getPropertyLong(properties, PROPERTIES_VISIBLE_VERSION); } + // "column_groups" = "group1:column1,column2;group2:column3,column4" + public static Map<String, List<String>> analyzeColumnGroups(Map<String, String> properties) + throws AnalysisException { + Map<String, List<String>> columnGroups = null; + if (properties != null && properties.containsKey(PROPERTIES_COLUMN_GROUPS)) { + columnGroups = Maps.newHashMap(); + String columnGroupsStr = properties.get(PROPERTIES_COLUMN_GROUPS); + if (Strings.isNullOrEmpty(columnGroupsStr)) { + return columnGroups; + } + String[] groups = columnGroupsStr.split(SEMICOLON_SEPARATOR); + for (String group : groups) { + String[] parts = group.split(COLON_SEPARATOR); Review Comment: special case: column name contains , or ; ########## fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java: ########## @@ -468,6 +469,36 @@ public void analyze(Analyzer analyzer) throws UserException { columnDefs.add(ColumnDef.newVersionColumnDef(AggregateType.REPLACE)); } } + + if (properties != null) { Review Comment: put it inside row store branch ########## fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java: ########## @@ -413,7 +413,7 @@ public void setNewFullSchema(List<Column> newSchema) { } public Column getColumn(String name) { - return nameToColumn.get(name); + return nameToColumn.getOrDefault(name, null); Review Comment: It's the same as get(name) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org