Search in sources :

Example 1 with StatementRewriteForMagicPseudoTimestamp

use of io.confluent.ksql.engine.rewrite.StatementRewriteForMagicPseudoTimestamp in project ksql by confluentinc.

the class FilterTypeValidator method getExpressionReturnType.

private SqlType getExpressionReturnType(final Expression exp) {
    final ExpressionTypeManager expressionTypeManager = new ExpressionTypeManager(schema, functionRegistry);
    // Rewrite the expression with magic timestamps, so type checking can pass
    final Expression magicTimestampRewrite = new StatementRewriteForMagicPseudoTimestamp().rewrite(exp);
    try {
        return expressionTypeManager.getExpressionSqlType(magicTimestampRewrite);
    } catch (KsqlException e) {
        throw new KsqlStatementException("Error in " + filterType.name() + " expression: " + e.getMessage(), exp.toString());
    }
}
Also used : ExpressionTypeManager(io.confluent.ksql.execution.util.ExpressionTypeManager) Expression(io.confluent.ksql.execution.expression.tree.Expression) StatementRewriteForMagicPseudoTimestamp(io.confluent.ksql.engine.rewrite.StatementRewriteForMagicPseudoTimestamp) KsqlStatementException(io.confluent.ksql.util.KsqlStatementException) KsqlException(io.confluent.ksql.util.KsqlException)

Example 2 with StatementRewriteForMagicPseudoTimestamp

use of io.confluent.ksql.engine.rewrite.StatementRewriteForMagicPseudoTimestamp in project ksql by confluentinc.

the class PullQueryRewriter method rewrite.

public static Expression rewrite(final Expression expression) {
    final Expression pseudoTimestamp = new StatementRewriteForMagicPseudoTimestamp().rewrite(expression);
    final Expression betweenPredicatesRemoved = rewriteBetweenPredicates(pseudoTimestamp);
    final Expression inPredicatesRemoved = rewriteInPredicates(betweenPredicatesRemoved);
    return LogicRewriter.rewriteDNF(inPredicatesRemoved);
}
Also used : Expression(io.confluent.ksql.execution.expression.tree.Expression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) LogicalBinaryExpression(io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression) StatementRewriteForMagicPseudoTimestamp(io.confluent.ksql.engine.rewrite.StatementRewriteForMagicPseudoTimestamp)

Aggregations

StatementRewriteForMagicPseudoTimestamp (io.confluent.ksql.engine.rewrite.StatementRewriteForMagicPseudoTimestamp)2 Expression (io.confluent.ksql.execution.expression.tree.Expression)2 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)1 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)1 ExpressionTypeManager (io.confluent.ksql.execution.util.ExpressionTypeManager)1 KsqlException (io.confluent.ksql.util.KsqlException)1 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)1