From b1a15f9ac7d1f760fb5ad3a4af3c6919dc838231 Mon Sep 17 00:00:00 2001 From: feiniaofeiafei <53502832+feiniaofeiafei@users.noreply.github.com> Date: Mon, 27 May 2024 19:52:09 +0800 Subject: [PATCH] [Fix](planner) fix create view star except and modify cast to sql (#35324) cherry-pick #25951 to branch-2.0 cherry-pick #33726 to branch-2.0 --------- Co-authored-by: morrySnow <101034200+morrySnow@users.noreply.github.com> Co-authored-by: feiniaofeiafei --- .../apache/doris/catalog/AggStateType.java | 2 +- .../org/apache/doris/catalog/ArrayType.java | 6 +- .../org/apache/doris/catalog/ScalarType.java | 48 ++++++------ .../org/apache/doris/analysis/CastExpr.java | 2 +- .../org/apache/doris/analysis/SelectStmt.java | 7 +- .../doris/analysis/AddColumnsClauseTest.java | 12 +-- .../apache/doris/analysis/ColumnDefTest.java | 10 +-- .../analysis/CreateTableAsSelectStmtTest.java | 76 +++++++++---------- .../doris/analysis/CreateTableStmtTest.java | 26 +++---- .../analysis/ShowCreateTableStmtTest.java | 2 +- .../apache/doris/catalog/ColumnTypeTest.java | 12 +-- .../external/elasticsearch/EsUtilTest.java | 18 ++--- .../apache/doris/planner/QueryPlanTest.java | 4 +- .../doris/planner/TableFunctionPlanTest.java | 38 +++++----- .../test_show_create_table_and_views.out | 8 +- ...reate_view_star_except_and_cast_to_sql.out | 11 +++ .../test_simplify_arithmetic.groovy | 2 +- .../suites/nereids_syntax_p0/explain.groovy | 2 +- .../show/test_nested_complex_switch.groovy | 16 ++-- .../test_materialized_view_array.groovy | 2 +- .../test_materialized_view_struct.groovy | 2 +- ...te_view_star_except_and_cast_to_sql.groovy | 45 +++++++++++ 22 files changed, 203 insertions(+), 148 deletions(-) create mode 100644 regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out create mode 100644 regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy diff --git a/fe/fe-common/src/main/java/org/apache/doris/catalog/AggStateType.java b/fe/fe-common/src/main/java/org/apache/doris/catalog/AggStateType.java index 47477a08f8d553..3d1b6ac64f5bf4 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/catalog/AggStateType.java +++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/AggStateType.java @@ -73,7 +73,7 @@ public boolean getResultIsNullable() { @Override public String toSql(int depth) { StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("agg_state("); + stringBuilder.append("AGG_STATE("); for (int i = 0; i < subTypes.size(); i++) { if (i > 0) { stringBuilder.append(", "); diff --git a/fe/fe-common/src/main/java/org/apache/doris/catalog/ArrayType.java b/fe/fe-common/src/main/java/org/apache/doris/catalog/ArrayType.java index 4d4f461f8b0a24..c71684dfdb53a3 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/catalog/ArrayType.java +++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/ArrayType.java @@ -131,9 +131,9 @@ public static ArrayType create(Type type, boolean containsNull) { @Override public String toSql(int depth) { if (!containsNull) { - return "array"; + return "ARRAY<" + itemType.toSql(depth + 1) + " NOT NULL>"; } else { - return "array<" + itemType.toSql(depth + 1) + ">"; + return "ARRAY<" + itemType.toSql(depth + 1) + ">"; } } @@ -211,7 +211,7 @@ public boolean supportSubType(Type subType) { @Override public String toString() { - return String.format("ARRAY<%s>", itemType.toString()).toUpperCase(); + return String.format("ARRAY<%s>", itemType.toString()); } @Override diff --git a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java index b68ae83b2e8459..f9a57670d682f5 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java +++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java @@ -614,37 +614,37 @@ public String toSql(int depth) { switch (type) { case CHAR: if (isWildcardChar()) { - stringBuilder.append("character"); + stringBuilder.append("CHARACTER"); } else if (Strings.isNullOrEmpty(lenStr)) { - stringBuilder.append("char").append("(").append(len).append(")"); + stringBuilder.append("CHAR").append("(").append(len).append(")"); } else { - stringBuilder.append("char").append("(`").append(lenStr).append("`)"); + stringBuilder.append("CHAR").append("(`").append(lenStr).append("`)"); } break; case VARCHAR: if (isWildcardVarchar()) { - stringBuilder.append("varchar(*)"); + return "VARCHAR(" + MAX_VARCHAR_LENGTH + ")"; } else if (Strings.isNullOrEmpty(lenStr)) { - stringBuilder.append("varchar").append("(").append(len).append(")"); + stringBuilder.append("VARCHAR").append("(").append(len).append(")"); } else { - stringBuilder.append("varchar").append("(`").append(lenStr).append("`)"); + stringBuilder.append("VARCHAR").append("(`").append(lenStr).append("`)"); } break; case DECIMALV2: if (Strings.isNullOrEmpty(precisionStr)) { - stringBuilder.append("decimal").append("(").append(precision) + stringBuilder.append("DECIMAL").append("(").append(precision) .append(", ").append(scale).append(")"); } else if (!Strings.isNullOrEmpty(precisionStr) && !Strings.isNullOrEmpty(scaleStr)) { - stringBuilder.append("decimal").append("(`").append(precisionStr) + stringBuilder.append("DECIMAL").append("(`").append(precisionStr) .append("`, `").append(scaleStr).append("`)"); } else { - stringBuilder.append("decimal").append("(`").append(precisionStr).append("`)"); + stringBuilder.append("DECIMAL").append("(`").append(precisionStr).append("`)"); } break; case DECIMAL32: case DECIMAL64: case DECIMAL128: - String typeName = "decimalv3"; + String typeName = "DECIMALV3"; if (Strings.isNullOrEmpty(precisionStr)) { stringBuilder.append(typeName).append("(").append(precision) .append(", ").append(scale).append(")"); @@ -656,26 +656,26 @@ public String toSql(int depth) { } break; case DATETIMEV2: - stringBuilder.append("datetimev2").append("(").append(scale).append(")"); + stringBuilder.append("DATETIMEV2").append("(").append(scale).append(")"); break; case TIME: - stringBuilder.append("time"); + stringBuilder.append("TIME"); break; case TIMEV2: - stringBuilder.append("time").append("(").append(scale).append(")"); + stringBuilder.append("TIME").append("(").append(scale).append(")"); break; case BOOLEAN: - return "boolean"; + return "BOOLEAN"; case TINYINT: - return "tinyint(4)"; + return "TINYINT"; case SMALLINT: - return "smallint(6)"; + return "SMALLINT"; case INT: - return "int(11)"; + return "INT"; case BIGINT: - return "bigint(20)"; + return "BIGINT"; case LARGEINT: - return "largeint(40)"; + return "LARGEINT"; case FLOAT: case DOUBLE: case DATE: @@ -688,19 +688,19 @@ public String toSql(int depth) { case LAMBDA_FUNCTION: case ARRAY: case NULL_TYPE: - stringBuilder.append(type.toString().toLowerCase()); + stringBuilder.append(type); break; case STRING: - stringBuilder.append("text"); + stringBuilder.append("TEXT"); break; case JSONB: - stringBuilder.append("json"); + stringBuilder.append("JSON"); break; case AGG_STATE: - stringBuilder.append("agg_state(unknown)"); + stringBuilder.append("AGG_STATE(UNKNOWN)"); break; default: - stringBuilder.append("unknown type: " + type.toString()); + stringBuilder.append("unknown type: ").append(type); break; } return stringBuilder.toString(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java index fe464bf25bdbd5..5e97bf5ba90322 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java @@ -208,7 +208,7 @@ public String toSqlImpl() { return getChild(0).toSql(); } if (isAnalyzed) { - return "CAST(" + getChild(0).toSql() + " AS " + type.toString() + ")"; + return "CAST(" + getChild(0).toSql() + " AS " + type.toSql() + ")"; } else { return "CAST(" + getChild(0).toSql() + " AS " + (isImplicit ? type.toString() : targetTypeDef.toSql()) + ")"; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java index 344fa3df6dbf79..875e7b86357104 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java @@ -530,6 +530,9 @@ public void analyze(Analyzer analyzer) throws UserException { } // populate selectListExprs, aliasSMap, groupingSmap and colNames if (selectList.isExcept()) { + if (needToSql) { + originalExpr = new ArrayList<>(); + } List items = selectList.getItems(); TableName tblName = items.get(0).getTblName(); if (tblName == null) { @@ -550,10 +553,6 @@ public void analyze(Analyzer analyzer) throws UserException { // remove excepted columns resultExprs.removeIf(expr -> exceptCols.contains(expr.toColumnLabel())); colLabels.removeIf(exceptCols::contains); - if (needToSql) { - originalExpr = Expr.cloneList(resultExprs); - } - } else { if (needToSql) { originalExpr = new ArrayList<>(); diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/AddColumnsClauseTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/AddColumnsClauseTest.java index 53ce6a81ccda75..06a4fe601381f6 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/AddColumnsClauseTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/AddColumnsClauseTest.java @@ -48,21 +48,21 @@ public void testNormal() throws AnalysisException { columns.add(definition); AddColumnsClause clause = new AddColumnsClause(columns, null, null); clause.analyze(analyzer); - Assert.assertEquals("ADD COLUMN (`col1` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\", " - + "`col2` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\")", clause.toString()); + Assert.assertEquals("ADD COLUMN (`col1` INT NOT NULL DEFAULT \"0\" COMMENT \"\", " + + "`col2` INT NOT NULL DEFAULT \"0\" COMMENT \"\")", clause.toString()); clause = new AddColumnsClause(columns, "", null); clause.analyze(analyzer); - Assert.assertEquals("ADD COLUMN (`col1` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\", " - + "`col2` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\")", + Assert.assertEquals("ADD COLUMN (`col1` INT NOT NULL DEFAULT \"0\" COMMENT \"\", " + + "`col2` INT NOT NULL DEFAULT \"0\" COMMENT \"\")", clause.toString()); Assert.assertNull(clause.getRollupName()); clause = new AddColumnsClause(columns, "testTable", null); clause.analyze(analyzer); - Assert.assertEquals("ADD COLUMN (`col1` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\", " - + "`col2` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\") IN `testTable`", + Assert.assertEquals("ADD COLUMN (`col1` INT NOT NULL DEFAULT \"0\" COMMENT \"\", " + + "`col2` INT NOT NULL DEFAULT \"0\" COMMENT \"\") IN `testTable`", clause.toString()); Assert.assertNull(clause.getProperties()); Assert.assertEquals("testTable", clause.getRollupName()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java index d969be252032f2..fad5787a37bc79 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java @@ -61,7 +61,7 @@ public void testNormal() throws AnalysisException { ColumnDef column = new ColumnDef("col", intCol); column.analyze(true); - Assert.assertEquals("`col` int(11) NOT NULL COMMENT \"\"", column.toString()); + Assert.assertEquals("`col` INT NOT NULL COMMENT \"\"", column.toString()); Assert.assertEquals("col", column.getName()); Assert.assertEquals(PrimitiveType.INT, column.getType().getPrimitiveType()); Assert.assertNull(column.getAggregateType()); @@ -72,14 +72,14 @@ public void testNormal() throws AnalysisException { column.analyze(true); Assert.assertNull(column.getAggregateType()); Assert.assertEquals("10", column.getDefaultValue()); - Assert.assertEquals("`col` int(11) NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql()); + Assert.assertEquals("`col` INT NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql()); // agg column = new ColumnDef("col", floatCol, false, AggregateType.SUM, false, new DefaultValue(true, "10"), ""); column.analyze(true); Assert.assertEquals("10", column.getDefaultValue()); Assert.assertEquals(AggregateType.SUM, column.getAggregateType()); - Assert.assertEquals("`col` float SUM NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql()); + Assert.assertEquals("`col` FLOAT SUM NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql()); } @Test @@ -89,14 +89,14 @@ public void testReplaceIfNotNull() throws AnalysisException { ColumnDef column = new ColumnDef("col", intCol, false, AggregateType.REPLACE_IF_NOT_NULL, false, DefaultValue.NOT_SET, ""); column.analyze(true); Assert.assertEquals(AggregateType.REPLACE_IF_NOT_NULL, column.getAggregateType()); - Assert.assertEquals("`col` int(11) REPLACE_IF_NOT_NULL NULL DEFAULT \"null\" COMMENT \"\"", column.toSql()); + Assert.assertEquals("`col` INT REPLACE_IF_NOT_NULL NULL DEFAULT \"null\" COMMENT \"\"", column.toSql()); } // CHECKSTYLE IGNORE THIS LINE { // CHECKSTYLE IGNORE THIS LINE // not allow null ColumnDef column = new ColumnDef("col", intCol, false, AggregateType.REPLACE_IF_NOT_NULL, false, new DefaultValue(true, "10"), ""); column.analyze(true); Assert.assertEquals(AggregateType.REPLACE_IF_NOT_NULL, column.getAggregateType()); - Assert.assertEquals("`col` int(11) REPLACE_IF_NOT_NULL NULL DEFAULT \"10\" COMMENT \"\"", column.toSql()); + Assert.assertEquals("`col` INT REPLACE_IF_NOT_NULL NULL DEFAULT \"10\" COMMENT \"\"", column.toSql()); } // CHECKSTYLE IGNORE THIS LINE } diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java index c64e304d06136c..6bc7d57e5dca87 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java @@ -83,7 +83,7 @@ public void testDecimal() throws Exception { + "as select * from `test`.`decimal_table`"; createTableAsSelect(selectFromDecimal); Assertions.assertEquals("CREATE TABLE `select_decimal_table` (\n" - + " `userId` varchar(255) NOT NULL,\n" + + " `userId` VARCHAR(255) NOT NULL,\n" + " `amount_decimal` " + "DECIMAL" + "(10, 2) NOT NULL\n" + ") ENGINE=OLAP\n" @@ -160,8 +160,8 @@ public void testVarchar() throws Exception { createTableAsSelect(selectFromVarchar); ShowResultSet showResultSet = showCreateTableByName("select_varchar"); Assertions.assertEquals("CREATE TABLE `select_varchar` (\n" - + " `userId` varchar(255) NOT NULL,\n" - + " `username` varchar(255) NOT NULL\n" + + " `userId` VARCHAR(255) NOT NULL,\n" + + " `username` VARCHAR(255) NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n" @@ -186,7 +186,7 @@ public void testFunction() throws Exception { ShowResultSet showResultSet1 = showCreateTableByName("select_function_1"); Assertions.assertEquals( "CREATE TABLE `select_function_1` (\n" - + " `_col0` bigint(20) NULL\n" + + " `_col0` BIGINT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`_col0`)\n" + "COMMENT 'OLAP'\n" @@ -209,11 +209,11 @@ public void testFunction() throws Exception { ShowResultSet showResultSet2 = showCreateTableByName("select_function_2"); Assertions.assertEquals( "CREATE TABLE `select_function_2` (\n" - + " `_col0` bigint(20) NULL,\n" - + " `_col1` bigint(20) NULL,\n" - + " `_col2` bigint(20) NULL,\n" - + " `_col3` bigint(20) NULL,\n" - + " `_col4` bigint(20) NULL\n" + + " `_col0` BIGINT NULL,\n" + + " `_col1` BIGINT NULL,\n" + + " `_col2` BIGINT NULL,\n" + + " `_col3` BIGINT NULL,\n" + + " `_col4` BIGINT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`_col0`, `_col1`, `_col2`)\n" + "COMMENT 'OLAP'\n" @@ -237,7 +237,7 @@ public void testAlias() throws Exception { createTableAsSelect(selectAlias1); ShowResultSet showResultSet1 = showCreateTableByName("select_alias_1"); Assertions.assertEquals("CREATE TABLE `select_alias_1` (\n" - + " `amount` bigint(20) NULL\n" + + " `amount` BIGINT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`amount`)\n" + "COMMENT 'OLAP'\n" @@ -256,8 +256,8 @@ public void testAlias() throws Exception { createTableAsSelect(selectAlias2); ShowResultSet showResultSet2 = showCreateTableByName("select_alias_2"); Assertions.assertEquals("CREATE TABLE `select_alias_2` (\n" - + " `alias_name` varchar(255) NOT NULL,\n" - + " `username` varchar(255) NOT NULL\n" + + " `alias_name` VARCHAR(255) NOT NULL,\n" + + " `username` VARCHAR(255) NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`alias_name`)\n" + "COMMENT 'OLAP'\n" @@ -282,9 +282,9 @@ public void testJoin() throws Exception { createTableAsSelect(selectFromJoin); ShowResultSet showResultSet = showCreateTableByName("select_join"); Assertions.assertEquals("CREATE TABLE `select_join` (\n" - + " `userId` varchar(255) NOT NULL,\n" - + " `username` varchar(255) NOT NULL,\n" - + " `status` int(11) NOT NULL\n" + + " `userId` VARCHAR(255) NOT NULL,\n" + + " `username` VARCHAR(255) NOT NULL,\n" + + " `status` INT NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n" @@ -305,10 +305,10 @@ public void testJoin() throws Exception { createTableAsSelect(selectFromJoin1); ShowResultSet showResultSet1 = showCreateTableByName("select_join1"); Assertions.assertEquals("CREATE TABLE `select_join1` (\n" - + " `userId1` varchar(255) NOT NULL,\n" - + " `userId2` varchar(255) NOT NULL,\n" - + " `username` varchar(255) NOT NULL,\n" - + " `status` int(11) NOT NULL\n" + + " `userId1` VARCHAR(255) NOT NULL,\n" + + " `userId2` VARCHAR(255) NOT NULL,\n" + + " `username` VARCHAR(255) NOT NULL,\n" + + " `status` INT NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId1`)\n" + "COMMENT 'OLAP'\n" @@ -334,9 +334,9 @@ public void testName() throws Exception { createTableAsSelect(selectFromName); ShowResultSet showResultSet = showCreateTableByName("select_name"); Assertions.assertEquals("CREATE TABLE `select_name` (\n" - + " `user` varchar(255) NOT NULL,\n" - + " `testname` varchar(255) NOT NULL,\n" - + " `userstatus` int(11) NOT NULL\n" + + " `user` VARCHAR(255) NOT NULL,\n" + + " `testname` VARCHAR(255) NOT NULL,\n" + + " `userstatus` INT NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`user`)\n" + "COMMENT 'OLAP'\n" @@ -361,7 +361,7 @@ public void testUnion() throws Exception { ShowResultSet showResultSet = showCreateTableByName("select_union"); Assertions.assertEquals( "CREATE TABLE `select_union` (\n" - + " `userId` varchar(255) NULL\n" + + " `userId` VARCHAR(255) NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n" @@ -385,7 +385,7 @@ public void testCte() throws Exception { ShowResultSet showResultSet = showCreateTableByName("select_cte"); Assertions.assertEquals( "CREATE TABLE `select_cte` (\n" - + " `userId` varchar(255) NOT NULL\n" + + " `userId` VARCHAR(255) NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n" @@ -405,7 +405,7 @@ public void testCte() throws Exception { createTableAsSelect(selectFromCteAndUnion); ShowResultSet showResultSet1 = showCreateTableByName("select_cte_union"); Assertions.assertEquals("CREATE TABLE `select_cte_union` (\n" - + " `id` tinyint(4) NULL\n" + + " `id` TINYINT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`id`)\n" + "COMMENT 'OLAP'\n" @@ -429,8 +429,8 @@ public void testPartition() throws Exception { createTableAsSelect(selectFromPartition); ShowResultSet showResultSet = showCreateTableByName("selectPartition"); Assertions.assertEquals("CREATE TABLE `selectPartition` (\n" - + " `userId` varchar(255) NOT NULL,\n" - + " `username` varchar(255) NOT NULL\n" + + " `userId` VARCHAR(255) NOT NULL,\n" + + " `username` VARCHAR(255) NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`userId`)\n" + "COMMENT 'OLAP'\n" @@ -456,7 +456,7 @@ public void testDefaultTimestamp() throws Exception { createTableAsSelect(createSql); ShowResultSet showResultSet = showCreateTableByName("test_default_timestamp"); Assertions.assertEquals("CREATE TABLE `test_default_timestamp` (\n" - + " `userId` varchar(255) NOT NULL,\n" + + " `userId` VARCHAR(255) NOT NULL,\n" + " `date` datetime" + " NULL DEFAULT CURRENT_TIMESTAMP\n" + ") ENGINE=OLAP\n" @@ -483,7 +483,7 @@ public void testAggValue() throws Exception { ShowResultSet showResultSet = showCreateTableByName("test_agg_value"); Assertions.assertEquals( "CREATE TABLE `test_agg_value` (\n" - + " `username` varchar(255) NOT NULL\n" + + " `username` VARCHAR(255) NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`username`)\n" + "COMMENT 'OLAP'\n" @@ -508,8 +508,8 @@ public void testUseKeyType() throws Exception { ShowResultSet showResultSet = showCreateTableByName("test_use_key_type"); Assertions.assertEquals( "CREATE TABLE `test_use_key_type` (\n" - + " `userId` varchar(255) NOT NULL,\n" - + " `username` varchar(255) NOT NULL\n" + + " `userId` VARCHAR(255) NOT NULL,\n" + + " `username` VARCHAR(255) NOT NULL\n" + ") ENGINE=OLAP\n" + "UNIQUE KEY(`userId`)\n" + "COMMENT 'OLAP'\n" @@ -558,8 +558,8 @@ public void testQuerySchema() throws Exception { createStmts.add(createTableStmts.get(0)); if (tbl.getName().equals("qs1")) { Assert.assertEquals("CREATE TABLE `qs1` (\n" - + " `k1` int(11) NULL,\n" - + " `k2` int(11) NULL\n" + + " `k1` INT NULL,\n" + + " `k2` INT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`k1`, `k2`)\n" + "COMMENT 'OLAP'\n" @@ -576,8 +576,8 @@ public void testQuerySchema() throws Exception { createTableStmts.get(0)); } else { Assert.assertEquals("CREATE TABLE `qs2` (\n" - + " `k1` int(11) NULL,\n" - + " `k2` int(11) NULL\n" + + " `k1` INT NULL,\n" + + " `k2` INT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`k1`, `k2`)\n" + "COMMENT 'OLAP'\n" @@ -607,9 +607,9 @@ public void testVarcharLength() throws Exception { String showStr = showResultSet.getResultRows().get(0).get(1); Assertions.assertEquals( "CREATE TABLE `varchar_len1` (\n" - + " `_col0` varchar(*) NULL,\n" - + " `_col1` varchar(*) NULL,\n" - + " `userId` varchar(255) NOT NULL\n" + + " `_col0` VARCHAR(65533) NULL,\n" + + " `_col1` VARCHAR(65533) NULL,\n" + + " `userId` VARCHAR(255) NOT NULL\n" + ") ENGINE=OLAP\n" + "DUPLICATE KEY(`_col0`)\n" + "COMMENT 'OLAP'\n" diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java index b7bdfed3ffd019..d856599a3d7b9a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java @@ -337,7 +337,7 @@ public void testHllNoAggTab() throws Exception { null, null, ""); expectedEx.expect(AnalysisException.class); expectedEx.expectMessage( - "Aggregate type `col3` hll NONE NOT NULL COMMENT \"\" is not compatible with primitive type hll"); + "Aggregate type `col3` HLL NONE NOT NULL COMMENT \"\" is not compatible with primitive type HLL"); stmt.analyze(analyzer); } @@ -419,8 +419,8 @@ public void testCreateHudiTableWithSchema() throws UserException { stmt.analyze(analyzer); Assert.assertEquals( - "CREATE EXTERNAL TABLE `testCluster:db1`.`table1` (\n" + " `id` int(11) NOT NULL COMMENT \"\",\n" - + " `name` int(11) NULL COMMENT \"\"\n" + ") ENGINE = hudi\n" + "CREATE EXTERNAL TABLE `testCluster:db1`.`table1` (\n" + " `id` INT NOT NULL COMMENT \"\",\n" + + " `name` INT NULL COMMENT \"\"\n" + ") ENGINE = hudi\n" + "PROPERTIES (\"hudi.database\" = \"doris\",\n" + "\"hudi.hive.metastore.uris\" = \"thrift://127.0.0.1:9087\",\n" + "\"hudi.table\" = \"test\")", stmt.toString()); @@ -455,8 +455,8 @@ public void testToSql() { properties, null, "", null); String createTableSql = "CREATE TABLE IF NOT EXISTS `demo`.`testTosql1` (\n" - + " `a` bigint(20) NOT NULL COMMENT \"\",\n" - + " `b` int(11) NOT NULL COMMENT \"\"\n" + + " `a` BIGINT NOT NULL COMMENT \"\",\n" + + " `b` INT NOT NULL COMMENT \"\"\n" + ") ENGINE = olap\n" + "AGGREGATE KEY(`a`)\n" + "PROPERTIES (\"replication_num\" = \"1\")"; @@ -484,14 +484,14 @@ public void testToSql() { tableName, columnDefs, engineName, keysDesc, null, null, properties, null, "", null); createTableSql = "CREATE TABLE `demo`.`testTosql2` (\n" - + " `a` bigint(20) NOT NULL COMMENT \"\",\n" - + " `b` int(11) NOT NULL COMMENT \"\",\n" - + " `c` text NULL COMMENT \"\",\n" - + " `d` double NULL COMMENT \"\",\n" - + " `e` decimalv3(38, 0) NOT NULL COMMENT \"\",\n" - + " `f` date NOT NULL COMMENT \"\",\n" - + " `g` smallint(6) NOT NULL COMMENT \"\",\n" - + " `h` boolean NOT NULL COMMENT \"\"\n" + + " `a` BIGINT NOT NULL COMMENT \"\",\n" + + " `b` INT NOT NULL COMMENT \"\",\n" + + " `c` TEXT NULL COMMENT \"\",\n" + + " `d` DOUBLE NULL COMMENT \"\",\n" + + " `e` DECIMALV3(38, 0) NOT NULL COMMENT \"\",\n" + + " `f` DATE NOT NULL COMMENT \"\",\n" + + " `g` SMALLINT NOT NULL COMMENT \"\",\n" + + " `h` BOOLEAN NOT NULL COMMENT \"\"\n" + ") ENGINE = olap\n" + "DUPLICATE KEY(`a`, `d`, `f`)\n" + "PROPERTIES (\"replication_num\" = \"10\")"; diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java index fe9adf9ccd0c31..0a5653b7f9ed34 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/ShowCreateTableStmtTest.java @@ -48,7 +48,7 @@ public void testNormal() throws Exception { String sql = "show create table table1"; ShowResultSet showResultSet = showCreateTable(sql); String showSql = showResultSet.getResultRows().get(0).get(1); - Assertions.assertTrue(showSql.contains("`k1` int(11) NULL COMMENT 'test column k1'")); + Assertions.assertTrue(showSql.contains("`k1` INT NULL COMMENT 'test column k1'")); Assertions.assertTrue(showSql.contains("COMMENT 'test table1'")); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTypeTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTypeTest.java index 351a0e9b3eddc0..7b4965efc4bd70 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTypeTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTypeTest.java @@ -48,7 +48,7 @@ public void testPrimitiveType() throws AnalysisException { type.analyze(null); Assert.assertEquals(PrimitiveType.INT, type.getType().getPrimitiveType()); - Assert.assertEquals("int(11)", type.toSql()); + Assert.assertEquals("INT", type.toSql()); // equal type TypeDef type2 = TypeDef.create(PrimitiveType.INT); @@ -69,7 +69,7 @@ public void testInvalidType() throws AnalysisException { public void testCharType() throws AnalysisException { TypeDef type = TypeDef.createVarchar(10); type.analyze(null); - Assert.assertEquals("varchar(10)", type.toString()); + Assert.assertEquals("VARCHAR(10)", type.toString()); Assert.assertEquals(PrimitiveType.VARCHAR, type.getType().getPrimitiveType()); Assert.assertEquals(10, ((ScalarType) type.getType()).getLength()); @@ -91,10 +91,10 @@ public void testDecimal() throws AnalysisException { TypeDef type = TypeDef.createDecimal(12, 5); type.analyze(null); if (Config.enable_decimal_conversion) { - Assert.assertEquals("decimalv3(12, 5)", type.toString()); + Assert.assertEquals("DECIMALV3(12, 5)", type.toString()); Assert.assertEquals(PrimitiveType.DECIMAL64, type.getType().getPrimitiveType()); } else { - Assert.assertEquals("decimal(12, 5)", type.toString()); + Assert.assertEquals("DECIMALV3(12, 5)", type.toString()); Assert.assertEquals(PrimitiveType.DECIMALV2, type.getType().getPrimitiveType()); } Assert.assertEquals(12, ((ScalarType) type.getType()).getScalarPrecision()); @@ -119,7 +119,7 @@ public void testDecimal() throws AnalysisException { public void testDatetimeV2() throws AnalysisException { TypeDef type = TypeDef.createDatetimeV2(3); type.analyze(null); - Assert.assertEquals("datetimev2(3)", type.toString()); + Assert.assertEquals("DATETIMEV2(3)", type.toString()); Assert.assertEquals(PrimitiveType.DATETIMEV2, type.getType().getPrimitiveType()); Assert.assertEquals(ScalarType.DATETIME_PRECISION, ((ScalarType) type.getType()).getScalarPrecision()); Assert.assertEquals(3, ((ScalarType) type.getType()).getScalarScale()); @@ -160,7 +160,7 @@ public void testDateV2() throws AnalysisException { public void testTimeV2() throws AnalysisException { TypeDef type = TypeDef.createTimeV2(3); type.analyze(null); - Assert.assertEquals("time(3)", type.toString()); + Assert.assertEquals("TIME(3)", type.toString()); Assert.assertEquals(PrimitiveType.TIMEV2, type.getType().getPrimitiveType()); Assert.assertEquals(ScalarType.DATETIME_PRECISION, ((ScalarType) type.getType()).getScalarPrecision()); Assert.assertEquals(3, ((ScalarType) type.getType()).getScalarScale()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java index 1cdf1cb94df9d2..025876fd06effb 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java @@ -227,25 +227,25 @@ public void testDateType() throws IOException, URISyntaxException { String name = column.getName(); String type = column.getType().toSql(); if ("test2".equals(name)) { - Assertions.assertEquals("datetimev2(0)", type); + Assertions.assertEquals("DATETIMEV2(0)", type); } if ("test3".equals(name)) { - Assertions.assertEquals("datetimev2(0)", type); + Assertions.assertEquals("DATETIMEV2(0)", type); } if ("test4".equals(name)) { - Assertions.assertEquals("datev2", type); + Assertions.assertEquals("DATEV2", type); } if ("test5".equals(name)) { - Assertions.assertEquals("datetimev2(0)", type); + Assertions.assertEquals("DATETIMEV2(0)", type); } if ("test6".equals(name)) { - Assertions.assertEquals("datev2", type); + Assertions.assertEquals("DATEV2", type); } if ("test7".equals(name)) { - Assertions.assertEquals("datetimev2(0)", type); + Assertions.assertEquals("DATETIMEV2(0)", type); } if ("test8".equals(name)) { - Assertions.assertEquals("bigint(20)", type); + Assertions.assertEquals("BIGINT", type); } } } @@ -255,8 +255,8 @@ public void testFieldAlias() throws IOException, URISyntaxException { ObjectNode testFieldAlias = EsUtil.getRootSchema( EsUtil.getMapping(loadJsonFromFile("data/es/test_field_alias.json")), null, new ArrayList<>()); List parseColumns = EsUtil.genColumnsFromEs("test_field_alias", null, testFieldAlias, true, new ArrayList<>()); - Assertions.assertEquals("datetimev2(0)", parseColumns.get(2).getType().toSql()); - Assertions.assertEquals("text", parseColumns.get(4).getType().toSql()); + Assertions.assertEquals("DATETIMEV2(0)", parseColumns.get(2).getType().toSql()); + Assertions.assertEquals("TEXT", parseColumns.get(4).getType().toSql()); } @Test diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java index b31baecf7fce18..e6bb0dd9cfcf71 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java @@ -573,11 +573,11 @@ public void testTypeCast() throws Exception { // disable implicit cast hll/bitmap to string assertSQLPlanOrErrorMsgContains( "select length(id2) from test.hll_table;", - "No matching function with signature: length(hll)" + "No matching function with signature: length(HLL)" ); assertSQLPlanOrErrorMsgContains( "select length(id2) from test.bitmap_table;", - "No matching function with signature: length(bitmap)" + "No matching function with signature: length(BITMAP)" ); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/TableFunctionPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/TableFunctionPlanTest.java index 1ec175173ee045..b8eaec685a8209 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/TableFunctionPlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/TableFunctionPlanTest.java @@ -79,7 +79,7 @@ public void normalTableFunction() throws Exception { explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')")); Assert.assertTrue(explainString.contains("tuple ids: 0 1")); Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR")); } /* Case2 without output explode column @@ -95,7 +95,7 @@ public void withoutOutputExplodeColumn() throws Exception { explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')")); Assert.assertTrue(explainString.contains("tuple ids: 0 1")); Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR")); } /* Case3 group by explode column @@ -116,7 +116,7 @@ public void groupByExplodeColumn() throws Exception { explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')")); Assert.assertTrue(explainString.contains("tuple ids: 0 1")); Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR")); // group by tuple Assert.assertTrue(explainString.contains("TupleDescriptor{id=2, tbl=null, byteSize=32}")); } @@ -135,7 +135,7 @@ public void whereExplodeColumn() throws Exception { Assert.assertTrue(explainString.contains("PREDICATES: `e1` = '1'")); Assert.assertTrue(explainString.contains("tuple ids: 0 1")); Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR")); } /* Case5 where normal column @@ -151,7 +151,7 @@ public void whereNormalColumn() throws Exception { explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')")); Assert.assertTrue(explainString.contains("tuple ids: 0 1")); Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR")); Assert.assertTrue(UtFrameUtils.checkPlanResultContainsNode(explainString, 0, "OlapScanNode")); Assert.assertTrue(explainString.contains("PREDICATES: `k1` = 1")); } @@ -171,10 +171,10 @@ public void testMultiLateralView() throws Exception { Assert.assertTrue(explainString.contains("lateral view tuple id: 1 2")); // lateral view 2 tuple Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp2, byteSize=32}")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e2, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e2, colUniqueId=-1, type=VARCHAR")); // lateral view 1 tuple Assert.assertTrue(explainString.contains("TupleDescriptor{id=2, tbl=tmp1, byteSize=32}")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=VARCHAR")); } // test explode_split function @@ -188,11 +188,11 @@ public void testMultiLateralView() throws Exception { public void errorParam() throws Exception { String sql = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ k1, e1 from db1.tbl1 lateral view explode_split(k2) tmp as e1;"; String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql); - Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(varchar(1))")); + Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(VARCHAR(1))")); sql = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ k1, e1 from db1.tbl1 lateral view explode_split(k1) tmp as e1;"; explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql); - Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(int(11))")); + Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(INT)")); } /* Case2 table function in where stmt @@ -203,7 +203,7 @@ public void tableFunctionInWhere() throws Exception { String sql = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ k1 from db1.tbl1 where explode_split(k2, \",\");"; String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql); Assert.assertTrue(explainString, - explainString.contains("No matching function with signature: explode_split(varchar(1), varchar(*)).")); + explainString.contains("No matching function with signature: explode_split(VARCHAR(1), VARCHAR(65533)).")); } // test projection @@ -350,8 +350,8 @@ public void scalarFunctionInLateralView() throws Exception { explainString.contains("table function: explode_split(concat(`a`.`k2`, ',', `a`.`k3`), ',')")); Assert.assertTrue(explainString.contains("lateral view tuple id: 1")); Assert.assertTrue(explainString.contains("output slot id: 3")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=0, col=k2, colUniqueId=1, type=varchar(1)")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=k3, colUniqueId=2, type=varchar(1)")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=0, col=k2, colUniqueId=1, type=VARCHAR(1)")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=k3, colUniqueId=2, type=VARCHAR(1)")); } // lateral view of subquery @@ -368,7 +368,7 @@ public void lateralViewColumnOfReduceTuple() throws Exception { Assert.assertTrue(explainString.contains("lateral view tuple id: 2")); Assert.assertTrue(explainString.contains("output slot id: 2")); Assert.assertTrue(explainString.contains("tuple ids: 0 2")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=VARCHAR")); } /* @@ -384,7 +384,7 @@ public void aggInlineView() throws Exception { Assert.assertTrue(explainString.contains("lateral view tuple id: 3")); Assert.assertTrue(explainString.contains("output slot id: 3")); Assert.assertTrue(explainString.contains("tuple ids: 1 3")); - Assert.assertTrue(explainString.contains("SlotDescriptor{id=3, col=e1, colUniqueId=-1, type=varchar")); + Assert.assertTrue(explainString.contains("SlotDescriptor{id=3, col=e1, colUniqueId=-1, type=VARCHAR")); } /* @@ -404,19 +404,19 @@ public void aggColumnInlineViewInTB() throws Exception { String formatString = explainString.replaceAll(" ", ""); System.out.println(formatString); Assert.assertTrue(formatString.contains( - "SlotDescriptor{id=0,col=k1,colUniqueId=0,type=int" + "SlotDescriptor{id=0,col=k1,colUniqueId=0,type=INT" )); Assert.assertTrue(formatString.contains( - "SlotDescriptor{id=1,col=k2,colUniqueId=1,type=varchar(1)" + "SlotDescriptor{id=1,col=k2,colUniqueId=1,type=VARCHAR(1)" )); Assert.assertTrue(formatString.contains( - "SlotDescriptor{id=2,col=k1,colUniqueId=0,type=int" + "SlotDescriptor{id=2,col=k1,colUniqueId=0,type=INT" )); Assert.assertTrue(formatString.contains( - "SlotDescriptor{id=3,col=null,colUniqueId=null,type=varchar" + "SlotDescriptor{id=3,col=null,colUniqueId=null,type=VARCHAR" )); Assert.assertTrue(formatString.contains( - "SlotDescriptor{id=6,col=e1,colUniqueId=-1,type=varchar" + "SlotDescriptor{id=6,col=e1,colUniqueId=-1,type=VARCHAR" )); } diff --git a/regression-test/data/show_p0/test_show_create_table_and_views.out b/regression-test/data/show_p0/test_show_create_table_and_views.out index 1e27c1bcf138a2..f280a24812d7af 100644 --- a/regression-test/data/show_p0/test_show_create_table_and_views.out +++ b/regression-test/data/show_p0/test_show_create_table_and_views.out @@ -1,6 +1,6 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !show -- -show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` largeint(40) NOT NULL,\n `good_id` largeint(40) NOT NULL,\n `cost` bigint(20) SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); -- !select -- 1 1 30 @@ -36,11 +36,11 @@ show_create_table_and_views_view CREATE VIEW `show_create_table_and_views_view` 300 1 -- !show -- -show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` largeint(40) NOT NULL,\n `good_id` largeint(40) NOT NULL,\n `cost` bigint(20) SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); -- !show -- -show_create_table_and_views_like CREATE TABLE `show_create_table_and_views_like` (\n `user_id` largeint(40) NOT NULL,\n `good_id` largeint(40) NOT NULL,\n `cost` bigint(20) SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_like CREATE TABLE `show_create_table_and_views_like` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); -- !show -- -show_create_table_and_views_like_with_rollup CREATE TABLE `show_create_table_and_views_like_with_rollup` (\n `user_id` largeint(40) NOT NULL,\n `good_id` largeint(40) NOT NULL,\n `cost` bigint(20) SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_like_with_rollup CREATE TABLE `show_create_table_and_views_like_with_rollup` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); diff --git a/regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out b/regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out new file mode 100644 index 00000000000000..7fc76481729505 --- /dev/null +++ b/regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out @@ -0,0 +1,11 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !test_select_star_except -- +1 1 +2 1 +3 5 +4 5 +6 \N + +-- !test_sql -- +v_mal_old_create_view2 CREATE VIEW `v_mal_old_create_view2` COMMENT 'VIEW' AS SELECT CAST(CAST(`a` AS TEXT) AS TIME(0)) AS `CAST(CAST(``a`` AS TEXT) AS TIME(0))` FROM `default_cluster:regression_test_view_p0`.`mal_old_create_view`; utf8 utf8_general_ci + diff --git a/regression-test/suites/nereids_rules_p0/expression/simplify_arithmetic/test_simplify_arithmetic.groovy b/regression-test/suites/nereids_rules_p0/expression/simplify_arithmetic/test_simplify_arithmetic.groovy index bc1fc20ee8fe9b..e0abc3f16c8446 100644 --- a/regression-test/suites/nereids_rules_p0/expression/simplify_arithmetic/test_simplify_arithmetic.groovy +++ b/regression-test/suites/nereids_rules_p0/expression/simplify_arithmetic/test_simplify_arithmetic.groovy @@ -30,7 +30,7 @@ suite("test_simplify_arithmetic") { explain { sql """ select -3 - (7 + id) from test_simplify_arithmetic""" verbose true - contains """type=bigint""" + contains """type=BIGINT""" } qt_return_type_after_projection_should_be_bigint """ diff --git a/regression-test/suites/nereids_syntax_p0/explain.groovy b/regression-test/suites/nereids_syntax_p0/explain.groovy index c38b89fd0518d4..568238c137be46 100644 --- a/regression-test/suites/nereids_syntax_p0/explain.groovy +++ b/regression-test/suites/nereids_syntax_p0/explain.groovy @@ -63,7 +63,7 @@ suite("nereids_explain") { when 1>1 then cast(1 as float) else 0.0 end; """ - contains "SlotDescriptor{id=0, col=null, colUniqueId=null, type=double, nullable=false}" + contains "SlotDescriptor{id=0, col=null, colUniqueId=null, type=DOUBLE, nullable=false}" } def explainStr = sql("select sum(if(lo_tax=1,lo_tax,0)) from lineorder where false").toString() diff --git a/regression-test/suites/query_p0/show/test_nested_complex_switch.groovy b/regression-test/suites/query_p0/show/test_nested_complex_switch.groovy index 2051635d761750..5639d52ddb0d52 100644 --- a/regression-test/suites/query_p0/show/test_nested_complex_switch.groovy +++ b/regression-test/suites/query_p0/show/test_nested_complex_switch.groovy @@ -142,45 +142,45 @@ suite("test_nested_complex_switch", "query") { // map test { sql sql_m_s - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: MAP>" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: MAP>" } test { sql sql_m_a - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: MAP,text>" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: MAP,TEXT>" } test { sql sql_m_m - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: MAP>" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: MAP>" } // array test { sql sql_a_s - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: ARRAY>" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: ARRAY>" } test { sql sql_a_m - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: ARRAY>" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported data type: ARRAY>" } // struct test { sql sql_s_s - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported field type: STRUCT for STRUCT" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported field type: STRUCT for STRUCT" } test { sql sql_s_a - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported field type: array for STRUCT" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported field type: ARRAY for STRUCT" } test { sql sql_s_m - exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported field type: MAP for STRUCT" + exception "java.sql.SQLException: errCode = 2, detailMessage = Unsupported field type: MAP for STRUCT" } } finally { diff --git a/regression-test/suites/rollup_p0/test_materialized_view_array.groovy b/regression-test/suites/rollup_p0/test_materialized_view_array.groovy index 501ff0734cd719..a4acde9294691e 100644 --- a/regression-test/suites/rollup_p0/test_materialized_view_array.groovy +++ b/regression-test/suites/rollup_p0/test_materialized_view_array.groovy @@ -67,7 +67,7 @@ suite("test_materialized_view_array", "rollup") { create_test_table.call(tableName) test { sql "CREATE MATERIALIZED VIEW idx AS select k2,k1, k3, k4, k5 from ${tableName}" - exception "errCode = 2, detailMessage = The ARRAY column[`mv_k2` array NULL] not support to create materialized view" + exception "errCode = 2, detailMessage = The ARRAY column[`mv_k2` ARRAY NULL] not support to create materialized view" } } finally { try_sql("DROP TABLE IF EXISTS ${tableName}") diff --git a/regression-test/suites/rollup_p0/test_materialized_view_struct.groovy b/regression-test/suites/rollup_p0/test_materialized_view_struct.groovy index 5ae06a6c262cbd..b44500af811d76 100644 --- a/regression-test/suites/rollup_p0/test_materialized_view_struct.groovy +++ b/regression-test/suites/rollup_p0/test_materialized_view_struct.groovy @@ -59,7 +59,7 @@ suite("test_materialized_view_struct", "rollup") { create_test_table.call(tableName) test { sql "CREATE MATERIALIZED VIEW idx AS select k2,k1, k3, k4, k5 from ${tableName}" - exception "errCode = 2, detailMessage = The STRUCT column[`mv_k2` STRUCT NULL] not support to create materialized view" + exception "errCode = 2, detailMessage = The STRUCT column[`mv_k2` STRUCT NULL] not support to create materialized view" } } finally { try_sql("DROP TABLE IF EXISTS ${tableName}") diff --git a/regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy b/regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy new file mode 100644 index 00000000000000..e22f929544b261 --- /dev/null +++ b/regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy @@ -0,0 +1,45 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("create_view_star_except_and_cast_to_sql") { + sql "SET enable_nereids_planner=false;" + + sql """ + DROP TABLE IF EXISTS mal_old_create_view + """ + sql """ + create table mal_old_create_view(pk int, a int, b int) distributed by hash(pk) buckets 10 + properties('replication_num' = '1'); + """ + + sql """ + insert into mal_old_create_view values(2,1,3),(1,1,2),(3,5,6),(6,null,6),(4,5,6); + """ + sql "sync" + sql "drop view if EXISTS v_mal_old_create_view" + + sql "create view v_mal_old_create_view as select * except(a) from mal_old_create_view" + + qt_test_select_star_except "select * from v_mal_old_create_view order by pk,b" + + sql "drop view if EXISTS v_mal_old_create_view2" + + sql "create view v_mal_old_create_view2 as select cast(cast(a as string) as time) from mal_old_create_view" + qt_test_sql "show create view v_mal_old_create_view2" + sql "select * from v_mal_old_create_view2" + +} \ No newline at end of file