Java Code Examples for io.prestosql.spi.predicate.TupleDomain#equals()
The following examples show how to use
io.prestosql.spi.predicate.TupleDomain#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccumuloMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { AccumuloTableHandle handle = (AccumuloTableHandle) table; TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new AccumuloTableHandle( handle.getSchema(), handle.getTable(), handle.getRowId(), newDomain, handle.isExternal(), handle.getSerializerClassName(), handle.getScanAuthorizations()); return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary())); }
Example 2
Source File: PinotMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { PinotTableHandle handle = (PinotTableHandle) table; TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new PinotTableHandle( handle.getSchemaName(), handle.getTableName(), newDomain, handle.getLimit(), handle.getQuery()); return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary())); }
Example 3
Source File: PinotQueryBuilder.java From presto with Apache License 2.0 | 6 votes |
public static Optional<String> getFilterClause(TupleDomain<ColumnHandle> tupleDomain, Optional<String> timePredicate, List<PinotColumnHandle> columnHandles) { ImmutableList.Builder<String> conjunctsBuilder = ImmutableList.builder(); timePredicate.ifPresent(predicate -> conjunctsBuilder.add(predicate)); if (!tupleDomain.equals(TupleDomain.all())) { for (PinotColumnHandle columnHandle : columnHandles) { Domain domain = tupleDomain.getDomains().get().get(columnHandle); if (domain != null) { conjunctsBuilder.add(toPredicate(columnHandle.getColumnName(), domain)); } } } List<String> conjuncts = conjunctsBuilder.build(); if (!conjuncts.isEmpty()) { return Optional.of(Joiner.on(" AND ").join(conjuncts)); } else { return Optional.empty(); } }
Example 4
Source File: KuduMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { KuduTableHandle handle = (KuduTableHandle) table; TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new KuduTableHandle( handle.getSchemaTableName(), handle.getTable(clientSession), newDomain, handle.getDesiredColumns(), handle.isDeleteHandle()); return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary())); }
Example 5
Source File: MongoMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { MongoTableHandle handle = (MongoTableHandle) table; TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new MongoTableHandle( handle.getSchemaTableName(), newDomain); return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary())); }
Example 6
Source File: LocalFileMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { LocalFileTableHandle handle = (LocalFileTableHandle) table; TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new LocalFileTableHandle( handle.getSchemaTableName(), handle.getTimestampColumn(), handle.getServerAddressColumn(), newDomain); return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary())); }
Example 7
Source File: RaptorMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) { RaptorTableHandle table = (RaptorTableHandle) handle; TupleDomain<RaptorColumnHandle> newDomain = constraint.getSummary().transform(RaptorColumnHandle.class::cast); if (newDomain.equals(table.getConstraint())) { return Optional.empty(); } return Optional.of(new ConstraintApplicationResult<>( new RaptorTableHandle(table.getSchemaName(), table.getTableName(), table.getTableId(), table.getDistributionId(), table.getDistributionName(), table.getBucketCount(), table.isOrganized(), table.getTransactionId(), newDomain.intersect(table.getConstraint()), table.getBucketAssignments(), table.isDelete()), constraint.getSummary())); }
Example 8
Source File: BigQueryMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter( ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) { log.debug("applyFilter(session=%s, handle=%s, summary=%s, predicate=%s, columns=%s)", session, handle, constraint.getSummary(), constraint.predicate(), constraint.getPredicateColumns()); BigQueryTableHandle bigQueryTableHandle = (BigQueryTableHandle) handle; TupleDomain<ColumnHandle> oldDomain = bigQueryTableHandle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } BigQueryTableHandle updatedHandle = bigQueryTableHandle.withConstraint(newDomain); return Optional.of(new ConstraintApplicationResult<>(updatedHandle, constraint.getSummary())); }
Example 9
Source File: IcebergMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) { IcebergTableHandle table = (IcebergTableHandle) handle; // TODO: Remove TupleDomain#simplify once Iceberg supports IN expression TupleDomain<IcebergColumnHandle> newDomain = convertTupleDomainTypes( constraint.getSummary() .transform(IcebergColumnHandle.class::cast) .simplify()) .intersect(table.getPredicate()); if (newDomain.equals(table.getPredicate())) { return Optional.empty(); } return Optional.of(new ConstraintApplicationResult<>( new IcebergTableHandle(table.getSchemaName(), table.getTableName(), table.getTableType(), table.getSnapshotId(), newDomain), constraint.getSummary())); }
Example 10
Source File: ThriftMetadata.java From presto with Apache License 2.0 | 6 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { ThriftTableHandle handle = (ThriftTableHandle) table; TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new ThriftTableHandle( handle.getSchemaName(), handle.getTableName(), newDomain, handle.getDesiredColumns()); return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary())); }
Example 11
Source File: HBaseMetadata.java From presto-hbase-connector with Apache License 2.0 | 5 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) { HBaseTableHandle tableHandle = (HBaseTableHandle) handle; TupleDomain<ColumnHandle> oldDomain = tableHandle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } tableHandle = new HBaseTableHandle(tableHandle.getSchemaTableName(), newDomain); return Optional.of(new ConstraintApplicationResult<>(tableHandle, constraint.getSummary())); }
Example 12
Source File: JmxMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) { Optional<Map<ColumnHandle, Domain>> domains = constraint.getSummary().getDomains(); if (domains.isEmpty()) { return Optional.empty(); } JmxTableHandle tableHandle = (JmxTableHandle) handle; Map<ColumnHandle, Domain> nodeDomains = new LinkedHashMap<>(); Map<ColumnHandle, Domain> otherDomains = new LinkedHashMap<>(); domains.get().forEach((column, domain) -> { JmxColumnHandle columnHandle = (JmxColumnHandle) column; if (columnHandle.getColumnName().equals(NODE_COLUMN_NAME)) { nodeDomains.put(column, domain); } else { otherDomains.put(column, domain); } }); TupleDomain<ColumnHandle> oldDomain = tableHandle.getNodeFilter(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(TupleDomain.withColumnDomains(nodeDomains)); if (oldDomain.equals(newDomain)) { return Optional.empty(); } JmxTableHandle newTableHandle = new JmxTableHandle(tableHandle.getTableName(), tableHandle.getObjectNames(), tableHandle.getColumnHandles(), tableHandle.isLiveData(), newDomain); return Optional.of(new ConstraintApplicationResult<>(newTableHandle, TupleDomain.withColumnDomains(otherDomains))); }
Example 13
Source File: TpchMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { TpchTableHandle handle = (TpchTableHandle) table; TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> predicate = TupleDomain.all(); TupleDomain<ColumnHandle> unenforcedConstraint = constraint.getSummary(); if (predicatePushdownEnabled && handle.getTableName().equals(TpchTable.ORDERS.getTableName())) { predicate = toTupleDomain(ImmutableMap.of( toColumnHandle(OrderColumn.ORDER_STATUS), filterValues(ORDER_STATUS_NULLABLE_VALUES, OrderColumn.ORDER_STATUS, constraint))); unenforcedConstraint = filterOutColumnFromPredicate(constraint.getSummary(), toColumnHandle(OrderColumn.ORDER_STATUS)); } else if (predicatePushdownEnabled && handle.getTableName().equals(TpchTable.PART.getTableName())) { predicate = toTupleDomain(ImmutableMap.of( toColumnHandle(PartColumn.CONTAINER), filterValues(PART_CONTAINER_NULLABLE_VALUES, PartColumn.CONTAINER, constraint), toColumnHandle(PartColumn.TYPE), filterValues(PART_TYPE_NULLABLE_VALUES, PartColumn.TYPE, constraint))); unenforcedConstraint = filterOutColumnFromPredicate(constraint.getSummary(), toColumnHandle(PartColumn.CONTAINER)); unenforcedConstraint = filterOutColumnFromPredicate(unenforcedConstraint, toColumnHandle(PartColumn.TYPE)); } if (oldDomain.equals(predicate)) { return Optional.empty(); } return Optional.of(new ConstraintApplicationResult<>( new TpchTableHandle( handle.getTableName(), handle.getScaleFactor(), oldDomain.intersect(predicate)), unenforcedConstraint)); }
Example 14
Source File: TestDomainTranslator.java From presto with Apache License 2.0 | 5 votes |
private void testSimpleComparison(Expression expression, Symbol symbol, Expression expectedRemainingExpression, Domain expectedDomain) { ExtractionResult result = fromPredicate(expression); assertEquals(result.getRemainingExpression(), expectedRemainingExpression); TupleDomain<Symbol> actual = result.getTupleDomain(); TupleDomain<Symbol> expected = withColumnDomains(ImmutableMap.of(symbol, expectedDomain)); if (!actual.equals(expected)) { fail(format("for comparison [%s] expected [%s] but found [%s]", expression.toString(), expected.toString(SESSION), actual.toString(SESSION))); } }
Example 15
Source File: TestTableLayoutResult.java From presto with Apache License 2.0 | 5 votes |
private void assertComputeEnforced(TupleDomain<ColumnHandle> predicate, TupleDomain<ColumnHandle> unenforced, TupleDomain<ColumnHandle> expectedEnforced) { TupleDomain<ColumnHandle> enforced = computeEnforced(predicate, unenforced); if (!enforced.equals(expectedEnforced)) { fail(format("expected [%s] but found [%s]", expectedEnforced.toString(SESSION), enforced.toString(SESSION))); } }
Example 16
Source File: SystemTablesMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) { SystemTableHandle table = (SystemTableHandle) handle; TupleDomain<ColumnHandle> oldDomain = table.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain) && constraint.predicate().isEmpty()) { return Optional.empty(); } SystemTable systemTable = checkAndGetTable(session, table); if (systemTable instanceof JdbcTable) { TupleDomain<ColumnHandle> filtered = ((JdbcTable) systemTable).applyFilter(session, new Constraint(newDomain, constraint.predicate(), constraint.getColumns())); newDomain = newDomain.intersect(filtered); } if (oldDomain.equals(newDomain)) { return Optional.empty(); } if (newDomain.isNone()) { // TODO (https://github.com/prestosql/presto/issues/3647) indicate the table scan is empty } table = new SystemTableHandle(table.getSchemaName(), table.getTableName(), newDomain); return Optional.of(new ConstraintApplicationResult<>(table, constraint.getSummary())); }
Example 17
Source File: JdbcMetadata.java From presto with Apache License 2.0 | 5 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { JdbcTableHandle handle = (JdbcTableHandle) table; if (handle.getGroupingSets().isPresent()) { // handle's aggregations are applied after constraint, so we cannot apply filter if aggregates is already set // TODO (https://github.com/prestosql/presto/issues/4112) allow filter pushdown after aggregation pushdown return Optional.empty(); } TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary()); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new JdbcTableHandle( handle.getSchemaTableName(), handle.getCatalogName(), handle.getSchemaName(), handle.getTableName(), newDomain, Optional.empty(), // groupBy handle.getLimit(), handle.getColumns()); return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary())); }
Example 18
Source File: ElasticsearchMetadata.java From presto with Apache License 2.0 | 4 votes |
@Override public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { ElasticsearchTableHandle handle = (ElasticsearchTableHandle) table; if (isPassthroughQuery(handle)) { // filter pushdown currently not supported for passthrough query return Optional.empty(); } Map<ColumnHandle, Domain> supported = new HashMap<>(); Map<ColumnHandle, Domain> unsupported = new HashMap<>(); if (constraint.getSummary().getDomains().isPresent()) { for (Map.Entry<ColumnHandle, Domain> entry : constraint.getSummary().getDomains().get().entrySet()) { ElasticsearchColumnHandle column = (ElasticsearchColumnHandle) entry.getKey(); if (column.isSupportsPredicates()) { supported.put(column, entry.getValue()); } else { unsupported.put(column, entry.getValue()); } } } TupleDomain<ColumnHandle> oldDomain = handle.getConstraint(); TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(TupleDomain.withColumnDomains(supported)); if (oldDomain.equals(newDomain)) { return Optional.empty(); } handle = new ElasticsearchTableHandle( handle.getType(), handle.getSchema(), handle.getIndex(), newDomain, handle.getQuery(), handle.getLimit()); return Optional.of(new ConstraintApplicationResult<>(handle, TupleDomain.withColumnDomains(unsupported))); }