Search in sources :

Example 1 with PatternSearchMode

use of io.trino.sql.tree.PatternSearchMode in project trino by trinodb.

the class AstBuilder method visitPatternRecognition.

@Override
public Node visitPatternRecognition(SqlBaseParser.PatternRecognitionContext context) {
    Relation child = (Relation) visit(context.aliasedRelation());
    if (context.MATCH_RECOGNIZE() == null) {
        return child;
    }
    Optional<OrderBy> orderBy = Optional.empty();
    if (context.ORDER() != null) {
        orderBy = Optional.of(new OrderBy(getLocation(context.ORDER()), visit(context.sortItem(), SortItem.class)));
    }
    Optional<PatternSearchMode> searchMode = Optional.empty();
    if (context.INITIAL() != null) {
        searchMode = Optional.of(new PatternSearchMode(getLocation(context.INITIAL()), INITIAL));
    } else if (context.SEEK() != null) {
        searchMode = Optional.of(new PatternSearchMode(getLocation(context.SEEK()), SEEK));
    }
    PatternRecognitionRelation relation = new PatternRecognitionRelation(getLocation(context), child, visit(context.partition, Expression.class), orderBy, visit(context.measureDefinition(), MeasureDefinition.class), getRowsPerMatch(context.rowsPerMatch()), visitIfPresent(context.skipTo(), SkipTo.class), searchMode, (RowPattern) visit(context.rowPattern()), visit(context.subsetDefinition(), SubsetDefinition.class), visit(context.variableDefinition(), VariableDefinition.class));
    if (context.identifier() == null) {
        return relation;
    }
    List<Identifier> aliases = null;
    if (context.columnAliases() != null) {
        aliases = visit(context.columnAliases().identifier(), Identifier.class);
    }
    return new AliasedRelation(getLocation(context), relation, (Identifier) visit(context.identifier()), aliases);
}
Also used : OrderBy(io.trino.sql.tree.OrderBy) VariableDefinition(io.trino.sql.tree.VariableDefinition) MeasureDefinition(io.trino.sql.tree.MeasureDefinition) SkipTo(io.trino.sql.tree.SkipTo) PatternRecognitionRelation(io.trino.sql.tree.PatternRecognitionRelation) AliasedRelation(io.trino.sql.tree.AliasedRelation) SampledRelation(io.trino.sql.tree.SampledRelation) Relation(io.trino.sql.tree.Relation) PatternRecognitionRelation(io.trino.sql.tree.PatternRecognitionRelation) SortItem(io.trino.sql.tree.SortItem) SubsetDefinition(io.trino.sql.tree.SubsetDefinition) Identifier(io.trino.sql.tree.Identifier) DereferenceExpression(io.trino.sql.tree.DereferenceExpression) LogicalExpression(io.trino.sql.tree.LogicalExpression) SearchedCaseExpression(io.trino.sql.tree.SearchedCaseExpression) BindExpression(io.trino.sql.tree.BindExpression) CoalesceExpression(io.trino.sql.tree.CoalesceExpression) QuantifiedComparisonExpression(io.trino.sql.tree.QuantifiedComparisonExpression) SimpleCaseExpression(io.trino.sql.tree.SimpleCaseExpression) SubqueryExpression(io.trino.sql.tree.SubqueryExpression) LambdaExpression(io.trino.sql.tree.LambdaExpression) SubscriptExpression(io.trino.sql.tree.SubscriptExpression) NullIfExpression(io.trino.sql.tree.NullIfExpression) ArithmeticUnaryExpression(io.trino.sql.tree.ArithmeticUnaryExpression) InListExpression(io.trino.sql.tree.InListExpression) NotExpression(io.trino.sql.tree.NotExpression) ArithmeticBinaryExpression(io.trino.sql.tree.ArithmeticBinaryExpression) TryExpression(io.trino.sql.tree.TryExpression) ComparisonExpression(io.trino.sql.tree.ComparisonExpression) IfExpression(io.trino.sql.tree.IfExpression) Expression(io.trino.sql.tree.Expression) PatternSearchMode(io.trino.sql.tree.PatternSearchMode) AliasedRelation(io.trino.sql.tree.AliasedRelation)

Aggregations

AliasedRelation (io.trino.sql.tree.AliasedRelation)1 ArithmeticBinaryExpression (io.trino.sql.tree.ArithmeticBinaryExpression)1 ArithmeticUnaryExpression (io.trino.sql.tree.ArithmeticUnaryExpression)1 BindExpression (io.trino.sql.tree.BindExpression)1 CoalesceExpression (io.trino.sql.tree.CoalesceExpression)1 ComparisonExpression (io.trino.sql.tree.ComparisonExpression)1 DereferenceExpression (io.trino.sql.tree.DereferenceExpression)1 Expression (io.trino.sql.tree.Expression)1 Identifier (io.trino.sql.tree.Identifier)1 IfExpression (io.trino.sql.tree.IfExpression)1 InListExpression (io.trino.sql.tree.InListExpression)1 LambdaExpression (io.trino.sql.tree.LambdaExpression)1 LogicalExpression (io.trino.sql.tree.LogicalExpression)1 MeasureDefinition (io.trino.sql.tree.MeasureDefinition)1 NotExpression (io.trino.sql.tree.NotExpression)1 NullIfExpression (io.trino.sql.tree.NullIfExpression)1 OrderBy (io.trino.sql.tree.OrderBy)1 PatternRecognitionRelation (io.trino.sql.tree.PatternRecognitionRelation)1 PatternSearchMode (io.trino.sql.tree.PatternSearchMode)1 QuantifiedComparisonExpression (io.trino.sql.tree.QuantifiedComparisonExpression)1