Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix](group commit) Fix table not found fault when disable group commit #39731

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,20 @@ private Object executeWithoutPassword(HttpServletRequest request,
return new RestBaseResult(e.getMessage());
}
} else {
Optional<?> database = Env.getCurrentEnv().getCurrentCatalog().getDb(dbName);
if (!database.isPresent()) {
return new RestBaseResult("Database not founded.");
long tableId = -1;
if (groupCommit) {
Optional<?> database = Env.getCurrentEnv().getCurrentCatalog().getDb(dbName);
if (!database.isPresent()) {
return new RestBaseResult("Database not found.");
}

Optional<?> olapTable = ((Database) database.get()).getTable(tableName);
if (!olapTable.isPresent()) {
return new RestBaseResult("OlapTable not found.");
}

tableId = ((OlapTable) olapTable.get()).getId();
}

Optional<?> olapTable = ((Database) database.get()).getTable(tableName);
if (!olapTable.isPresent()) {
return new RestBaseResult("OlapTable not founded.");
}

long tableId = ((OlapTable) olapTable.get()).getId();
redirectAddr = selectRedirectBackend(request, groupCommit, tableId);
}

Expand Down Expand Up @@ -384,6 +387,9 @@ private TNetworkAddress selectRedirectBackend(HttpServletRequest request, boolea
}
return selectCloudRedirectBackend(cloudClusterName, request, groupCommit);
} else {
if (groupCommit && tableId == -1) {
throw new LoadException("Group commit table id wrong.");
}
return selectLocalRedirectBackend(groupCommit, request, tableId);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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_group_commit_stream_load_with_nonexist_db_and_table") {
def tableName = "test_group_commit_stream_load_with_nonexist_db_and_table"
sql "create database if not exists ${tableName}"

try {
def command = "curl --location-trusted -u ${context.config.feHttpUser}:${context.config.feHttpPassword}" +
" -H group_commit:sync_mode" +
" -H column_separator:," +
" -T ${context.config.dataPath}/load_p0/stream_load/test_stream_load1.csv" +
" http://${context.config.feHttpAddress}/api/${tableName}/${tableName}/_stream_load"
log.info("stream load command: ${command}")

def process = command.execute()
code = process.waitFor()
out = process.text
log.info("stream lad result: ${out}".toString())
assertTrue(out.toString().contains("table not found"))
} catch (Exception e) {
logger.info("failed: " + e.getMessage())
assertTrue(false)
} finally {

}
}
Loading