use of com.datastax.oss.dsbulk.generated.cql3.CqlParser.TermContext in project dsbulk by datastax.
the class QueryInspector method visitFunction.
@Override
@NonNull
public FunctionCall visitFunction(FunctionContext ctx) {
CQLWord keyspaceName = null;
if (ctx.functionName().keyspaceName() != null) {
keyspaceName = visitKeyspaceName(ctx.functionName().keyspaceName());
}
CQLWord functionName = visitAllowedFunctionName(ctx.functionName().allowedFunctionName());
List<CQLFragment> args = new ArrayList<>();
if (ctx.functionArgs() != null) {
for (TermContext arg : ctx.functionArgs().term()) {
CQLFragment term = visitTerm(arg);
if (term == QUESTION_MARK) {
throw new IllegalArgumentException(String.format("Invalid query: positional variables are not allowed as function parameters: %s.", query));
}
args.add(term);
}
}
return new FunctionCall(keyspaceName, functionName, args);
}
use of com.datastax.oss.dsbulk.generated.cql3.CqlParser.TermContext 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;
}
Aggregations