use of org.apache.ignite.internal.processors.query.QueryField in project ignite by apache.
the class H2DynamicColumnsAbstractBasicSelfTest method testAddColumnToNonDynamicCacheWithRealValueType.
/**
* Test that we can add columns dynamically to tables associated with non dynamic caches storing user types as well.
*/
@SuppressWarnings("unchecked")
public void testAddColumnToNonDynamicCacheWithRealValueType() throws SQLException {
CacheConfiguration<Integer, City> ccfg = defaultCacheConfiguration().setName("City").setIndexedTypes(Integer.class, City.class);
IgniteCache<Integer, ?> cache = ignite(nodeIndex()).getOrCreateCache(ccfg);
run(cache, "ALTER TABLE \"City\".City ADD COLUMN population int");
doSleep(500);
QueryField c = c("POPULATION", Integer.class.getName());
checkTableState("City", "CITY", c);
run(cache, "INSERT INTO \"City\".City (_key, id, name, state_name, population) values " + "(1, 1, 'Washington', 'DC', 2500000)");
List<List<?>> res = run(cache, "select _key, id, name, state_name, population from \"City\".City");
assertEquals(Collections.singletonList(Arrays.asList(1, 1, "Washington", "DC", 2500000)), res);
if (!Boolean.valueOf(GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER))) {
City city = (City) cache.get(1);
assertEquals(1, city.id());
assertEquals("Washington", city.name());
assertEquals("DC", city.state());
} else {
BinaryObject city = (BinaryObject) cache.withKeepBinary().get(1);
assertEquals(1, (int) city.field("id"));
assertEquals("Washington", (String) city.field("name"));
assertEquals("DC", (String) city.field("state"));
assertEquals(2500000, (int) city.field("population"));
}
cache.destroy();
}
use of org.apache.ignite.internal.processors.query.QueryField in project ignite by apache.
the class H2DynamicColumnsAbstractBasicSelfTest method testAddNullColumn.
/**
* Test addition of column explicitly defined as nullable.
*/
public void testAddNullColumn() throws SQLException {
run("ALTER TABLE Person ADD COLUMN age int NULL");
doSleep(500);
QueryField c = new QueryField("AGE", Integer.class.getName(), true);
checkTableState(QueryUtils.DFLT_SCHEMA, "PERSON", c);
}
Aggregations