Search in sources :

Example 1 with RelationTypeContext

use of com.datastax.oss.dsbulk.generated.cql3.CqlParser.RelationTypeContext in project dsbulk by datastax.

the class QueryInspector method visitRelation.

// WHERE clause
@Override
@Nullable
public CQLFragment visitRelation(RelationContext ctx) {
    // relation contains another relation: drill down
    while (ctx.relation() != null) {
        ctx = ctx.relation();
    }
    // myCol = :myVar or myCol = ?
    if (ctx.getChildCount() == 3 && ctx.getChild(0) instanceof CidentContext && ctx.getChild(1) instanceof RelationTypeContext && ctx.getChild(2) instanceof TermContext && ctx.getChild(1).getText().equals("=")) {
        CQLWord column = visitCident(ctx.cident());
        if (column.equals(SOLR_QUERY)) {
            hasSearchClause = true;
        }
        CQLFragment variable = visitTerm(ctx.term().get(0));
        assignmentsBuilder.put(column, variable.equals(QUESTION_MARK) ? column : variable);
    } else if (ctx.K_TOKEN() != null) {
        CQLFragment variable = visitTerm(ctx.term().get(0));
        if (variable instanceof CQLWord) {
            if (variable == QUESTION_MARK) {
                variable = INTERNAL_TOKEN_VARNAME;
            }
            if (ctx.relationType().getText().equals(">")) {
                tokenRangeRestrictionStartVariable = (CQLWord) variable;
                tokenRangeRestrictionStartVariableIndex = tokenRangeRestrictionVariableIndex++;
            } else if (ctx.relationType().getText().equals("<=")) {
                tokenRangeRestrictionEndVariable = (CQLWord) variable;
                tokenRangeRestrictionEndVariableIndex = tokenRangeRestrictionVariableIndex++;
            }
        }
    }
    // other relation types: unsupported
    return null;
}
Also used : CidentContext(com.datastax.oss.dsbulk.generated.cql3.CqlParser.CidentContext) RelationTypeContext(com.datastax.oss.dsbulk.generated.cql3.CqlParser.RelationTypeContext) CQLWord(com.datastax.oss.dsbulk.mapping.CQLWord) CQLFragment(com.datastax.oss.dsbulk.mapping.CQLFragment) TermContext(com.datastax.oss.dsbulk.generated.cql3.CqlParser.TermContext) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Aggregations

CidentContext (com.datastax.oss.dsbulk.generated.cql3.CqlParser.CidentContext)1 RelationTypeContext (com.datastax.oss.dsbulk.generated.cql3.CqlParser.RelationTypeContext)1 TermContext (com.datastax.oss.dsbulk.generated.cql3.CqlParser.TermContext)1 CQLFragment (com.datastax.oss.dsbulk.mapping.CQLFragment)1 CQLWord (com.datastax.oss.dsbulk.mapping.CQLWord)1 Nullable (edu.umd.cs.findbugs.annotations.Nullable)1