From 03316e235530d85063255513d7c8d23583997222 Mon Sep 17 00:00:00 2001 From: "jiafeng.zhang" Date: Sat, 14 Oct 2023 06:48:24 -0500 Subject: [PATCH] [fix](fe rest api)api gets execution plan, table name case problem (#25112) The user has configured the parameter lower_case_table_names, which ignores the case of the table name. When executed on the SQL client, the table name can be queried in both case. But when using Connector to read doris data, the table names must be in the same case, otherwise an error will be reported. --- .../httpv2/rest/TableQueryPlanAction.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java index f337935570..0bd83617f1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java @@ -35,6 +35,7 @@ import org.apache.doris.planner.PlanFragment; import org.apache.doris.planner.Planner; import org.apache.doris.planner.ScanNode; import org.apache.doris.qe.ConnectContext; +import org.apache.doris.qe.GlobalVariable; import org.apache.doris.qe.OriginStatement; import org.apache.doris.qe.StmtExecutor; import org.apache.doris.thrift.TDataSink; @@ -197,10 +198,21 @@ public class TableQueryPlanAction extends RestBaseController { // check consistent http requested resource with sql referenced // if consistent in this way, can avoid check privilege TableName tableAndDb = fromTables.get(0).getName(); - if (!(tableAndDb.getDb().equals(requestDb) && tableAndDb.getTbl().equals(requestTable))) { - throw new DorisHttpException(HttpResponseStatus.BAD_REQUEST, - "requested database and table must consistent with sql: request [ " - + requestDb + "." + requestTable + "]" + "and sql [" + tableAndDb.toString() + "]"); + int lower = GlobalVariable.lowerCaseTableNames; + //Determine whether table names are case-sensitive + if (lower == 0) { + if (!(tableAndDb.getDb().equals(requestDb) && tableAndDb.getTbl().equals(requestTable))) { + throw new DorisHttpException(HttpResponseStatus.BAD_REQUEST, + "requested database and table must consistent with sql: request [ " + + requestDb + "." + requestTable + "]" + "and sql [" + tableAndDb.toString() + "]"); + } + } else { + if (!(tableAndDb.getDb().equalsIgnoreCase(requestDb) + && tableAndDb.getTbl().equalsIgnoreCase(requestTable))) { + throw new DorisHttpException(HttpResponseStatus.BAD_REQUEST, + "requested database and table must consistent with sql: request [ " + + requestDb + "." + requestTable + "]" + "and sql [" + tableAndDb.toString() + "]"); + } } // acquired Planner to get PlanNode and fragment templates