[fix](es catalog) only es_query function can push down to ES (#29320)

Issue Number: close #29318 
1. Only push down `es_query` function to ES
2. Add null check where ES query result not have `_source` or `fields` fields.
This commit is contained in:
qiye
2023-12-30 09:33:26 +08:00
committed by GitHub
parent 56058623f6
commit 2c4e52e44e
11 changed files with 157 additions and 62 deletions

View File

@ -209,11 +209,8 @@ public final class QueryBuilders {
// }');
// The first child k1 compatible with expr syntax
FunctionCallExpr functionCallExpr = (FunctionCallExpr) expr;
if ("esquery".equals(functionCallExpr.getFnName().getFunction())) {
String stringValue = functionCallExpr.getChild(1).getStringValue();
return new QueryBuilders.EsQueryBuilder(stringValue);
}
return null;
String stringValue = functionCallExpr.getChild(1).getStringValue();
return new QueryBuilders.EsQueryBuilder(stringValue);
}
/**
@ -276,7 +273,14 @@ public final class QueryBuilders {
return parseInPredicate(expr, column, needDateCompat);
}
if (expr instanceof FunctionCallExpr) {
return parseFunctionCallExpr(expr);
FunctionCallExpr functionCallExpr = (FunctionCallExpr) expr;
// current only esquery functionCallExpr can be push down to ES
if (!"esquery".equals(functionCallExpr.getFnName().getFunction())) {
notPushDownList.add(expr);
return null;
} else {
return parseFunctionCallExpr(expr);
}
}
return null;
}