Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
}

table = new InformationSchemaTableHandle(table.getCatalogName(), table.getTable(), prefixes, table.getLimit());
return Optional.of(new ConstraintApplicationResult<>(table, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(table, constraint.getSummary(), constraint.getExpression(), false));
}

public static Set<QualifiedTablePrefix> defaultPrefixes(String catalogName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
// TODO (https://github.com/trinodb/trino/issues/3647) indicate the table scan is empty
}
table = new SystemTableHandle(table.getSchemaName(), table.getTableName(), newDomain);
return Optional.of(new ConstraintApplicationResult<>(table, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(table, constraint.getSummary(), constraint.getExpression(), false));
}

private Constraint effectiveConstraint(TupleDomain<ColumnHandle> oldDomain, Constraint newConstraint, TupleDomain<ColumnHandle> effectiveDomain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ private ApplyFilter getMockApplyFilter(Set<ColumnHandle> pushdownColumns)
new MockConnectorTableHandle(handle.getTableName(), newDomain, Optional.empty()),
constraint.getSummary()
.filter((columnHandle, domain) -> !pushdownColumns.contains(columnHandle)),
constraint.getExpression(),
false));
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ public static MockConnectorFactory createMockFactory()
builder
.withApplyFilter((session, tableHandle, constraint) -> {
if (tableHandle.equals(CONNECTOR_PARTITIONED_TABLE_HANDLE_TO_UNPARTITIONED)) {
return Optional.of(new ConstraintApplicationResult<>(CONNECTOR_UNPARTITIONED_TABLE_HANDLE, TupleDomain.all(), false));
return Optional.of(new ConstraintApplicationResult<>(CONNECTOR_UNPARTITIONED_TABLE_HANDLE, TupleDomain.all(), constraint.getExpression(), false));
}
if (tableHandle.equals(CONNECTOR_PARTITIONED_TABLE_HANDLE)) {
return Optional.of(new ConstraintApplicationResult<>(CONNECTOR_PARTITIONED_TABLE_HANDLE, TupleDomain.all(), false));
return Optional.of(new ConstraintApplicationResult<>(CONNECTOR_PARTITIONED_TABLE_HANDLE, TupleDomain.all(), constraint.getExpression(), false));
}
return Optional.empty();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private MockConnectorFactory.ApplyFilter applyFilter()
new MockConnectorTableHandle(handle.getTableName(), TupleDomain.none(), Optional.empty()),
constraint.getSummary()
.filter((ch, domain) -> !shouldPushdown.test(ch)),
constraint.getExpression(),
false));
}

Expand All @@ -160,6 +161,7 @@ private MockConnectorFactory.ApplyFilter applyFilter()
new MockConnectorTableHandle(handle.getTableName(), newDomain, Optional.empty()),
constraint.getSummary()
.filter((columnHandle, domain) -> !shouldPushdown.test(columnHandle)),
constraint.getExpression(),
false));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class ConstraintApplicationResult<T>
/**
* @param precalculateStatistics Indicates whether engine should consider calculating statistics based on the plan before pushdown,
* as the connector may be unable to provide good table statistics for {@code handle}.
*
* @deprecated Use {@link #ConstraintApplicationResult(Object, TupleDomain, ConnectorExpression, boolean)}.
*/
@Deprecated
public ConstraintApplicationResult(T handle, TupleDomain<ColumnHandle> remainingFilter, boolean precalculateStatistics)
{
this(handle, remainingFilter, Optional.empty(), precalculateStatistics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
handle.getSerializerClassName(),
handle.getScanAuthorizations());

return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), constraint.getExpression(), false));
}

private void checkNoRollback()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
newStartTimeDomain,
newEndTimeDomain);

return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), constraint.getExpression(), false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary());
List<ParameterizedExpression> newConstraintExpressions;
TupleDomain<ColumnHandle> remainingFilter;
Optional<ConnectorExpression> remainingExpression;
ConnectorExpression remainingExpression;
if (newDomain.isNone()) {
newConstraintExpressions = ImmutableList.of();
remainingFilter = TupleDomain.all();
remainingExpression = Optional.of(Constant.TRUE);
remainingExpression = Constant.TRUE;
}
else {
Map<ColumnHandle, Domain> domains = newDomain.getDomains().orElseThrow();
Expand Down Expand Up @@ -225,11 +225,11 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
.addAll(handle.getConstraintExpressions())
.addAll(newExpressions)
.build().asList();
remainingExpression = Optional.of(and(remainingExpressions));
remainingExpression = and(remainingExpressions);
}
else {
newConstraintExpressions = ImmutableList.of();
remainingExpression = Optional.empty();
remainingExpression = constraint.getExpression();
}
}

