use of io.crate.analyze.relations.QueriedRelation in project crate by crate.
the class SelectStatementAnalyzerTest method testRewriteRegexpNoMatch.
@Test
public void testRewriteRegexpNoMatch() throws Exception {
String statement = "select * from sys.nodes where sys.nodes.name !~ '[sS]omething'";
QueriedRelation relation = analyze(statement).relation();
WhereClause whereClause = relation.querySpec().where();
Function notFunction = (Function) whereClause.query();
assertThat(notFunction.info().ident().name(), is(NotPredicate.NAME));
assertThat(notFunction.arguments().size(), is(1));
Function eqFunction = (Function) notFunction.arguments().get(0);
assertThat(eqFunction.info().ident().name(), is(RegexpMatchOperator.NAME));
assertThat(eqFunction.arguments().size(), is(2));
List<Symbol> eqArguments = eqFunction.arguments();
assertThat(eqArguments.get(0), isReference("name"));
assertThat(eqArguments.get(1), isLiteral("[sS]omething"));
}
use of io.crate.analyze.relations.QueriedRelation in project crate by crate.
the class SelectStatementAnalyzerTest method testGroupByOnOrdinal.
@Test
public void testGroupByOnOrdinal() throws Exception {
// just like in postgres access by ordinal starts with 1
QueriedRelation relation = analyze("select count(*), name as n from sys.nodes group by 2").relation();
assertThat(relation.querySpec().groupBy().get().size(), is(1));
assertEquals(relation.querySpec().groupBy().get().get(0), relation.querySpec().outputs().get(1));
}
use of io.crate.analyze.relations.QueriedRelation in project crate by crate.
the class SelectStatementAnalyzerTest method testAllColumnCluster.
@Test
public void testAllColumnCluster() throws Exception {
QueriedRelation relation = analyze("select * from sys.cluster").relation();
assertThat(relation.fields().size(), is(4));
assertThat(outputNames(relation), containsInAnyOrder("id", "master_node", "name", "settings"));
assertThat(relation.querySpec().outputs().size(), is(4));
}
Aggregations