use of io.crate.types.ArrayType in project crate by crate.
the class AnyNotLikeOperatorTest method normalizeSymbol.
private static Symbol normalizeSymbol(String pattern, String... expressions) {
Literal patternLiteral = Literal.of(pattern);
Object[] value = new Object[expressions.length];
for (int i = 0; i < expressions.length; i++) {
value[i] = expressions[i] == null ? null : new BytesRef(expressions[i]);
}
Literal valuesLiteral = Literal.of(new ArrayType(DataTypes.STRING), value);
AnyNotLikeOperator impl = (AnyNotLikeOperator) new AnyNotLikeOperator.AnyNotLikeResolver().getForTypes(Arrays.asList(patternLiteral.valueType(), valuesLiteral.valueType()));
Function function = new Function(impl.info(), Arrays.<Symbol>asList(patternLiteral, valuesLiteral));
return impl.normalizeSymbol(function, new TransactionContext(SessionContext.SYSTEM_SESSION));
}
use of io.crate.types.ArrayType in project crate by crate.
the class DataTypeTest method testForValueWithObjectList.
@Test
public void testForValueWithObjectList() {
Map<String, Object> objA = new HashMap<>();
objA.put("a", 1);
Map<String, Object> objB = new HashMap<>();
Map<String, Object> objBNested = new HashMap<>();
objB.put("b", objBNested);
objBNested.put("bn1", 1);
objBNested.put("bn2", 2);
List<Object> objects = Arrays.<Object>asList(objA, objB);
DataType dataType = DataTypes.guessType(objects);
assertEquals(dataType, new ArrayType(DataTypes.OBJECT));
}
use of io.crate.types.ArrayType in project crate by crate.
the class WhereClauseAnalyzerTest method testAnyEqConvertableArrayTypeLiterals.
@Test
public void testAnyEqConvertableArrayTypeLiterals() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from users where name = any([1, 2, 3])");
assertThat(whereClause.query(), isFunction(AnyEqOperator.NAME, ImmutableList.<DataType>of(DataTypes.STRING, new ArrayType(DataTypes.STRING))));
}
use of io.crate.types.ArrayType 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.types.ArrayType in project crate by crate.
the class WhereClauseAnalyzerTest method testAnyLikeConvertableArrayTypeLiterals.
@Test
public void testAnyLikeConvertableArrayTypeLiterals() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from users where name like any([1, 2, 3])");
assertThat(whereClause.query(), isFunction(AnyLikeOperator.NAME, ImmutableList.<DataType>of(DataTypes.STRING, new ArrayType(DataTypes.STRING))));
}
Aggregations