Skip to content

Commit

Permalink
[chore](routine load) make error msg clear if routine load name illeg…
Browse files Browse the repository at this point in the history
…al (#40037) (#40510)

pick (#40037)
  • Loading branch information
sollhui authored Sep 9, 2024
1 parent 314f6ae commit 9c9827b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,14 @@ public void analyze(Analyzer analyzer) throws UserException {
// check dbName and tableName
checkDBTable(analyzer);
// check name
FeNameFormat.checkCommonName(NAME_TYPE, name);
try {
FeNameFormat.checkCommonName(NAME_TYPE, name);
} catch (AnalysisException e) {
// 64 is the length of regular expression matching
// (FeNameFormat.COMMON_NAME_REGEX/UNDERSCORE_COMMON_NAME_REGEX)
throw new AnalysisException(e.getMessage()
+ " Maybe routine load job name is longer than 64 or contains illegal characters");
}
// check load properties include column separator etc.
checkLoadProperties();
// check routine load job properties include desired concurrent number etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

public class FeNameFormat {
private static final String LABEL_REGEX = "^[-_A-Za-z0-9:]{1," + Config.label_regex_length + "}$";
// if modify the matching length of a regular expression,
// please modify error msg when FeNameFormat.checkCommonName throw exception in CreateRoutineLoadStmt
private static final String COMMON_NAME_REGEX = "^[a-zA-Z][a-zA-Z0-9-_]{0,63}$";
private static final String UNDERSCORE_COMMON_NAME_REGEX = "^[_a-zA-Z][a-zA-Z0-9-_]{0,63}$";
private static final String TABLE_NAME_REGEX = "^[a-zA-Z][a-zA-Z0-9-_]*$";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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_routine_load_name","p0") {
String kafka_port = context.config.otherConfigs.get("kafka_port")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
try {
sql """
CREATE ROUTINE LOAD test_routine_load_name_too_much_filler_filler_filler_filler_filler_filler_filler
COLUMNS TERMINATED BY "|"
PROPERTIES
(
"max_batch_interval" = "5",
"max_batch_rows" = "300000",
"max_batch_size" = "209715200"
)
FROM KAFKA
(
"kafka_broker_list" = "${externalEnvIp}:${kafka_port}",
"kafka_topic" = "multi_table_load_invalid_table",
"property.kafka_default_offsets" = "OFFSET_BEGINNING"
);
"""
} catch (Exception e) {
log.info("exception: ${e.toString()}".toString())
assertEquals(e.toString().contains("Incorrect ROUTINE LOAD NAME name"), true)
assertEquals(e.toString().contains("Maybe routine load job name is longer than 64 or contains illegal characters"), true)
}
}

0 comments on commit 9c9827b

Please sign in to comment.