Search in sources :

Example 1 with FAILING_FIELD_TYPE_PROVIDER

use of com.hazelcast.sql.impl.plan.node.PlanNodeFieldTypeProvider.FAILING_FIELD_TYPE_PROVIDER in project hazelcast by hazelcast.

the class SlidingWindow method windowPolicyProvider.

public final FunctionEx<ExpressionEvalContext, SlidingWindowPolicy> windowPolicyProvider() {
    QueryParameterMetadata parameterMetadata = ((HazelcastRelOptCluster) getCluster()).getParameterMetadata();
    RexToExpressionVisitor visitor = new RexToExpressionVisitor(FAILING_FIELD_TYPE_PROVIDER, parameterMetadata);
    if (operator() == HazelcastSqlOperatorTable.TUMBLE) {
        Expression<?> windowSizeExpression = operand(2).accept(visitor);
        return context -> tumblingWinPolicy(WindowUtils.extractMillis(windowSizeExpression, context));
    } else if (operator() == HazelcastSqlOperatorTable.HOP) {
        Expression<?> windowSizeExpression = operand(2).accept(visitor);
        Expression<?> slideSizeExpression = operand(3).accept(visitor);
        return context -> slidingWinPolicy(WindowUtils.extractMillis(windowSizeExpression, context), WindowUtils.extractMillis(slideSizeExpression, context));
    } else {
        throw new IllegalArgumentException();
    }
}
Also used : SlidingWindowPolicy.slidingWinPolicy(com.hazelcast.jet.core.SlidingWindowPolicy.slidingWinPolicy) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) FAILING_FIELD_TYPE_PROVIDER(com.hazelcast.sql.impl.plan.node.PlanNodeFieldTypeProvider.FAILING_FIELD_TYPE_PROVIDER) SlidingWindowPolicy(com.hazelcast.jet.core.SlidingWindowPolicy) HazelcastRelOptCluster(org.apache.calcite.plan.HazelcastRelOptCluster) RelColumnMapping(org.apache.calcite.rel.metadata.RelColumnMapping) RexNode(org.apache.calcite.rex.RexNode) SqlOperator(org.apache.calcite.sql.SqlOperator) RexToExpressionVisitor(com.hazelcast.jet.sql.impl.opt.physical.visitor.RexToExpressionVisitor) Expression(com.hazelcast.sql.impl.expression.Expression) Preconditions.checkTrue(com.hazelcast.internal.util.Preconditions.checkTrue) RelTraitSet(org.apache.calcite.plan.RelTraitSet) RelOptCluster(org.apache.calcite.plan.RelOptCluster) FunctionEx(com.hazelcast.function.FunctionEx) TableFunctionScan(org.apache.calcite.rel.core.TableFunctionScan) RelDataType(org.apache.calcite.rel.type.RelDataType) Set(java.util.Set) RelNode(org.apache.calcite.rel.RelNode) RexInputRef(org.apache.calcite.rex.RexInputRef) List(java.util.List) ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) Type(java.lang.reflect.Type) HazelcastSqlOperatorTable(com.hazelcast.jet.sql.impl.validate.HazelcastSqlOperatorTable) SlidingWindowPolicy.tumblingWinPolicy(com.hazelcast.jet.core.SlidingWindowPolicy.tumblingWinPolicy) WindowUtils(com.hazelcast.jet.sql.impl.aggregate.WindowUtils) RexCall(org.apache.calcite.rex.RexCall) HazelcastRelOptCluster(org.apache.calcite.plan.HazelcastRelOptCluster) RexToExpressionVisitor(com.hazelcast.jet.sql.impl.opt.physical.visitor.RexToExpressionVisitor) Expression(com.hazelcast.sql.impl.expression.Expression) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata)

Aggregations

FunctionEx (com.hazelcast.function.FunctionEx)1 Preconditions.checkTrue (com.hazelcast.internal.util.Preconditions.checkTrue)1 SlidingWindowPolicy (com.hazelcast.jet.core.SlidingWindowPolicy)1 SlidingWindowPolicy.slidingWinPolicy (com.hazelcast.jet.core.SlidingWindowPolicy.slidingWinPolicy)1 SlidingWindowPolicy.tumblingWinPolicy (com.hazelcast.jet.core.SlidingWindowPolicy.tumblingWinPolicy)1 WindowUtils (com.hazelcast.jet.sql.impl.aggregate.WindowUtils)1 RexToExpressionVisitor (com.hazelcast.jet.sql.impl.opt.physical.visitor.RexToExpressionVisitor)1 HazelcastSqlOperatorTable (com.hazelcast.jet.sql.impl.validate.HazelcastSqlOperatorTable)1 QueryParameterMetadata (com.hazelcast.sql.impl.QueryParameterMetadata)1 Expression (com.hazelcast.sql.impl.expression.Expression)1 ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)1 FAILING_FIELD_TYPE_PROVIDER (com.hazelcast.sql.impl.plan.node.PlanNodeFieldTypeProvider.FAILING_FIELD_TYPE_PROVIDER)1 Type (java.lang.reflect.Type)1 List (java.util.List)1 Set (java.util.Set)1 HazelcastRelOptCluster (org.apache.calcite.plan.HazelcastRelOptCluster)1 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 RelNode (org.apache.calcite.rel.RelNode)1 TableFunctionScan (org.apache.calcite.rel.core.TableFunctionScan)1