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

[#FLINK-33596] Fold expression before transfer function to RexNode #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -211,7 +211,7 @@ public static RexNode convert(

public RexNode convert(ExprNodeDesc expr) throws SemanticException {
if (expr instanceof ExprNodeGenericFuncDesc) {
return convertGenericFunc((ExprNodeGenericFuncDesc) expr);
return convertGenericFunc((ExprNodeGenericFuncDesc) expr, cluster);
} else if (expr instanceof ExprNodeConstantDesc) {
return convertConstant((ExprNodeConstantDesc) expr, cluster);
} else if (expr instanceof ExprNodeColumnDesc) {
Expand Down Expand Up @@ -518,13 +518,18 @@ public static RexNode convertConstant(ExprNodeConstantDesc literal, RelOptCluste
return calciteLiteral;
}

private RexNode convertGenericFunc(ExprNodeGenericFuncDesc func) throws SemanticException {
private RexNode convertGenericFunc(ExprNodeGenericFuncDesc func, RelOptCluster cluster) throws SemanticException {
ExprNodeDesc tmpExprNode;
RexNode tmpRN;

List<RexNode> childRexNodeLst = new ArrayList<>();
List<RelDataType> argTypes = new ArrayList<>();

ExprNodeDesc afterFoldDesc = ConstantPropagateProcFactory.foldExpr(func);
if (afterFoldDesc instanceof ExprNodeConstantDesc) {
return convertConstant((ExprNodeConstantDesc) afterFoldDesc, cluster);
}

// TODO: 1) Expand to other functions as needed 2) What about types other than primitive.
TypeInfo tgtDT = null;
GenericUDF tgtUdf = func.getGenericUDF();
Expand Down
4 changes: 4 additions & 0 deletions flink-connector-hive/src/test/resources/query-test/group_by.q
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ select dep,count(1) from employee where salary<5000 and age>=38 and dep='Sales'
select x,null as n from foo group by x,'a',null;

[+I[1, null], +I[2, null], +I[3, null], +I[4, null], +I[5, null]]

select dep, sum(salary) from employee group by dep, UNIX_TIMESTAMP();

[+I[Management, 12900], +I[Production, 18600], +I[Sales, 8400], +I[Service, 4100]]