use of io.crate.expression.symbol.Literal in project crate by crate.
the class ValueNormalizerTest method testNormalizeIgnoredNewColumnTimestamp.
@Test
public void testNormalizeIgnoredNewColumnTimestamp() throws Exception {
Reference objInfo = userTableInfo.getReference(new ColumnIdent("ignored"));
Map<String, Object> map = new HashMap<String, Object>() {
{
put("time", "1970-01-01T00:00:00");
}
};
Literal<Map<String, Object>> literal = (Literal) normalizeInputForReference(Literal.of(map), objInfo);
assertThat((String) literal.value().get("time"), is("1970-01-01T00:00:00"));
}
use of io.crate.expression.symbol.Literal in project crate by crate.
the class ValueNormalizerTest method testNormalizeStringToNumberColumn.
@Test
public void testNormalizeStringToNumberColumn() throws Exception {
Reference objInfo = userTableInfo.getReference(new ColumnIdent("d"));
Literal<String> stringDoubleLiteral = Literal.of("298.444");
Literal literal = (Literal) normalizeInputForReference(stringDoubleLiteral, objInfo);
assertThat(literal, isLiteral(298.444d, DataTypes.DOUBLE));
}
use of io.crate.expression.symbol.Literal in project crate by crate.
the class ValueNormalizerTest method testNormalizeObjectLiteral.
@Test
public void testNormalizeObjectLiteral() throws Exception {
Reference objInfo = userTableInfo.getReference(new ColumnIdent("dyn"));
Map<String, Object> map = new HashMap<String, Object>() {
{
put("d", 2.9d);
put("inner_strict", new HashMap<String, Object>() {
{
put("double", "-88.7");
}
});
}
};
normalizeInputForReference(Literal.of(map), objInfo);
Symbol normalized = normalizeInputForReference(Literal.of(map), objInfo);
assertThat(normalized, instanceOf(Literal.class));
assertThat(((Literal<Map<String, Object>>) normalized).value().get("d"), Matchers.<Object>is(2.9d));
assertThat(((Literal<Map<String, Object>>) normalized).value().get("inner_strict"), Matchers.<Object>is(new HashMap<String, Object>() {
{
put("double", -88.7d);
}
}));
}
use of io.crate.expression.symbol.Literal in project crate by crate.
the class ExpressionAnalyzerTest method testInterval.
@Test
public void testInterval() throws Exception {
Literal literal = (Literal) expressions.asSymbol("INTERVAL '1' MONTH");
assertThat(literal.valueType(), is(DataTypes.INTERVAL));
Period period = (Period) literal.value();
assertThat(period, is(new Period().withMonths(1)));
}
use of io.crate.expression.symbol.Literal in project crate by crate.
the class ExpressionAnalyzerTest method testIntervalConversion.
@Test
public void testIntervalConversion() throws Exception {
Literal literal = (Literal) expressions.asSymbol("INTERVAL '1' HOUR to SECOND");
assertThat(literal.valueType(), is(DataTypes.INTERVAL));
Period period = (Period) literal.value();
assertThat(period, is(new Period().withSeconds(1)));
}
Aggregations