[Enhance](multi-catalog) parse hive view ddl first to avoid NPE. (#28067)

This commit is contained in:
Xiangyu Wang
2023-12-08 13:54:50 +08:00
committed by GitHub
parent 61d556c718
commit 16230b5ebd

View File

@ -39,6 +39,7 @@ import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.IdGenerator;
import org.apache.doris.common.Pair;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.planner.AggregationNode;
import org.apache.doris.planner.AnalyticEvalNode;
@ -852,6 +853,13 @@ public class Analyzer {
View hmsView = new View(table.getId(), table.getName(), table.getFullSchema());
hmsView.setInlineViewDefWithSqlMode(((HMSExternalTable) table).getViewText(),
ConnectContext.get().getSessionVariable().getSqlMode());
// for user experience consideration, parse hive view ddl first to avoid NPE
// if legacy parser can not parse hive view ddl properly
try {
hmsView.init();
} catch (UserException e) {
throw new AnalysisException(e.getMessage(), e);
}
InlineViewRef inlineViewRef = new InlineViewRef(hmsView, tableRef);
if (StringUtils.isNotEmpty(tableName.getCtl())) {
inlineViewRef.setExternalCtl(tableName.getCtl());