use of io.crate.testing.SqlExpressions in project crate by crate.
the class CurrentSchemaFunctionTest method testNormalizeCurrentSchemaCustomSchema.
@Test
public void testNormalizeCurrentSchemaCustomSchema() throws Exception {
sqlExpressions = new SqlExpressions(tableSources, new SessionContext(0, Option.NONE, "custom_schema"));
functions = sqlExpressions.getInstance(Functions.class);
assertNormalize("current_schema()", isLiteral("custom_schema"), false);
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class ExpressionAnalyzerTest method testBetweenNullIsRewrittenToLteAndGte.
@Test
public void testBetweenNullIsRewrittenToLteAndGte() throws Exception {
SqlExpressions expressions = new SqlExpressions(T3.SOURCES);
Symbol symbol = expressions.asSymbol("10 between 1 and NULL");
assertThat(symbol, isSQL("((10 >= 1) AND (10 <= NULL))"));
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class SymbolPrinterTest method prepare.
@Before
public void prepare() throws Exception {
DocTableInfo tableInfo = TestingTableInfo.builder(new TableIdent(DocSchemaInfo.NAME, TABLE_NAME), null).add("foo", DataTypes.STRING).add("bar", DataTypes.LONG).add("CraZy", DataTypes.IP).add("select", DataTypes.BYTE).add("idx", DataTypes.INTEGER).add("s_arr", new ArrayType(DataTypes.STRING)).build();
Map<QualifiedName, AnalyzedRelation> sources = ImmutableMap.<QualifiedName, AnalyzedRelation>builder().put(QualifiedName.of(TABLE_NAME), new TableRelation(tableInfo)).build();
sqlExpressions = new SqlExpressions(sources);
printer = new SymbolPrinter(sqlExpressions.functions());
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class AbstractScalarFunctionsTest method prepareFunctions.
@Before
public void prepareFunctions() throws Exception {
DocTableInfo tableInfo = TestingTableInfo.builder(new TableIdent(DocSchemaInfo.NAME, "users"), null).add("id", DataTypes.INTEGER).add("name", DataTypes.STRING).add("tags", new ArrayType(DataTypes.STRING)).add("age", DataTypes.INTEGER).add("a", DataTypes.INTEGER).add("x", DataTypes.LONG).add("shape", DataTypes.GEO_SHAPE).add("timestamp", DataTypes.TIMESTAMP).add("timezone", DataTypes.STRING).add("interval", DataTypes.STRING).add("time_format", DataTypes.STRING).add("long_array", new ArrayType(DataTypes.LONG)).add("int_array", new ArrayType(DataTypes.INTEGER)).add("long_set", new SetType(DataTypes.LONG)).add("regex_pattern", DataTypes.STRING).add("geoshape", DataTypes.GEO_SHAPE).add("geopoint", DataTypes.GEO_POINT).add("geostring", DataTypes.STRING).add("is_awesome", DataTypes.BOOLEAN).add("double_val", DataTypes.DOUBLE).add("float_val", DataTypes.DOUBLE).add("short_val", DataTypes.SHORT).add("obj", DataTypes.OBJECT, ImmutableList.of()).build();
DocTableRelation tableRelation = new DocTableRelation(tableInfo);
tableSources = ImmutableMap.of(new QualifiedName("users"), tableRelation);
sqlExpressions = new SqlExpressions(tableSources);
functions = sqlExpressions.getInstance(Functions.class);
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class NestedLoopPhaseTest method testSerialization.
@Test
public void testSerialization() throws Exception {
TopNProjection topNProjection = new TopNProjection(10, 0, Collections.emptyList());
UUID jobId = UUID.randomUUID();
MergePhase mp1 = new MergePhase(jobId, 2, "merge", 1, Collections.emptyList(), ImmutableList.<DataType>of(DataTypes.STRING), ImmutableList.of(), DistributionInfo.DEFAULT_BROADCAST, null);
MergePhase mp2 = new MergePhase(jobId, 3, "merge", 1, Collections.emptyList(), ImmutableList.<DataType>of(DataTypes.STRING), ImmutableList.of(), DistributionInfo.DEFAULT_BROADCAST, null);
SqlExpressions sqlExpressions = new SqlExpressions(T3.SOURCES, T3.TR_1);
Symbol joinCondition = sqlExpressions.normalize(sqlExpressions.asSymbol("t1.x = t1.i"));
NestedLoopPhase node = new NestedLoopPhase(jobId, 1, "nestedLoop", ImmutableList.of(topNProjection), mp1, mp2, Sets.newHashSet("node1", "node2"), JoinType.INNER, joinCondition, 1, 1);
BytesStreamOutput output = new BytesStreamOutput();
node.writeTo(output);
StreamInput input = StreamInput.wrap(output.bytes());
NestedLoopPhase node2 = new NestedLoopPhase();
node2.readFrom(input);
assertThat(node.nodeIds(), Is.is(node2.nodeIds()));
assertThat(node.jobId(), Is.is(node2.jobId()));
assertThat(node.name(), is(node2.name()));
assertThat(node.outputTypes(), is(node2.outputTypes()));
assertThat(node.joinType(), is(node2.joinType()));
assertThat(node.numLeftOutputs(), is(node2.numLeftOutputs()));
assertThat(node.numRightOutputs(), is(node2.numRightOutputs()));
}
Aggregations