use of com.hazelcast.sql.SqlRowMetadata in project hazelcast by hazelcast.
the class PlanExecutor method execute.
SqlResult execute(ExplainStatementPlan plan) {
Stream<String> planRows;
SqlRowMetadata metadata = new SqlRowMetadata(singletonList(new SqlColumnMetadata("rel", VARCHAR, false)));
InternalSerializationService serializationService = Util.getSerializationService(hazelcastInstance);
planRows = Arrays.stream(plan.getRel().explain().split(LE));
return new SqlResultImpl(QueryId.create(hazelcastInstance.getLocalEndpoint().getUuid()), new StaticQueryResultProducerImpl(planRows.map(rel -> new JetSqlRow(serializationService, new Object[] { rel })).iterator()), metadata, false);
}
use of com.hazelcast.sql.SqlRowMetadata in project hazelcast by hazelcast.
the class SqlJsonTestSupport method query.
public static List<Map<String, Object>> query(final String sql) {
final List<Map<String, Object>> results = new ArrayList<>();
for (final SqlRow row : instance().getSql().execute(sql)) {
final Map<String, Object> result = new HashMap<>();
final SqlRowMetadata rowMetadata = row.getMetadata();
for (int i = 0; i < rowMetadata.getColumnCount(); i++) {
result.put(rowMetadata.getColumn(i).getName(), row.getObject(i));
}
results.add(result);
}
return results;
}
use of com.hazelcast.sql.SqlRowMetadata in project hazelcast by hazelcast.
the class ShowStatementTest method test_showStatement_metadata.
@Test
public void test_showStatement_metadata() {
SqlRowMetadata expectedMetadata = new SqlRowMetadata(singletonList(new SqlColumnMetadata("name", SqlColumnType.VARCHAR, false)));
assertThat(sqlService.execute("show mappings").getRowMetadata()).isEqualTo(expectedMetadata);
assertThat(sqlService.execute("show jobs").getRowMetadata()).isEqualTo(expectedMetadata);
}
use of com.hazelcast.sql.SqlRowMetadata in project hazelcast by hazelcast.
the class SqlInsertWindowBoundsTest method test_windowBoundsSameTypeAsDescriptor_BIGINT.
@Test
public void test_windowBoundsSameTypeAsDescriptor_BIGINT() {
String name = randomName();
TestStreamSqlConnector.create(sqlService, name, asList("ts", "name"), asList(BIGINT, VARCHAR), row(1L, "Alice"), row(10L, null));
String interval = "1";
final SqlRow row = instance().getSql().execute(sql(name, interval)).iterator().next();
final SqlRowMetadata metadata = row.getMetadata();
assertThat(metadata.getColumn(0).getType()).isEqualTo(SqlColumnType.BIGINT);
assertThat((Object) row.getObject(0)).isInstanceOf(SqlColumnType.BIGINT.getValueClass());
assertThat(metadata.getColumn(1).getType()).isEqualTo(SqlColumnType.BIGINT);
assertThat((Object) row.getObject(1)).isInstanceOf(SqlColumnType.BIGINT.getValueClass());
assertThat(metadata.getColumn(2).getType()).isEqualTo(SqlColumnType.BIGINT);
assertThat((Object) row.getObject(2)).isInstanceOf(SqlColumnType.BIGINT.getValueClass());
}
use of com.hazelcast.sql.SqlRowMetadata in project hazelcast by hazelcast.
the class SqlInsertWindowBoundsTest method test_windowBoundsSameTypeAsDescriptor_TINYINT.
@Test
public void test_windowBoundsSameTypeAsDescriptor_TINYINT() {
String name = randomName();
TestStreamSqlConnector.create(sqlService, name, asList("ts", "name"), asList(TINYINT, VARCHAR), row((byte) 1, "Alice"), row((byte) 10, null));
String interval = "1";
final SqlRow row = instance().getSql().execute(sql(name, interval)).iterator().next();
final SqlRowMetadata metadata = row.getMetadata();
assertThat(metadata.getColumn(0).getType()).isEqualTo(SqlColumnType.TINYINT);
assertThat((Object) row.getObject(0)).isInstanceOf(SqlColumnType.TINYINT.getValueClass());
assertThat(metadata.getColumn(1).getType()).isEqualTo(SqlColumnType.TINYINT);
assertThat((Object) row.getObject(1)).isInstanceOf(SqlColumnType.TINYINT.getValueClass());
assertThat(metadata.getColumn(2).getType()).isEqualTo(SqlColumnType.TINYINT);
assertThat((Object) row.getObject(2)).isInstanceOf(SqlColumnType.TINYINT.getValueClass());
}
Aggregations