use of io.confluent.ksql.parser.tree.QualifiedNameReference in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatRow.
@Test
public void shouldFormatRow() {
final String result = ExpressionFormatter.formatExpression(new Row(Arrays.asList(new LongLiteral("1"), new QualifiedNameReference(QualifiedName.of(Arrays.asList("a", "b"))))));
assertThat(result, equalTo("ROW (1, a.b)"));
}
use of io.confluent.ksql.parser.tree.QualifiedNameReference 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;
}
use of io.confluent.ksql.parser.tree.QualifiedNameReference in project ksql by confluentinc.
the class QueryAnalyzerTest method shouldCreateAnalysisForSimpleQuery.
@Test
public void shouldCreateAnalysisForSimpleQuery() {
final List<Statement> statements = ksqlParser.buildAst("select orderid from orders;", metaStore);
final Analysis analysis = queryAnalyzer.analyze("sqlExpression", (Query) statements.get(0));
final Pair<StructuredDataSource, String> fromDataSource = analysis.getFromDataSource(0);
assertThat(analysis.getSelectExpressions(), equalTo(Collections.singletonList(new DereferenceExpression(new QualifiedNameReference(QualifiedName.of("ORDERS")), "ORDERID"))));
assertThat(analysis.getFromDataSources().size(), equalTo(1));
assertThat(fromDataSource.left, instanceOf(KsqlStream.class));
assertThat(fromDataSource.right, equalTo("ORDERS"));
}
Aggregations