use of org.apache.ignite.internal.processors.query.GridQueryFieldMetadata in project ignite by apache.
the class IgniteCacheAbstractFieldsQuerySelfTest method testExecuteWithMetaDataAndPrecision.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
@Test
public void testExecuteWithMetaDataAndPrecision() throws Exception {
QueryEntity qeWithPrecision = new QueryEntity().setKeyType("java.lang.Long").setValueType("TestType").addQueryField("strField", "java.lang.String", "strField").setFieldsPrecision(ImmutableMap.of("strField", 999));
grid(0).getOrCreateCache(cacheConfiguration().setName("cacheWithPrecision").setQueryEntities(Collections.singleton(qeWithPrecision)));
GridQueryProcessor qryProc = grid(0).context().query();
qryProc.querySqlFields(new SqlFieldsQuery("INSERT INTO TestType(_KEY, strField) VALUES(?, ?)").setSchema("cacheWithPrecision").setArgs(1, "ABC"), true);
qryProc.querySqlFields(new SqlFieldsQuery("INSERT INTO TestType(_KEY, strField) VALUES(?, ?)").setSchema("cacheWithPrecision").setArgs(2, "DEF"), true);
QueryCursorImpl<List<?>> cursor = (QueryCursorImpl<List<?>>) qryProc.querySqlFields(new SqlFieldsQuery("SELECT _KEY, strField FROM TestType").setSchema("cacheWithPrecision"), true);
List<GridQueryFieldMetadata> fieldsMeta = cursor.fieldsMeta();
for (GridQueryFieldMetadata meta : fieldsMeta) {
if (!meta.fieldName().equalsIgnoreCase("strField"))
continue;
assertEquals(999, meta.precision());
}
}
use of org.apache.ignite.internal.processors.query.GridQueryFieldMetadata in project ignite by apache.
the class ParameterTypeInferenceTest method check.
/**
* Execute query.
*
* @param qry Query.
* @param loc Local flag.
*/
private void check(String qry, boolean loc) {
List<Object[]> argss = new ArrayList<>();
argss.add(new Object[] { null });
argss.add(new Object[] { "STRING" });
argss.add(new Object[] { 1 });
argss.add(new Object[] { 1L });
argss.add(new Object[] { new BigDecimal("12.12") });
argss.add(new Object[] { UUID.randomUUID() });
clearParserCache();
for (int i = 0; i < argss.size(); i++) {
for (Object[] args : argss) {
for (int j = 0; j < 2; j++) {
SqlFieldsQuery qry0 = new SqlFieldsQuery(qry).setLocal(loc).setArgs(args);
try (QueryCursorEx<List<?>> cur = (QueryCursorEx<List<?>>) grid(0).cache(CACHE_NAME).query(qry0)) {
GridQueryFieldMetadata meta = cur.fieldsMeta().get(0);
cur.getAll();
String errMsg = "Failure on i=" + i + ", j=" + j + ": " + meta.fieldTypeName();
assertEquals(errMsg, Object.class.getName(), meta.fieldTypeName());
}
}
}
argss.add(argss.remove(0));
}
}
Aggregations