use of io.confluent.ksql.parser.tree.QualifiedName in project ksql by confluentinc.
the class AstBuilder method visitFunctionCall.
@Override
public Node visitFunctionCall(SqlBaseParser.FunctionCallContext context) {
Optional<Window> window = visitIfPresent(context.over(), Window.class);
QualifiedName name = getQualifiedName(context.qualifiedName());
boolean distinct = false;
if (name.toString().equals("NULLIF")) {
check(context.expression().size() == 2, "Invalid number of arguments for 'nullif' function", context);
check(!window.isPresent(), "OVER clause not valid for 'nullif' function", context);
check(!distinct, "DISTINCT not valid for 'nullif' function", context);
return new NullIfExpression(getLocation(context), (Expression) visit(context.expression(0)), (Expression) visit(context.expression(1)));
}
return new FunctionCall(getLocation(context), getQualifiedName(context.qualifiedName()), window, distinct, visit(context.expression(), Expression.class));
}
use of io.confluent.ksql.parser.tree.QualifiedName in project ksql by confluentinc.
the class AstBuilder method visitPrintTopic.
@Override
public Node visitPrintTopic(SqlBaseParser.PrintTopicContext context) {
boolean fromBeginning = context.FROM() != null;
QualifiedName topicName = null;
if (context.STRING() != null) {
topicName = QualifiedName.of(unquote(context.STRING().getText(), "'"));
} else {
topicName = getQualifiedName(context.qualifiedName());
}
if (context.number() == null) {
return new PrintTopic(getLocation(context), topicName, fromBeginning, null);
} else if (context.number() instanceof SqlBaseParser.IntegerLiteralContext) {
SqlBaseParser.IntegerLiteralContext integerLiteralContext = (SqlBaseParser.IntegerLiteralContext) context.number();
return new PrintTopic(getLocation(context), topicName, fromBeginning, (LongLiteral) visitIntegerLiteral(integerLiteralContext));
} else {
throw new KsqlException("Interval value should be integer in 'PRINT' command!");
}
}
use of io.confluent.ksql.parser.tree.QualifiedName in project ksql by confluentinc.
the class AstBuilder method visitDereference.
@Override
public Node visitDereference(SqlBaseParser.DereferenceContext context) {
String fieldName = getIdentifierText(context.identifier());
Expression baseExpression;
QualifiedName tableName = QualifiedName.of(context.primaryExpression().getText().toUpperCase());
baseExpression = new QualifiedNameReference(getLocation(context.primaryExpression()), tableName);
DereferenceExpression dereferenceExpression = new DereferenceExpression(getLocation(context), baseExpression, fieldName);
return dereferenceExpression;
}
Aggregations