use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlQueryResultTest method checkSuccess.
private void checkSuccess(HazelcastInstance target, String sql, SqlExpectedResultType type, List<SqlRow> expectedRows, int expectedUpdateCount) {
SqlResult result = target.getSql().execute(new SqlStatement(sql).setExpectedResultType(type));
assertEquals(expectedUpdateCount, result.updateCount());
if (expectedUpdateCount >= 0) {
return;
}
List<SqlRow> rows = new ArrayList<>();
for (SqlRow row : result) {
rows.add(row);
}
assertEquals(expectedRows.size(), rows.size());
for (int i = 0; i < expectedRows.size(); i++) {
SqlRow expectedRow = expectedRows.get(i);
SqlRow row = rows.get(i);
assertEquals(expectedRow.getMetadata(), row.getMetadata());
for (int j = 0; j < expectedRow.getMetadata().getColumnCount(); j++) {
Object expectedValue = expectedRow.getObject(j);
Object value = row.getObject(j);
assertEquals(expectedValue, value);
}
}
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlTumbleTest method checkValidArguments.
private static void checkValidArguments(QueryDataTypeFamily orderingColumnType, String windowSize, Object[]... values) {
String name = randomName();
TestStreamSqlConnector.create(sqlService, name, singletonList("ts"), singletonList(orderingColumnType), values);
try (SqlResult result = sqlService.execute("SELECT * FROM " + "TABLE(TUMBLE(TABLE " + name + ", DESCRIPTOR(ts), " + windowSize + "))")) {
assertThat(result.getRowMetadata().findColumn("window_start")).isEqualTo(1);
assertThat(result.getRowMetadata().getColumn(1).getType()).isEqualTo(orderingColumnType.getPublicType());
assertThat(result.getRowMetadata().findColumn("window_end")).isEqualTo(2);
assertThat(result.getRowMetadata().getColumn(2).getType()).isEqualTo(orderingColumnType.getPublicType());
assertThat(result.iterator()).hasNext();
}
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlMetadataInJobConfigTest method test_dmlMetadata.
@Test
public void test_dmlMetadata() {
createMapping("dest", Integer.class, Integer.class);
TestBatchSqlConnector.create(instance().getSql(), "src", 1, true);
String sql = "INSERT INTO dest SELECT v, v FROM src";
Future<SqlResult> f = spawn(() -> instance().getSql().execute(sql));
awaitSingleRunningJob(instance());
List<Job> runningJobs = getJobsByStatus(RUNNING);
assertEquals(1, runningJobs.size());
JobConfig config = runningJobs.get(0).getConfig();
assertEquals(sql, config.getArgument(KEY_SQL_QUERY_TEXT));
assertEquals(Boolean.FALSE, config.getArgument(KEY_SQL_UNBOUNDED));
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlMetadataInJobConfigTest method test_selectMetadata_member.
@Test
public void test_selectMetadata_member() {
String sql = "SELECT * FROM table(generate_stream(1))";
try (SqlResult ignored = client().getSql().execute(new SqlStatement(sql).setCursorBufferSize(1))) {
List<Job> runningJobs = getJobsByStatus(RUNNING);
assertEquals(1, runningJobs.size());
JobConfig config = runningJobs.get(0).getConfig();
assertEquals(sql, config.getArgument(KEY_SQL_QUERY_TEXT));
assertEquals(Boolean.TRUE, config.getArgument(KEY_SQL_UNBOUNDED));
}
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlNullableColumnTest method testSelectWithNonNullSupport.
@Test
public void testSelectWithNonNullSupport() {
createMapping("map", String.class, int.class);
instance().getMap("map").put("key", 1);
SqlResult result = instance().getSql().execute("SELECT __key, 1 FROM map");
List<SqlColumnMetadata> columns = result.getRowMetadata().getColumns();
assertEquals(columns.size(), 2);
assertTrue(columns.get(0).isNullable());
assertFalse(columns.get(1).isNullable());
}
Aggregations