Search in sources :

Example 41 with Expression

use of io.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitStore_input.

@Override
public Object visitStore_input(SiddhiQLParser.Store_inputContext ctx) {
    String sourceId = (String) visit(ctx.source_id());
    String alias = null;
    if (ctx.alias() != null) {
        alias = (String) visit(ctx.source_id());
    }
    Store store = InputStore.store(alias, sourceId);
    Expression expression = null;
    if (ctx.expression() != null) {
        expression = (Expression) visit(ctx.expression());
    }
    populateQueryContext(store, ctx);
    if (ctx.per() != null) {
        return store.on(expression, (Within) visit(ctx.within_time_range()), (Expression) visit(ctx.per()));
    } else if (expression != null) {
        return store.on(expression);
    } else {
        return store;
    }
}
Also used : Expression(io.siddhi.query.api.expression.Expression) Store(io.siddhi.query.api.execution.query.input.store.Store) InputStore(io.siddhi.query.api.execution.query.input.store.InputStore)

Example 42 with Expression

use of io.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitStore_query_output.

/**
 * {@inheritDoc}
 * <p>
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 */
@Override
public OutputStream visitStore_query_output(@NotNull SiddhiQLParser.Store_query_outputContext ctx) {
    if (ctx.DELETE() != null) {
        Source source = (Source) visit(ctx.target());
        if (source.isInnerStream || source.isFaultStream) {
            throw newSiddhiParserException(ctx, "DELETE can be only used with Tables!");
        }
        Expression expression = null;
        if (ctx.expression() != null) {
            expression = (Expression) visit(ctx.expression());
        }
        OutputStream outputStream = new DeleteStream(source.streamId, expression);
        populateQueryContext(outputStream, ctx);
        return outputStream;
    } else if (ctx.UPDATE() != null) {
        Source source = (Source) visit(ctx.target());
        if (source.isInnerStream || source.isFaultStream) {
            throw newSiddhiParserException(ctx, "DELETE can be only used with Tables!");
        }
        if (ctx.set_clause() != null) {
            OutputStream outputStream = new UpdateStream(source.streamId, (UpdateSet) visit(ctx.set_clause()), (Expression) visit(ctx.expression()));
            populateQueryContext(outputStream, ctx);
            return outputStream;
        } else {
            OutputStream outputStream = new UpdateStream(source.streamId, (Expression) visit(ctx.expression()));
            populateQueryContext(outputStream, ctx);
            return outputStream;
        }
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : Expression(io.siddhi.query.api.expression.Expression) DeleteStream(io.siddhi.query.api.execution.query.output.stream.DeleteStream) OutputStream(io.siddhi.query.api.execution.query.output.stream.OutputStream) UpdateStream(io.siddhi.query.api.execution.query.output.stream.UpdateStream) UpdateSet(io.siddhi.query.api.execution.query.output.stream.UpdateSet)

Example 43 with Expression

use of io.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitFunction_operation.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitFunction_operation(@NotNull SiddhiQLParser.Function_operationContext ctx) {
    Expression expression;
    if (ctx.function_namespace() != null) {
        if (ctx.attribute_list() != null) {
            expression = Expression.function((String) visit(ctx.function_namespace()), (String) visit(ctx.function_id()), (Expression[]) visit(ctx.attribute_list()));
        } else {
            expression = Expression.function((String) visit(ctx.function_namespace()), (String) visit(ctx.function_id()), null);
        }
    } else {
        if (ctx.attribute_list() != null) {
            expression = Expression.function((String) visit(ctx.function_id()), (Expression[]) visit(ctx.attribute_list()));
        } else {
            expression = Expression.function((String) visit(ctx.function_id()), null);
        }
    }
    populateQueryContext(expression, ctx);
    return expression;
}
Also used : Expression(io.siddhi.query.api.expression.Expression)

Example 44 with Expression

use of io.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitIn_math_operation.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitIn_math_operation(@NotNull SiddhiQLParser.In_math_operationContext ctx) {
    Expression expression = Expression.in((Expression) visit(ctx.math_operation()), (String) visit(ctx.name()));
    populateQueryContext(expression, ctx);
    return expression;
}
Also used : Expression(io.siddhi.query.api.expression.Expression)

Aggregations

Expression (io.siddhi.query.api.expression.Expression)44 Attribute (io.siddhi.query.api.definition.Attribute)18 Variable (io.siddhi.query.api.expression.Variable)14 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)13 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)13 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)11 ArrayList (java.util.ArrayList)11 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)10 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)10 ConstantExpressionExecutor (io.siddhi.core.executor.ConstantExpressionExecutor)9 OutputAttribute (io.siddhi.query.api.execution.query.selection.OutputAttribute)9 SiddhiQueryContext (io.siddhi.core.config.SiddhiQueryContext)7 AbstractDefinition (io.siddhi.query.api.definition.AbstractDefinition)7 AttributeFunction (io.siddhi.query.api.expression.AttributeFunction)7 Compare (io.siddhi.query.api.expression.condition.Compare)6 Table (io.siddhi.core.table.Table)5 ReturnAttribute (io.siddhi.annotation.ReturnAttribute)4 SiddhiAppRuntimeException (io.siddhi.core.exception.SiddhiAppRuntimeException)4 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)4 HashMap (java.util.HashMap)4