use of io.crate.expression.symbol.Function in project crate by crate.
the class SelectStatementAnalyzerTest method testILikeInWhereQuery.
@Test
public void testILikeInWhereQuery() {
var executor = SQLExecutor.builder(clusterService).build();
QueriedSelectRelation relation = executor.analyze("select * from sys.nodes where name ilike 'foo%'");
assertNotNull(relation.where());
Function whereClause = (Function) relation.where();
assertThat(whereClause.name(), is(LikeOperators.OP_ILIKE));
List<DataType> argumentTypes = List.of(DataTypes.STRING, DataTypes.STRING);
assertEquals(argumentTypes, Symbols.typeView(whereClause.arguments()));
assertThat(whereClause.arguments().get(0), isReference("name"));
assertThat(whereClause.arguments().get(1), isLiteral("foo%"));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class SelectStatementAnalyzerTest method testAnyLike.
@Test
public void testAnyLike() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
QueriedSelectRelation relation = executor.analyze("select * from users where 'awesome' LIKE ANY (tags)");
Function query = (Function) relation.where();
assertThat(query.name(), is("any_like"));
assertThat(query.arguments().size(), is(2));
assertThat(query.arguments().get(0), instanceOf(Literal.class));
assertThat(query.arguments().get(0), isLiteral("awesome", DataTypes.STRING));
assertThat(query.arguments().get(1), isReference("tags"));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class SelectStatementAnalyzerTest method testLikeInWhereQuery.
@Test
public void testLikeInWhereQuery() {
var executor = SQLExecutor.builder(clusterService).build();
QueriedSelectRelation relation = executor.analyze("select * from sys.nodes where name like 'foo'");
assertNotNull(relation.where());
Function whereClause = (Function) relation.where();
assertThat(whereClause.name(), is(LikeOperators.OP_LIKE));
List<DataType> argumentTypes = List.of(DataTypes.STRING, DataTypes.STRING);
assertEquals(argumentTypes, Symbols.typeView(whereClause.arguments()));
assertThat(whereClause.arguments().get(0), isReference("name"));
assertThat(whereClause.arguments().get(1), isLiteral("foo"));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class SelectStatementAnalyzerTest method testSubscriptArrayNested.
@Test
public void testSubscriptArrayNested() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable(TableDefinitions.DEEPLY_NESTED_TABLE_DEFINITION).build();
AnalyzedRelation relation = executor.analyze("select tags[1]['name'] from deeply_nested");
assertThat(relation.outputs().get(0), isFunction(SubscriptFunction.NAME));
List<Symbol> arguments = ((Function) relation.outputs().get(0)).arguments();
assertThat(arguments.size(), is(2));
assertThat(arguments.get(0), isReference("tags['name']"));
assertThat(arguments.get(1), isLiteral(1));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class SelectStatementAnalyzerTest method testSubscriptArray.
@Test
public void testSubscriptArray() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
AnalyzedRelation relation = executor.analyze("select tags[1] from users");
assertThat(relation.outputs().get(0), isFunction(SubscriptFunction.NAME));
List<Symbol> arguments = ((Function) relation.outputs().get(0)).arguments();
assertThat(arguments.size(), is(2));
assertThat(arguments.get(0), isReference("tags"));
assertThat(arguments.get(1), isLiteral(1));
}
Aggregations