Fix stream load failure when target table contains HLL and insert failure when it contains subquery (#359)

This commit is contained in:
chenhao
2018-11-29 15:40:04 +08:00
committed by ZHAO Chun
parent aa27d0e056
commit 5694bcbd78
2 changed files with 9 additions and 15 deletions

View File

@ -48,6 +48,11 @@ public class StmtRewriter {
QueryStmt analyzedStmt = (QueryStmt) parsedStmt;
Preconditions.checkNotNull(analyzedStmt.analyzer);
rewriteQueryStatement(analyzedStmt, analyzer);
} else if (parsedStmt instanceof InsertStmt) {
final InsertStmt insertStmt = (InsertStmt)parsedStmt;
final QueryStmt analyzedStmt = (QueryStmt)insertStmt.getQueryStmt();
Preconditions.checkNotNull(analyzedStmt.analyzer);
rewriteQueryStatement(analyzedStmt, analyzer);
} else {
throw new AnalysisException("Unsupported statement containing subqueries: "
+ parsedStmt.toSql());

View File

@ -329,24 +329,13 @@ public class StreamLoadScanNode extends ScanNode {
}
private Expr castToSlot(SlotDescriptor slotDesc, Expr expr) throws UserException {
if (slotDesc.getType().isNull()) {
return expr;
}
PrimitiveType dstType = slotDesc.getType().getPrimitiveType();
PrimitiveType srcType = expr.getType().getPrimitiveType();
if (dstType.isStringType()) {
if (srcType.isStringType()) {
return expr;
} else {
CastExpr castExpr = (CastExpr)expr.castTo(Type.VARCHAR);
return castExpr;
}
} else if (dstType != srcType) {
CastExpr castExpr = (CastExpr)expr.castTo(slotDesc.getType());
return castExpr;
if (dstType != srcType) {
return expr.castTo(slotDesc.getType());
} else {
return expr;
}
return expr;
}
@Override