Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Aug 21, 2024
1 parent 5585073 commit aeb3fc5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ public Expression visitUnboundVariable(UnboundVariable unboundVariable, Cascades
throw new AnalysisException(e.getMessage());
}
}
context.getStatementContext().hasUnsupportedSqlCacheExpression = true;
if (context != null) {
context.getStatementContext().hasUnsupportedSqlCacheExpression = true;
}
return new Variable(unboundVariable.getName(), unboundVariable.getType(), literal);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public Expression visitUnboundFunction(UnboundFunction unboundFunction, Expressi
FunctionBuilder builder = functionRegistry.findFunctionBuilder(
unboundFunction.getDbName(), functionName, arguments);
if (builder instanceof AliasUdfBuilder) {
context.cascadesContext.getStatementContext().hasUnsupportedSqlCacheExpression = true;
if (context != null) {
context.cascadesContext.getStatementContext().hasUnsupportedSqlCacheExpression = true;
}
// we do type coercion in build function in alias function, so it's ok to return directly.
return builder.build(functionName, arguments);
} else {
Expand All @@ -133,7 +135,7 @@ public Expression visitUnboundFunction(UnboundFunction unboundFunction, Expressi
// so wrap COUNT with Nvl to ensure it's result is 0 instead of null to get the correct result
boundFunction = new Nvl(boundFunction, new BigIntLiteral(0));
}
if (boundFunction instanceof Nondeterministic) {
if (context != null && boundFunction instanceof Nondeterministic) {
context.cascadesContext.getStatementContext().hasUnsupportedSqlCacheExpression = true;
}
return boundFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private CacheMode innerCheckCacheModeForNereids(long now) {
}
return CacheMode.NoNeed;
}
if (context.getStatementContext().hasUnsupportedSqlCacheExpression) {
if (context != null && context.getStatementContext().hasUnsupportedSqlCacheExpression) {
return CacheMode.None;
}
if (!(parsedStmt instanceof LogicalPlanAdapter) || scanNodes.size() == 0) {
Expand Down

0 comments on commit aeb3fc5

Please sign in to comment.