use of io.crate.expression.symbol.Literal in project crate by crate.
the class ValueNormalizerTest method testNormalizeDynamicEmptyObjectLiteral.
@Test
@SuppressWarnings("unchecked")
public void testNormalizeDynamicEmptyObjectLiteral() throws Exception {
Reference objRef = userTableInfo.getReference(new ColumnIdent("dyn_empty"));
Map<String, Object> map = new HashMap<>();
map.put("time", "2014-02-16T00:00:01");
map.put("false", true);
Literal<Map<String, Object>> normalized = (Literal) normalizeInputForReference(Literal.of(map), objRef);
assertThat((String) normalized.value().get("time"), is("2014-02-16T00:00:01"));
assertThat((Boolean) normalized.value().get("false"), is(true));
}
use of io.crate.expression.symbol.Literal in project crate by crate.
the class ValueNormalizerTest method testNormalizeDynamicObjectLiteralWithAdditionalColumn.
@Test
public void testNormalizeDynamicObjectLiteralWithAdditionalColumn() throws Exception {
Reference objInfo = userTableInfo.getReference(new ColumnIdent("dyn"));
Map<String, Object> map = new HashMap<>();
map.put("d", 2.9d);
map.put("half", "1.45");
Symbol normalized = normalizeInputForReference(Literal.of(map), objInfo);
assertThat(normalized, instanceOf(Literal.class));
// stays the same
assertThat(((Literal) normalized).value(), Matchers.<Object>is(map));
}
use of io.crate.expression.symbol.Literal in project crate by crate.
the class ValueNormalizerTest method testNormalizeDynamicNewColumnTimestamp.
@Test
public void testNormalizeDynamicNewColumnTimestamp() throws Exception {
Reference objInfo = userTableInfo.getReference(new ColumnIdent("dyn"));
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 testNormalizeObjectLiteralConvertFromString.
@Test
public void testNormalizeObjectLiteralConvertFromString() throws Exception {
Reference objInfo = userTableInfo.getReference(new ColumnIdent("dyn"));
Map<String, Object> map = new HashMap<>();
map.put("d", "2.9");
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));
}
use of io.crate.expression.symbol.Literal in project crate by crate.
the class ValueNormalizerTest method testNormalizeDynamicNewColumnNoTimestamp.
@Test
public void testNormalizeDynamicNewColumnNoTimestamp() throws Exception {
Reference objInfo = userTableInfo.getReference(new ColumnIdent("ignored"));
Map<String, Object> map = new HashMap<String, Object>() {
{
put("no_time", "1970");
}
};
Literal<Map<String, Object>> literal = (Literal) normalizeInputForReference(Literal.of(map), objInfo);
assertThat((String) literal.value().get("no_time"), is("1970"));
}
Aggregations