diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java index 33f11c4687..13a4b7503e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java @@ -2890,7 +2890,7 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor { return new TableSample(percent, true, seek); } SampleByRowsContext sampleByRowsContext = (SampleByRowsContext) sampleContext; - long rows = Long.parseLong(sampleByRowsContext.ROWS().getText()); + long rows = Long.parseLong(sampleByRowsContext.INTEGER_VALUE().getText()); return new TableSample(rows, false, seek); } 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 b52890ede0..f77a3b9fdc 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 @@ -2666,8 +2666,7 @@ public class StmtExecutor { planner = new NereidsPlanner(statementContext); planner.plan(parsedStmt, context.getSessionVariable().toThrift()); } catch (Exception e) { - LOG.warn("Arrow Flight SQL fall back to legacy planner, because: {}", - e.getMessage(), e); + LOG.warn("Fall back to legacy planner, because: {}", e.getMessage(), e); parsedStmt = null; planner = null; context.getState().setNereids(false); diff --git a/regression-test/suites/external_table_p0/hive/test_hive_tablesample_p0.groovy b/regression-test/suites/external_table_p0/hive/test_hive_tablesample_p0.groovy new file mode 100644 index 0000000000..2594b02bf1 --- /dev/null +++ b/regression-test/suites/external_table_p0/hive/test_hive_tablesample_p0.groovy @@ -0,0 +1,50 @@ +// 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("test_hive_tablesample_p0", "all_types,p0,external,hive,external_docker,external_docker_hive") { + + String enabled = context.config.otherConfigs.get("enableHiveTest") + if (enabled != null && enabled.equalsIgnoreCase("true")) { + try { + String hms_port = context.config.otherConfigs.get("hms_port") + String catalog_name = "test_hive_tablesample_p0" + String externalEnvIp = context.config.otherConfigs.get("externalEnvIp") + + sql """drop catalog if exists ${catalog_name}""" + sql """create catalog if not exists ${catalog_name} properties ( + "type"="hms", + 'hive.metastore.uris' = 'thrift://${externalEnvIp}:${hms_port}' + );""" + sql """use `${catalog_name}`.`default`""" + sql """SET enable_nereids_planner=true""" + sql """SET enable_fallback_to_original_planner=false""" + sql """select count(*) from student tablesample(10 rows);""" + sql """select count(*) from student tablesample(10 percent);""" + explain { + sql("select count(*) from student tablesample(10 rows);") + contains "count(*)[#7]" + } + explain { + sql("select count(*) from student tablesample(10 percent);") + contains "count(*)[#7]" + } + sql """drop catalog if exists ${catalog_name}""" + } finally { + } + } +} +