[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.
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user