Expand All @@ -250,10 +250,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
handle.getAuthorization(),
handle.getUpdateAssignments());

return Optional.of(
remainingExpression.isPresent()
? new ConstraintApplicationResult<>(handle, remainingFilter, remainingExpression.get(), precalculateStatisticsForPushdown)
: new ConstraintApplicationResult<>(handle, remainingFilter, precalculateStatisticsForPushdown));
return Optional.of(new ConstraintApplicationResult<>(handle, remainingFilter, remainingExpression, precalculateStatisticsForPushdown));
}

private JdbcTableHandle flushAttributesAsQuery(ConnectorSession session, JdbcTableHandle handle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(

BigQueryTableHandle updatedHandle = bigQueryTableHandle.withConstraint(newDomain);

return Optional.of(new ConstraintApplicationResult<>(updatedHandle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(updatedHandle, constraint.getSummary(), constraint.getExpression(), false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
// TODO this should probably be AND-ed with handle.getClusteringKeyPredicates()
clusteringKeyPredicates)),
unenforcedConstraint,
constraint.getExpression(),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2753,6 +2753,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
return Optional.of(new ConstraintApplicationResult<>(
newHandle,
newUnenforcedConstraint.transformKeys(ColumnHandle.class::cast),
constraint.getExpression(),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2995,7 +2995,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
unenforcedConstraint = partitionResult.getEffectivePredicate().filter((column, domain) -> !partitionColumns.contains(column));
}

return Optional.of(new ConstraintApplicationResult<>(newHandle, unenforcedConstraint, false));
return Optional.of(new ConstraintApplicationResult<>(newHandle, unenforcedConstraint, constraint.getExpression(), false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
return Optional.of(new ConstraintApplicationResult<>(
newHudiTableHandle,
newHudiTableHandle.getRegularPredicates().transformKeys(ColumnHandle.class::cast),
constraint.getExpression(),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C

JmxTableHandle newTableHandle = new JmxTableHandle(tableHandle.getTableName(), tableHandle.getObjectNames(), tableHandle.getColumnHandles(), tableHandle.isLiveData(), newDomain);

return Optional.of(new ConstraintApplicationResult<>(newTableHandle, TupleDomain.withColumnDomains(otherDomains), false));
return Optional.of(new ConstraintApplicationResult<>(newTableHandle, TupleDomain.withColumnDomains(otherDomains), constraint.getExpression(), false));
}

private static Type getColumnType(MBeanAttributeInfo attribute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
handle.getColumns(),
newDomain);

return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), constraint.getExpression(), false));
}

private KafkaTopicDescription getRequiredTopicDescription(ConnectorSession session, SchemaTableName schemaTableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
handle.getBucketCount(),
handle.getLimit());

return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), constraint.getExpression(), false));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
handle.getServerAddressColumn(),
newDomain);

return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), constraint.getExpression(), false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
handle.getProjectedColumns(),
handle.getLimit());

return Optional.of(new ConstraintApplicationResult<>(handle, remainingFilter, false));
return Optional.of(new ConstraintApplicationResult<>(handle, remainingFilter, constraint.getExpression(), false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ else if (isFilterPushdownUnsupported(entry.getValue())) {
newDomain,
handle.getLimit(),
handle.getQuery());
return Optional.of(new ConstraintApplicationResult<>(handle, remainingFilter, false));
return Optional.of(new ConstraintApplicationResult<>(handle, remainingFilter, constraint.getExpression(), false));
}

// IS NULL and IS NOT NULL are handled differently in Pinot, pushing down would lead to inconsistent results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
{
PrometheusTableHandle tableHandle = ((PrometheusTableHandle) handle)
.withPredicate(constraint.getSummary());
return Optional.of(new ConstraintApplicationResult<>(tableHandle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(tableHandle, constraint.getSummary(), constraint.getExpression(), false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
newDomain.intersect(table.getConstraint()),
table.getBucketAssignments()),
constraint.getSummary(),
constraint.getExpression(),
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ else if (getUserDefinedKeySize(session, handle) > 1) {
handle.getKeyName(),
newDomain);

return Optional.of(new ConstraintApplicationResult<>(handle, remainingFilter, false));
return Optional.of(new ConstraintApplicationResult<>(handle, remainingFilter, constraint.getExpression(), false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
newDomain,
handle.getDesiredColumns());

return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), false));
return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary(), constraint.getExpression(), false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ else if (predicatePushdownEnabled && handle.getTableName().equals(TpchTable.PART
handle.getScaleFactor(),
oldDomain.intersect(predicate)),
unenforcedConstraint,
constraint.getExpression(),
false));
}

Expand Down