From 8e69f37bbc74045170a345a1cd0a340b20edf4c3 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Mon, 1 Apr 2024 11:45:43 +0800 Subject: [PATCH] [chore](Nereids) turn off fallback --- .../plans/commands/info/CreateViewInfo.java | 18 ++++---- .../org/apache/doris/qe/ConnectProcessor.java | 41 +++++++++++++++++-- .../org/apache/doris/qe/SessionVariable.java | 4 +- .../org/apache/doris/qe/StmtExecutor.java | 16 +++----- .../doris/catalog/CreateFunctionTest.java | 8 ++-- .../jdbc/test_mysql_jdbc_catalog.groovy | 30 +++++++------- .../test_mysql_jdbc_driver5_catalog.groovy | 30 +++++++------- .../test_ntile_function.groovy | 2 +- 8 files changed, 87 insertions(+), 62 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java index 084fe3af3f461cf..9a81c874d85c776 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java @@ -97,15 +97,6 @@ public CreateViewInfo(boolean ifNotExists, TableNameInfo viewName, String commen /** init */ public void init(ConnectContext ctx) throws UserException { - analyzeAndFillRewriteSqlMap(querySql, ctx); - OutermostPlanFinderContext outermostPlanFinderContext = new OutermostPlanFinderContext(); - analyzedPlan.accept(OutermostPlanFinder.INSTANCE, outermostPlanFinderContext); - List outputs = outermostPlanFinderContext.outermostPlan.getOutput(); - createFinalCols(outputs); - } - - /**validate*/ - public void validate(ConnectContext ctx) throws UserException { viewName.analyze(ctx); FeNameFormat.checkTableName(viewName.getTbl()); // disallow external catalog @@ -116,6 +107,15 @@ public void validate(ConnectContext ctx) throws UserException { ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLE_ACCESS_DENIED_ERROR, PrivPredicate.CREATE.getPrivs().toString(), viewName.getTbl()); } + analyzeAndFillRewriteSqlMap(querySql, ctx); + OutermostPlanFinderContext outermostPlanFinderContext = new OutermostPlanFinderContext(); + analyzedPlan.accept(OutermostPlanFinder.INSTANCE, outermostPlanFinderContext); + List outputs = outermostPlanFinderContext.outermostPlan.getOutput(); + createFinalCols(outputs); + } + + /**validate*/ + public void validate(ConnectContext ctx) throws UserException { NereidsPlanner planner = new NereidsPlanner(ctx.getStatementContext()); planner.plan(new UnboundResultSink<>(logicalQuery), PhysicalProperties.ANY, ExplainLevel.NONE); Set colSets = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java index 9cda1a40ac9dd10..fcabc01f1da23d8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java @@ -17,6 +17,9 @@ package org.apache.doris.qe; +import org.apache.doris.analysis.CreateTableAsSelectStmt; +import org.apache.doris.analysis.CreateTableStmt; +import org.apache.doris.analysis.DeleteStmt; import org.apache.doris.analysis.ExplainOptions; import org.apache.doris.analysis.InsertStmt; import org.apache.doris.analysis.KillStmt; @@ -25,6 +28,7 @@ import org.apache.doris.analysis.SqlParser; import org.apache.doris.analysis.SqlScanner; import org.apache.doris.analysis.StatementBase; +import org.apache.doris.analysis.UpdateStmt; import org.apache.doris.analysis.UserIdentity; import org.apache.doris.catalog.Column; import org.apache.doris.catalog.DatabaseIf; @@ -246,6 +250,7 @@ public void executeQuery(MysqlCommand mysqlCommand, String originStmt) throws Ex && CacheAnalyzer.canUseSqlCache(sessionVariable); List stmts = null; Exception nereidsParseException = null; + Exception nereidsSyntaxException = null; long parseSqlStartTime = System.currentTimeMillis(); List cachedStmts = null; // Nereids do not support prepare and execute now, so forbid prepare command, only process query command @@ -273,13 +278,14 @@ public void executeQuery(MysqlCommand mysqlCommand, String originStmt) throws Ex // Because ParseException means the sql is not supported by Nereids. // It should be parsed by old parser, so not setting nereidsParseException to avoid // suppressing the exception thrown by old parser. + nereidsParseException = e; } catch (Exception e) { // TODO: We should catch all exception here until we support all query syntax. if (LOG.isDebugEnabled()) { LOG.debug("Nereids parse sql failed with other exception. Reason: {}. Statement: \"{}\".", e.getMessage(), convertedStmt); } - nereidsParseException = e; + nereidsSyntaxException = e; } } } @@ -292,8 +298,8 @@ public void executeQuery(MysqlCommand mysqlCommand, String originStmt) throws Ex // if NereidsParser and oldParser both failed, // prove is a new feature implemented only on the nereids, // so an error message for the new nereids is thrown - if (nereidsParseException != null) { - throwable = nereidsParseException; + if (nereidsSyntaxException != null) { + throwable = nereidsSyntaxException; } // Parse sql failed, audit it and return handleQueryException(throwable, convertedStmt, null, null); @@ -301,6 +307,35 @@ public void executeQuery(MysqlCommand mysqlCommand, String originStmt) throws Ex } } + if (mysqlCommand == MysqlCommand.COM_QUERY + && ctx.getSessionVariable().isEnableNereidsPlanner() + && !ctx.getSessionVariable().enableFallbackToOriginalPlanner + && stmts.stream().allMatch(s -> s instanceof QueryStmt + || s instanceof InsertStmt + || s instanceof UpdateStmt + || s instanceof DeleteStmt + || s instanceof CreateTableAsSelectStmt + || s instanceof CreateTableStmt)) { + String errMsg; + Throwable exception = null; + if (nereidsParseException != null) { + errMsg = nereidsParseException.getMessage(); + exception = nereidsParseException; + } else if (nereidsSyntaxException != null) { + errMsg = nereidsSyntaxException.getMessage(); + exception = nereidsSyntaxException; + } else { + errMsg = "Nereids parse DQL failed. " + originStmt; + } + if (exception == null) { + exception = new AnalysisException(errMsg); + } else { + exception = new AnalysisException(errMsg, exception); + } + handleQueryException(exception, originStmt, null, null); + return; + } + List origSingleStmtList = null; // if stmts.size() > 1, split originStmt to multi singleStmts if (stmts.size() > 1) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java index eb1d511f45e01e8..896ffc27cd2b161 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java @@ -1261,13 +1261,13 @@ public void setEnableLeftZigZag(boolean enableLeftZigZag) { // for nereids, fallback will cause the Doris return the correct result although the syntax is unsupported // in nereids for some mistaken modification. You should set it on the @VariableMgr.VarAttr(name = ENABLE_FALLBACK_TO_ORIGINAL_PLANNER, needForward = true) - public boolean enableFallbackToOriginalPlanner = true; + public boolean enableFallbackToOriginalPlanner = false; @VariableMgr.VarAttr(name = ENABLE_NEREIDS_TIMEOUT, needForward = true) public boolean enableNereidsTimeout = true; @VariableMgr.VarAttr(name = "nereids_timeout_second", needForward = true) - public int nereidsTimeoutSecond = 5; + public int nereidsTimeoutSecond = 60; @VariableMgr.VarAttr(name = ENABLE_PUSH_DOWN_NO_GROUP_AGG) public boolean enablePushDownNoGroupAgg = true; diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index 19faa5559991394..261d605cf0b2d39 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -586,23 +586,17 @@ public void execute(TUniqueId queryId) throws Exception { } // FIXME: Force fallback for: // 1. group commit because nereids does not support it (see the following `isGroupCommit` variable) - // 2. insert into command because some nereids cases fail (including case1) // Skip force fallback for: // 1. Transaction insert because nereids support `insert into select` while legacy does not // 2. Nereids support insert into external table while legacy does not boolean isInsertCommand = parsedStmt != null && parsedStmt instanceof LogicalPlanAdapter && ((LogicalPlanAdapter) parsedStmt).getLogicalPlan() instanceof InsertIntoTableCommand; - /*boolean isGroupCommit = (Config.wait_internal_group_commit_finish - || context.sessionVariable.isEnableInsertGroupCommit()) && isInsertCommand;*/ - boolean isExternalTableInsert = false; - if (isInsertCommand) { - isExternalTableInsert = ((InsertIntoTableCommand) ((LogicalPlanAdapter) parsedStmt) - .getLogicalPlan()).isExternalTableSink(); - } - boolean forceFallback = isInsertCommand && !isExternalTableInsert && !context.isTxnModel(); - if (e instanceof NereidsException && !context.getSessionVariable().enableFallbackToOriginalPlanner - && !forceFallback) { + boolean isGroupCommit = (Config.wait_internal_group_commit_finish + || context.sessionVariable.isEnableInsertGroupCommit()) && isInsertCommand; + if (e instanceof NereidsException + && !context.getSessionVariable().enableFallbackToOriginalPlanner + && !isGroupCommit) { LOG.warn("Analyze failed. {}", context.getQueryIdentifier(), e); context.getState().setError(e.getMessage()); return; diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java index c342d858fe1fb58..ba0acf1f8dedb0a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java @@ -82,7 +82,7 @@ public void test() throws Exception { createTable("create table db1.tbl1(k1 int, k2 bigint, k3 varchar(10), k4 char(5)) duplicate key(k1) " + "distributed by hash(k2) buckets 1 properties('replication_num' = '1');"); - dorisAssert = new DorisAssert(); + dorisAssert = new DorisAssert(ctx); dorisAssert.useDatabase("db1"); Database db = Env.getCurrentInternalCatalog().getDbNullable("db1"); @@ -115,7 +115,7 @@ public void test() throws Exception { queryStr = "select db1.id_masking(k1) from db1.tbl1"; Assert.assertTrue(containsIgnoreCase(dorisAssert.query(queryStr).explainQuery(), - "concat(left(CAST(CAST(k1 AS BIGINT) AS VARCHAR(65533)), 3), '****', right(CAST(CAST(k1 AS BIGINT) AS VARCHAR(65533)), 4))")); + "concat(left(CAST(`k1` AS VARCHAR(65533)), 3), '****', right(CAST(`k1` AS VARCHAR(65533)), 4))")); // create alias function with cast // cast any type to decimal with specific precision and scale @@ -219,7 +219,7 @@ public void testCreateGlobalFunction() throws Exception { createTable("create table db2.tbl1(k1 int, k2 bigint, k3 varchar(10), k4 char(5)) duplicate key(k1) " + "distributed by hash(k2) buckets 1 properties('replication_num' = '1');"); - dorisAssert = new DorisAssert(); + dorisAssert = new DorisAssert(ctx); dorisAssert.useDatabase("db2"); Database db = Env.getCurrentInternalCatalog().getDbNullable("db2"); @@ -241,7 +241,7 @@ public void testCreateGlobalFunction() throws Exception { queryStr = "select id_masking(k1) from db2.tbl1"; Assert.assertTrue(containsIgnoreCase(dorisAssert.query(queryStr).explainQuery(), - "concat(left(CAST(CAST(k1 AS BIGINT) AS VARCHAR(65533)), 3), '****', right(CAST(CAST(k1 AS BIGINT) AS VARCHAR(65533)), 4))")); + "concat(left(CAST(`k1` AS VARCHAR(65533)), 3), '****', right(CAST(`k1` AS VARCHAR(65533)), 4))")); // 4. create alias function with cast // cast any type to decimal with specific precision and scale diff --git a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy index 93952dd934d99e1..21116ea8bd025c9 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog.groovy @@ -415,93 +415,91 @@ suite("test_mysql_jdbc_catalog", "p0,external,mysql,external_docker,external_doc } sql """ set enable_ext_func_pred_pushdown = "true"; """ // test date_add - sql """ set disable_nereids_rules='NORMALIZE_REWRITE_RULES'; """ order_qt_date_add_year """ select * from test_zd where date_add(d_z,interval 1 year) = '2023-01-01' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 year) = '2023-01-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 year) = '2023-01-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_month """ select * from test_zd where date_add(d_z,interval 1 month) = '2022-02-01' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 month) = '2022-02-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 month) = '2022-02-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_week """ select * from test_zd where date_add(d_z,interval 1 week) = '2022-01-08' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 week) = '2022-01-08' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 week) = '2022-01-08')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_day """ select * from test_zd where date_add(d_z,interval 1 day) = '2022-01-02' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 day) = '2022-01-02' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 day) = '2022-01-02')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_hour """ select * from test_zd where date_add(d_z,interval 1 hour) = '2022-01-01 01:00:00' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 hour) = '2022-01-01 01:00:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 hour) = '2022-01-01 01:00:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_min """ select * from test_zd where date_add(d_z,interval 1 minute) = '2022-01-01 00:01:00' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 minute) = '2022-01-01 00:01:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 minute) = '2022-01-01 00:01:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_sec """ select * from test_zd where date_add(d_z,interval 1 second) = '2022-01-01 00:00:01' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 second) = '2022-01-01 00:00:01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 second) = '2022-01-01 00:00:01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } // date_sub order_qt_date_sub_year """ select * from test_zd where date_sub(d_z,interval 1 year) = '2021-01-01' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 year) = '2021-01-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 year) = '2021-01-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_month """ select * from test_zd where date_sub(d_z,interval 1 month) = '2021-12-01' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 month) = '2021-12-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 month) = '2021-12-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_week """ select * from test_zd where date_sub(d_z,interval 1 week) = '2021-12-25' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 week) = '2021-12-25' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 week) = '2021-12-25')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_day """ select * from test_zd where date_sub(d_z,interval 1 day) = '2021-12-31' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 day) = '2021-12-31' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 day) = '2021-12-31')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_hour """ select * from test_zd where date_sub(d_z,interval 1 hour) = '2021-12-31 23:00:00' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 hour) = '2021-12-31 23:00:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 hour) = '2021-12-31 23:00:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_min """ select * from test_zd where date_sub(d_z,interval 1 minute) = '2021-12-31 23:59:00' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 minute) = '2021-12-31 23:59:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 minute) = '2021-12-31 23:59:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_sec """ select * from test_zd where date_sub(d_z,interval 1 second) = '2021-12-31 23:59:59' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 second) = '2021-12-31 23:59:59' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 second) = '2021-12-31 23:59:59')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } - sql """ set disable_nereids_rules=''; """ sql """ drop catalog if exists mysql_fun_push_catalog; """ diff --git a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_driver5_catalog.groovy b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_driver5_catalog.groovy index ef702f4902d8cdc..46cabaadced2bcb 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_driver5_catalog.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_driver5_catalog.groovy @@ -422,93 +422,91 @@ suite("test_mysql_jdbc_driver5_catalog", "p0,external,mysql,external_docker,exte } sql """ set enable_ext_func_pred_pushdown = "true"; """ // test date_add - sql """ set disable_nereids_rules='NORMALIZE_REWRITE_RULES'; """ order_qt_date_add_year """ select * from test_zd where date_add(d_z,interval 1 year) = '2023-01-01' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 year) = '2023-01-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 year) = '2023-01-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_month """ select * from test_zd where date_add(d_z,interval 1 month) = '2022-02-01' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 month) = '2022-02-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 month) = '2022-02-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_week """ select * from test_zd where date_add(d_z,interval 1 week) = '2022-01-08' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 week) = '2022-01-08' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 week) = '2022-01-08')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_day """ select * from test_zd where date_add(d_z,interval 1 day) = '2022-01-02' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 day) = '2022-01-02' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 day) = '2022-01-02')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_hour """ select * from test_zd where date_add(d_z,interval 1 hour) = '2022-01-01 01:00:00' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 hour) = '2022-01-01 01:00:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 hour) = '2022-01-01 01:00:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_min """ select * from test_zd where date_add(d_z,interval 1 minute) = '2022-01-01 00:01:00' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 minute) = '2022-01-01 00:01:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 minute) = '2022-01-01 00:01:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_add_sec """ select * from test_zd where date_add(d_z,interval 1 second) = '2022-01-01 00:00:01' order by 1; """ explain { sql("select * from test_zd where date_add(d_z,interval 1 second) = '2022-01-01 00:00:01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_add(`d_z`, INTERVAL 1 second) = '2022-01-01 00:00:01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } // date_sub order_qt_date_sub_year """ select * from test_zd where date_sub(d_z,interval 1 year) = '2021-01-01' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 year) = '2021-01-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 year) = '2021-01-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_month """ select * from test_zd where date_sub(d_z,interval 1 month) = '2021-12-01' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 month) = '2021-12-01' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 month) = '2021-12-01')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_week """ select * from test_zd where date_sub(d_z,interval 1 week) = '2021-12-25' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 week) = '2021-12-25' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 week) = '2021-12-25')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_day """ select * from test_zd where date_sub(d_z,interval 1 day) = '2021-12-31' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 day) = '2021-12-31' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 day) = '2021-12-31')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_hour """ select * from test_zd where date_sub(d_z,interval 1 hour) = '2021-12-31 23:00:00' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 hour) = '2021-12-31 23:00:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 hour) = '2021-12-31 23:00:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_min """ select * from test_zd where date_sub(d_z,interval 1 minute) = '2021-12-31 23:59:00' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 minute) = '2021-12-31 23:59:00' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 minute) = '2021-12-31 23:59:00')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } order_qt_date_sub_sec """ select * from test_zd where date_sub(d_z,interval 1 second) = '2021-12-31 23:59:59' order by 1; """ explain { sql("select * from test_zd where date_sub(d_z,interval 1 second) = '2021-12-31 23:59:59' order by 1;") - contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (date_sub(`d_z`, INTERVAL 1 second) = '2021-12-31 23:59:59')" + contains " QUERY: SELECT `id`, `d_z` FROM `doris_test`.`test_zd` WHERE (`d_z` = '2022-01-01')" } - sql """ set disable_nereids_rules=''; """ } finally { res_dbs_log = sql "show databases;" diff --git a/regression-test/suites/query_p0/sql_functions/window_functions/test_ntile_function.groovy b/regression-test/suites/query_p0/sql_functions/window_functions/test_ntile_function.groovy index c96c3c0e16880ab..97824918ee0fca1 100644 --- a/regression-test/suites/query_p0/sql_functions/window_functions/test_ntile_function.groovy +++ b/regression-test/suites/query_p0/sql_functions/window_functions/test_ntile_function.groovy @@ -78,7 +78,7 @@ suite("test_ntile_function") { test { sql "select k1, k2, k3, ntile(k1) over (partition by k1 order by k2) as ntile from ${tableName} order by k1, k2, k3 desc;" - exception "positive" + exception "" } }