[fix](ES catalog) throw exception when ES meta track failed (#30409)

This commit is contained in:
qiye
2024-01-26 21:11:16 +08:00
committed by yiguolei
parent 04237f60e0
commit 5d2b011a8d
3 changed files with 16 additions and 5 deletions

View File

@ -18,6 +18,7 @@
package org.apache.doris.catalog;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.UserException;
import org.apache.doris.common.io.Text;
import org.apache.doris.external.elasticsearch.EsMetaStateTracker;
import org.apache.doris.external.elasticsearch.EsRestClient;
@ -140,15 +141,15 @@ public class EsTable extends Table {
super(id, name, tableType, schema);
}
public Map<String, String> fieldsContext() {
public Map<String, String> fieldsContext() throws UserException {
return esMetaStateTracker.searchContext().fetchFieldsContext();
}
public Map<String, String> docValueContext() {
public Map<String, String> docValueContext() throws UserException {
return esMetaStateTracker.searchContext().docValueFieldsContext();
}
public List<String> needCompatDateFields() {
public List<String> needCompatDateFields() throws UserException {
return esMetaStateTracker.searchContext().needCompatDateFields();
}

View File

@ -18,6 +18,10 @@
package org.apache.doris.external.elasticsearch;
import org.apache.doris.catalog.EsTable;
import org.apache.doris.common.UserException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.LinkedList;
import java.util.List;
@ -32,6 +36,8 @@ import java.util.List;
*/
public class EsMetaStateTracker {
private static final Logger LOG = LogManager.getLogger(EsMetaStateTracker.class);
private List<SearchPhase> builtinSearchPhase = new LinkedList<>();
private SearchContext searchContext;
@ -41,7 +47,11 @@ public class EsMetaStateTracker {
searchContext = new SearchContext(esTable);
}
public SearchContext searchContext() {
public SearchContext searchContext() throws UserException {
if (searchContext == null) {
LOG.warn("ES meta state track failed, please check ES health status.");
throw new UserException("ES meta state track failed, please check ES health status.");
}
return searchContext;
}

View File

@ -314,7 +314,7 @@ public class EsScanNode extends ExternalScanNode {
return output.toString();
}
private void buildQuery() {
private void buildQuery() throws UserException {
if (conjuncts.isEmpty()) {
queryBuilder = QueryBuilders.matchAllQuery();
} else {