use of io.crate.analyze.symbol.Symbol in project crate by crate.
the class SymbolToTrueVisitorTest method testNotPredicate.
@Test
public void testNotPredicate() throws Exception {
Symbol symbol = convertFromSQL(("not (clustered_by = 'foo')"));
assertThat(symbol, isLiteral(true));
}
use of io.crate.analyze.symbol.Symbol in project crate by crate.
the class SymbolToTrueVisitorTest method testNot_FalseAndSubstr.
@Test
public void testNot_FalseAndSubstr() throws Exception {
Symbol symbol = convertFromSQL("not (false and substr(table_name, 1, 1) = '1')");
assertThat(symbol, isLiteral(true));
}
use of io.crate.analyze.symbol.Symbol in project crate by crate.
the class InsertFromSubQueryAnalyzerTest method assertCompatibleColumns.
private void assertCompatibleColumns(InsertFromSubQueryAnalyzedStatement statement) {
List<Symbol> outputSymbols = statement.subQueryRelation().querySpec().outputs();
assertThat(statement.columns().size(), is(outputSymbols.size()));
for (int i = 0; i < statement.columns().size(); i++) {
Symbol subQueryColumn = outputSymbols.get(i);
assertThat(subQueryColumn, instanceOf(Symbol.class));
Reference insertColumn = statement.columns().get(i);
assertThat(subQueryColumn.valueType().isConvertableTo(insertColumn.valueType()), is(true));
}
}
use of io.crate.analyze.symbol.Symbol in project crate by crate.
the class InsertFromValuesAnalyzerTest method testInsertFromValuesWithOnDuplicateKey.
@Test
public void testInsertFromValuesWithOnDuplicateKey() throws Exception {
InsertFromValuesAnalyzedStatement statement = e.analyze("insert into users (id, name, other_id) values (1, 'Arthur', 10) " + "on duplicate key update name = substr(values (name), 1, 2), " + "other_id = other_id + 100");
assertThat(statement.onDuplicateKeyAssignments().size(), is(1));
Symbol[] assignments = statement.onDuplicateKeyAssignments().get(0);
assertThat(assignments.length, is(2));
assertThat(assignments[0], isLiteral("Ar"));
assertThat(assignments[1], isFunction(AddFunction.NAME));
Function function = (Function) assignments[1];
assertThat(function.arguments().get(0), isReference("other_id"));
}
use of io.crate.analyze.symbol.Symbol in project crate by crate.
the class TopNProjectionTest method testStreaming.
@Test
public void testStreaming() throws Exception {
ImmutableList<Symbol> outputs = ImmutableList.of(new Value(DataTypes.BOOLEAN), new Value(DataTypes.INTEGER));
TopNProjection p = new TopNProjection(5, 10, outputs);
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(p, out);
StreamInput in = StreamInput.wrap(out.bytes());
TopNProjection p2 = (TopNProjection) Projection.fromStream(in);
assertEquals(p, p2);
}
Aggregations