[Fix](nereids)Fix nereids fail to parse tablesample rows bug (#26981)

This commit is contained in:
Jibing-Li
2023-11-16 12:23:37 +08:00
committed by GitHub
parent bf6a9383bc
commit 343d58123d
3 changed files with 52 additions and 3 deletions

View File

@ -2890,7 +2890,7 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
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);
}

View File

@ -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);

View File

@ -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 {
}
}
}