public synchronized MaterializedResult build() { return new MaterializedResult(rows.build(), types); } }
@Override public MaterializedResult build(Map<String, String> setSessionProperties, Set<String> resetSessionProperties) { checkState(types.get() != null, "never received types for the query"); return new MaterializedResult( rows.build(), types.get(), setSessionProperties, resetSessionProperties, updateType.get(), updateCount.get()); } }
/** * Converts this {@link MaterializedResult} to a new one, representing the data using the same type domain as returned by {@code TestingPrestoClient}. */ public MaterializedResult toTestTypes() { return new MaterializedResult( rows.stream() .map(MaterializedResult::convertToTestTypes) .collect(toImmutableList()), types, setSessionProperties, resetSessionProperties, updateType, updateCount); }
public MaterializedResult execute(Session session, @Language("SQL") String sql, List<? extends Type> resultTypes) { MaterializedResult materializedRows = new MaterializedResult( handle.setSqlParser(new RawSqlParser()) .setTemplateEngine((template, context) -> template) .createQuery(sql) .map(rowMapper(resultTypes)) .list(), resultTypes); return materializedRows; }
private MaterializedResult readTable( Transaction transaction, ConnectorTableHandle tableHandle, List<ColumnHandle> columnHandles, ConnectorSession session, TupleDomain<ColumnHandle> tupleDomain, OptionalInt expectedSplitCount, Optional<HiveStorageFormat> expectedStorageFormat) throws Exception { List<ConnectorTableLayoutResult> tableLayoutResults = transaction.getMetadata().getTableLayouts( session, tableHandle, new Constraint<>(tupleDomain), Optional.empty()); ConnectorTableLayoutHandle layoutHandle = getOnlyElement(tableLayoutResults).getTableLayout().getHandle(); List<ConnectorSplit> splits = getAllSplits(splitManager.getSplits(transaction.getTransactionHandle(), session, layoutHandle, UNGROUPED_SCHEDULING)); if (expectedSplitCount.isPresent()) { assertEquals(splits.size(), expectedSplitCount.getAsInt()); } ImmutableList.Builder<MaterializedRow> allRows = ImmutableList.builder(); for (ConnectorSplit split : splits) { try (ConnectorPageSource pageSource = pageSourceProvider.createPageSource(transaction.getTransactionHandle(), session, split, columnHandles)) { expectedStorageFormat.ifPresent(format -> assertPageSourceType(pageSource, format)); MaterializedResult result = materializeSourceDataStream(session, pageSource, getTypes(columnHandles)); allRows.addAll(result.getMaterializedRows()); } } return new MaterializedResult(allRows.build(), getTypes(columnHandles)); }
public synchronized MaterializedResult build() { return new MaterializedResult(rows.build(), types); } }
@Override public MaterializedResult build(Map<String, String> setSessionProperties, Set<String> resetSessionProperties) { checkState(types.get() != null, "never received types for the query"); return new MaterializedResult( rows.build(), types.get(), setSessionProperties, resetSessionProperties, updateType.get(), updateCount.get()); } }
public MaterializedResult toTimeZone(DateTimeZone oldTimeZone, DateTimeZone newTimeZone) { ImmutableList.Builder<MaterializedRow> jdbcRows = ImmutableList.builder(); for (MaterializedRow row : rows) { jdbcRows.add(toTimeZone(row, oldTimeZone, newTimeZone)); } return new MaterializedResult(jdbcRows.build(), types); }
public MaterializedResult toJdbcTypes() { ImmutableList.Builder<MaterializedRow> jdbcRows = ImmutableList.builder(); for (MaterializedRow row : rows) { jdbcRows.add(convertToJdbcTypes(row)); } return new MaterializedResult( jdbcRows.build(), types, setSessionProperties, resetSessionProperties, updateType, updateCount); }
public MaterializedResult execute(Session session, @Language("SQL") String sql, List<? extends Type> resultTypes) { MaterializedResult materializedRows = new MaterializedResult( handle.setSqlParser(new RawSqlParser()) .setTemplateEngine((template, context) -> template) .createQuery(sql) .map(rowMapper(resultTypes)) .list(), resultTypes); return materializedRows; }
private MaterializedResult readTable( ConnectorTableHandle tableHandle, List<ColumnHandle> columnHandles, ConnectorSession session, TupleDomain<ColumnHandle> tupleDomain, OptionalInt expectedSplitCount, Optional<HiveStorageFormat> expectedStorageFormat) throws Exception { ConnectorMetadata metadata = newMetadata(); ConnectorTransactionHandle transactionHandle = newTransaction(); List<ConnectorTableLayoutResult> tableLayoutResults = metadata.getTableLayouts(session, tableHandle, new Constraint<>(tupleDomain, bindings -> true), Optional.empty()); ConnectorTableLayoutHandle layoutHandle = getOnlyElement(tableLayoutResults).getTableLayout().getHandle(); List<ConnectorSplit> splits = getAllSplits(splitManager.getSplits(transactionHandle, session, layoutHandle)); if (expectedSplitCount.isPresent()) { assertEquals(splits.size(), expectedSplitCount.getAsInt()); } ImmutableList.Builder<MaterializedRow> allRows = ImmutableList.builder(); for (ConnectorSplit split : splits) { try (ConnectorPageSource pageSource = pageSourceProvider.createPageSource(transactionHandle, session, split, columnHandles)) { if (expectedStorageFormat.isPresent()) { assertPageSourceType(pageSource, expectedStorageFormat.get()); } MaterializedResult result = materializeSourceDataStream(session, pageSource, getTypes(columnHandles)); allRows.addAll(result.getMaterializedRows()); } } return new MaterializedResult(allRows.build(), getTypes(columnHandles)); }
private MaterializedResult readTable( Transaction transaction, ConnectorTableHandle tableHandle, List<ColumnHandle> columnHandles, ConnectorSession session, TupleDomain<ColumnHandle> tupleDomain, OptionalInt expectedSplitCount, Optional<HiveStorageFormat> expectedStorageFormat) throws Exception { List<ConnectorTableLayoutResult> tableLayoutResults = transaction.getMetadata().getTableLayouts( session, tableHandle, new Constraint<>(tupleDomain), Optional.empty()); ConnectorTableLayoutHandle layoutHandle = getOnlyElement(tableLayoutResults).getTableLayout().getHandle(); List<ConnectorSplit> splits = getAllSplits(splitManager.getSplits(transaction.getTransactionHandle(), session, layoutHandle, UNGROUPED_SCHEDULING)); if (expectedSplitCount.isPresent()) { assertEquals(splits.size(), expectedSplitCount.getAsInt()); } ImmutableList.Builder<MaterializedRow> allRows = ImmutableList.builder(); for (ConnectorSplit split : splits) { try (ConnectorPageSource pageSource = pageSourceProvider.createPageSource(transaction.getTransactionHandle(), session, split, columnHandles)) { expectedStorageFormat.ifPresent(format -> assertPageSourceType(pageSource, format)); MaterializedResult result = materializeSourceDataStream(session, pageSource, getTypes(columnHandles)); allRows.addAll(result.getMaterializedRows()); } } return new MaterializedResult(allRows.build(), getTypes(columnHandles)); }
.build(); private static final MaterializedResult CREATE_TABLE_PARTITIONED_DATA = new MaterializedResult( CREATE_TABLE_DATA.getMaterializedRows().stream() .map(row -> new MaterializedRow(row.getPrecision(), newArrayList(concat(row.getFields(), ImmutableList.of("2015-07-0" + row.getField(0))))))