From 6de5d15420634d50c6f84c3a06ab32c56cc9fec2 Mon Sep 17 00:00:00 2001 From: hui lai Date: Tue, 22 Jul 2025 21:01:03 +0800 Subject: [PATCH] [chore](load) optimize show create load error message (#53694) ### What problem does this PR solve? If show create load with not exist label, the error message is `Database does not exist`, it make users confused and not correct, and it should be `Label does not exist` --- .../apache/doris/load/loadv2/LoadManager.java | 5 ++- .../broker_load/test_show_create_load.groovy | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 regression-test/suites/load_p0/broker_load/test_show_create_load.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java index f661513cd66558..89f7df1fcf8e56 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java @@ -553,7 +553,10 @@ public List> getCreateLoadStmt(long dbId, String label) throw throw new DdlException("Label does not exist: " + label); } } else { - throw new DdlException("Database does not exist"); + // If dbId is not found in dbIdToLabelToLoadJobs, + // it means the database has no label records, + // so throw a "Label does not exist" error. + throw new DdlException("Label does not exist: " + label); } return result; } finally { diff --git a/regression-test/suites/load_p0/broker_load/test_show_create_load.groovy b/regression-test/suites/load_p0/broker_load/test_show_create_load.groovy new file mode 100644 index 00000000000000..8881e35ef8e75c --- /dev/null +++ b/regression-test/suites/load_p0/broker_load/test_show_create_load.groovy @@ -0,0 +1,34 @@ +// 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_show_create_load", "load_p0") { + // test unknown db + try { + sql "show create load for unknown_db.test_label" + } catch (Exception e) { + logger.info("result: ${e.message}") + assertTrue(e.message.contains(" Unknown database 'unknown_db'")) + } + + // test unknown label + try { + sql "show create load for ${context.dbName}.unknown_label" + } catch (Exception e) { + logger.info("result: ${e.message}") + assertTrue(e.message.contains("Label does not exist: unknown_label")) + } +} \ No newline at end of file