Search in sources :

Example 6 with DeleteStream

use of io.siddhi.query.api.execution.query.output.stream.DeleteStream 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 7 with DeleteStream

use of io.siddhi.query.api.execution.query.output.stream.DeleteStream in project siddhi by wso2.

the class Query method deleteBy.

public void deleteBy(String outputTableId, Expression onDeletingExpression) {
    this.outputStream = new DeleteStream(outputTableId, onDeletingExpression);
    updateOutputEventType(outputRate, outputStream);
}
Also used : DeleteStream(io.siddhi.query.api.execution.query.output.stream.DeleteStream)

Aggregations

DeleteStream (io.siddhi.query.api.execution.query.output.stream.DeleteStream)7 UpdateStream (io.siddhi.query.api.execution.query.output.stream.UpdateStream)5 InsertIntoStream (io.siddhi.query.api.execution.query.output.stream.InsertIntoStream)4 UpdateOrInsertStream (io.siddhi.query.api.execution.query.output.stream.UpdateOrInsertStream)4 OutputStream (io.siddhi.query.api.execution.query.output.stream.OutputStream)3 Expression (io.siddhi.query.api.expression.Expression)3 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)2 Table (io.siddhi.core.table.Table)2 Window (io.siddhi.core.window.Window)2 ReturnStream (io.siddhi.query.api.execution.query.output.stream.ReturnStream)2 UpdateSet (io.siddhi.query.api.execution.query.output.stream.UpdateSet)2 AggregationRuntime (io.siddhi.core.aggregation.AggregationRuntime)1 SiddhiOnDemandQueryContext (io.siddhi.core.config.SiddhiOnDemandQueryContext)1 SiddhiQueryContext (io.siddhi.core.config.SiddhiQueryContext)1 StateEventFactory (io.siddhi.core.event.state.StateEventFactory)1 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)1 StreamEventConverter (io.siddhi.core.event.stream.converter.StreamEventConverter)1 ZeroStreamEventConverter (io.siddhi.core.event.stream.converter.ZeroStreamEventConverter)1 OnDemandQueryCreationException (io.siddhi.core.exception.OnDemandQueryCreationException)1 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)1