Split split = getLocalQuerySplit(session, layouts.get(0).getLayout().getHandle());
@Override public List<TableLayoutResult> getLayouts(Session session, TableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { if (constraint.getSummary().isNone()) { return ImmutableList.of(); } ConnectorId connectorId = table.getConnectorId(); ConnectorTableHandle connectorTable = table.getConnectorHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, connectorId); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId); ConnectorTransactionHandle transaction = catalogMetadata.getTransactionHandleFor(connectorId); ConnectorSession connectorSession = session.toConnectorSession(connectorId); List<ConnectorTableLayoutResult> layouts = metadata.getTableLayouts(connectorSession, connectorTable, constraint, desiredColumns); return layouts.stream() .map(layout -> new TableLayoutResult(fromConnectorLayout(connectorId, transaction, layout.getTableLayout()), layout.getUnenforcedConstraint())) .collect(toImmutableList()); }
.filter(layout -> layout.hasAllOutputs(node)) .collect(toList()); checkState(!layouts.isEmpty(), "No usable layouts for %s", node); if (layouts.stream().anyMatch(layout -> layout.getLayout().getPredicate().isNone())) { return ImmutableList.of(new ValuesNode(idAllocator.getNextId(), node.getOutputSymbols(), ImmutableList.of())); node.getOutputSymbols(), node.getAssignments(), Optional.of(layout.getLayout().getHandle()), layout.getLayout().getPredicate(), computeEnforced(newDomain, layout.getUnenforcedConstraint())); domainTranslator.toPredicate(layout.getUnenforcedConstraint().transform(assignments::get)), filterNonDeterministicConjuncts(predicate), decomposedPredicate.getRemainingExpression());
scan.getOutputSymbols(), scan.getAssignments(), Optional.of(layoutResult.getLayout().getHandle()), layoutResult.getLayout().getPredicate(), computeEnforced(originalEnforcedConstraint, layoutResult.getUnenforcedConstraint()));
node.getOutputSymbols(), node.getAssignments(), Optional.of(layout.getLayout().getHandle()), simplifiedConstraint.intersect(layout.getLayout().getPredicate()), Optional.ofNullable(node.getOriginalConstraint()).orElse(predicate)); Expression resultingPredicate = combineConjuncts( decomposedPredicate.getRemainingExpression(), DomainTranslator.toPredicate(layout.getUnenforcedConstraint().transform(assignments::get)));
private void assertComputeEnforcedFails(TupleDomain<ColumnHandle> predicate, TupleDomain<ColumnHandle> unenforced) { try { TupleDomain<ColumnHandle> enforced = computeEnforced(predicate, unenforced); fail(String.format("expected IllegalArgumentException but found [%s]", enforced.toString(SESSION))); } catch (IllegalArgumentException e) { // do nothing } }
node.getOutputSymbols(), node.getAssignments(), Optional.of(layout.getLayout().getHandle()), simplifiedConstraint.intersect(layout.getLayout().getPredicate()), Optional.ofNullable(node.getOriginalConstraint()).orElse(predicate)); DomainTranslator.toPredicate(layout.getUnenforcedConstraint().transform(assignments::get)), stripDeterministicConjuncts(predicate), decomposedPredicate.getRemainingExpression());
private void assertComputeEnforced(TupleDomain<ColumnHandle> predicate, TupleDomain<ColumnHandle> unenforced, TupleDomain<ColumnHandle> expectedEnforced) { TupleDomain<ColumnHandle> enforced = computeEnforced(predicate, unenforced); if (!enforced.equals(expectedEnforced)) { fail(String.format("expected [%s] but found [%s]", expectedEnforced.toString(SESSION), enforced.toString(SESSION))); } } }
try (SplitSource splitSource = splitManager.getSplits(session, layouts.get(0).getLayout().getHandle(), UNGROUPED_SCHEDULING)) { while (!Thread.currentThread().isInterrupted()) { SplitBatch splitBatch = getFutureValue(splitSource.getNextBatch(NOT_PARTITIONED, Lifespan.taskWide(), 1000));
@Override public List<TableLayoutResult> getLayouts(Session session, TableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { if (constraint.getSummary().isNone()) { return ImmutableList.of(); } TupleDomain<ColumnHandle> summary = constraint.getSummary(); String connectorId = table.getConnectorId(); ConnectorTableHandle connectorTable = table.getConnectorHandle(); Predicate<Map<ColumnHandle, NullableValue>> predicate = constraint.predicate(); ConnectorEntry entry = getConnectorMetadata(connectorId); ConnectorMetadata metadata = entry.getMetadata(session); ConnectorTransactionHandle transaction = entry.getTransactionHandle(session); ConnectorSession connectorSession = session.toConnectorSession(entry.getCatalog()); List<ConnectorTableLayoutResult> layouts = metadata.getTableLayouts(connectorSession, connectorTable, new Constraint<>(summary, predicate::test), desiredColumns); return layouts.stream() .map(layout -> new TableLayoutResult(fromConnectorLayout(connectorId, transaction, layout.getTableLayout()), layout.getUnenforcedConstraint())) .collect(toImmutableList()); }
List<TableLayoutResult> layouts = metadata.getLayouts(session, tableScan.getTable(), Constraint.alwaysTrue(), Optional.empty()); if (layouts.size() == 1) { layout = Iterables.getOnlyElement(layouts).getLayout();
private Object getHiveTableProperty(String tableName, Function<HiveTableLayoutHandle, Object> propertyGetter) { Session session = getSession(); Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata(); return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl()) .readOnly() .execute(session, transactionSession -> { Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(catalog, TPCH_SCHEMA, tableName)); assertTrue(tableHandle.isPresent()); List<TableLayoutResult> layouts = metadata.getLayouts(transactionSession, tableHandle.get(), Constraint.alwaysTrue(), Optional.empty()); TableLayout layout = getOnlyElement(layouts).getLayout(); return propertyGetter.apply((HiveTableLayoutHandle) layout.getHandle().getConnectorHandle()); }); }
Split split = getLocalQuerySplit(session, layouts.get(0).getLayout().getHandle());
Split split = getLocalQuerySplit(session, layouts.get(0).getLayout().getHandle());
List<TableLayoutResult> layouts = metadata.getLayouts(session, tableScan.getTable(), Constraint.<ColumnHandle>alwaysTrue(), Optional.empty()); if (layouts.size() == 1) { layout = Iterables.getOnlyElement(layouts).getLayout();
TableLayout layout = Iterables.getOnlyElement(layouts).getLayout(); layout.getDiscretePredicates().ifPresent(predicates -> { int partitionNumber = 1;
Optional.of(ImmutableSet.copyOf(scan.getAssignments().values()))); verify(layouts.size() == 1, "Expected exactly one layout for delete"); TableLayoutHandle layout = Iterables.getOnlyElement(layouts).getLayout().getHandle();
throw new SemanticException(NOT_SUPPORTED, showPartitions, "Table does not have exactly one layout: %s", table); TableLayout layout = getOnlyElement(layouts).getLayout(); if (!layout.getDiscretePredicates().isPresent()) { throw new SemanticException(NOT_SUPPORTED, showPartitions, "Table does not have partition columns: %s", table);
private List<HivePartition> getPartitions(String tableName) { Session session = getSession(); Metadata metadata = ((DistributedQueryRunner) queryRunner).getCoordinator().getMetadata(); return transaction(queryRunner.getTransactionManager()) .readOnly() .execute(session, transactionSession -> { Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(HIVE_CATALOG, TPCH_SCHEMA, tableName)); assertTrue(tableHandle.isPresent()); List<TableLayoutResult> layouts = metadata.getLayouts(transactionSession, tableHandle.get(), Constraint.alwaysTrue(), Optional.empty()); TableLayout layout = Iterables.getOnlyElement(layouts).getLayout(); return ((HiveTableLayoutHandle) layout.getHandle().getConnectorHandle()).getPartitions().get(); }); }