Skip to content

Commit

Permalink
Addressed comments by Anant
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrapCodes committed Nov 20, 2024
1 parent 95d4186 commit 40b6f47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ private class RowExpressionStatsVisitor
private final PlanNodeStatsEstimate input;
private final ConnectorSession session;
private final FunctionResolution resolution = new FunctionResolution(metadata.getFunctionAndTypeManager().getFunctionAndTypeResolver());
private final boolean isStatsPropagationEnabled;
private final boolean isScalarFunctionStatsPropagationEnabled;

public RowExpressionStatsVisitor(PlanNodeStatsEstimate input, ConnectorSession session)
{
this.input = requireNonNull(input, "input is null");
this.session = requireNonNull(session, "session is null");
// casting session to FullConnectorSession is not ideal.
this.isStatsPropagationEnabled =
this.isScalarFunctionStatsPropagationEnabled =
SystemSessionProperties.shouldEnableScalarFunctionStatsPropagation(((FullConnectorSession) session).getSession());
}

Expand Down Expand Up @@ -216,7 +216,7 @@ public VariableStatsEstimate visitSpecialForm(SpecialFormExpression specialForm,

private VariableStatsEstimate computeStatsViaAnnotations(CallExpression call, Void context, FunctionMetadata functionMetadata)
{
if (isStatsPropagationEnabled) {
if (isScalarFunctionStatsPropagationEnabled) {
if (functionMetadata.hasStatsHeader() && call.getFunctionHandle() instanceof BuiltInFunctionHandle) {
Signature signature = ((BuiltInFunctionHandle) call.getFunctionHandle()).getSignature().canonicalization();
Optional<ScalarStatsHeader> statsHeader = functionMetadata.getScalarStatsHeader(signature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ public static long customPrng(
return (long) ((Math.random() * (max - min)) + min);
}

// Following functions are annotated with incorrect Stats annotation to cover -ve or boundary conditions.
@ScalarFunction(value = "custom_is_null2", calledOnNullInput = true)
@SqlType(StandardTypes.BOOLEAN)
@ScalarFunctionConstantStats(distinctValuesCount = -3.19, nullFraction = 0.0)
Expand Down

0 comments on commit 40b6f47

Please sign in to comment.