Gabriel39 commented on code in PR #71365:
URL: https://github.com/apache/doris/pull/71365#discussion_r4786912508
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergPartitionUtils.java:
##########
@@ -940,38 +940,38 @@ static List<ConnectorPartitionInfo> listPartitions(Table
table, long pinnedSnaps
return partitions;
}
- /**
- * Port of master {@code IcebergExternalTable.isValidRelatedTable}: an
iceberg table is a valid MTMV related
- * table iff EVERY partition spec has exactly one field whose transform is
{@code year}/{@code month}/{@code
- * day}/{@code hour}, and the partition source column is stable across
partition evolution (a single distinct
- * source column over all specs). Failure -> the connector reports an
UNPARTITIONED view.
- */
+ /** Validates the current snapshot while retaining the original fast path
for time-transform-only tables. */
static boolean isValidRelatedTable(Table table) {
- Set<String> allFields = new HashSet<>();
- for (PartitionSpec spec : table.specs().values()) {
- if (spec == null) {
- return false;
- }
- List<PartitionField> fields = spec.fields();
- if (fields.size() != 1) {
- return false;
- }
- PartitionField partitionField = fields.get(0);
- Type sourceType =
spec.schema().findType(partitionField.sourceId());
- // Historical void partition fields can outlive their dropped
source column.
- if (sourceType == null || sourceType.typeId() ==
Type.TypeID.TIMESTAMP_NANO) {
- // Calendar boundaries and the NULL sentinel can exceed
TIMESTAMP_NS's domain.
- // Leave pruning to Iceberg instead of building invalid Doris
RANGE boundaries.
- return false;
- }
- String transformName = partitionField.transform().toString();
- if (!YEAR.equals(transformName) && !MONTH.equals(transformName)
- && !DAY.equals(transformName) &&
!HOUR.equals(transformName)) {
- return false;
- }
-
allFields.add(table.schema().findColumnName(partitionField.sourceId()));
+ return IcebergMvPartitionSnapshot.supportsAllSpecs(table)
+ || IcebergMvPartitionSnapshot.qualifies(table, -1);
+ }
+
+ private static ConnectorMvccPartitionView
buildEvolvedMvccPartitionView(Table table, long pinnedSnapshotId) {
+ IcebergMvPartitionSnapshot snapshot =
IcebergMvPartitionSnapshot.load(table, pinnedSnapshotId);
+ if (!snapshot.isSupported()) {
+ LOG.debug("Iceberg table {} is not eligible for a partitioned MV:
{}",
+ table.name(), snapshot.getUnsupportedReason());
+ return ConnectorMvccPartitionView.unpartitioned();
+ }
+ Map<String, RangeBuild> ranges = new java.util.TreeMap<>();
+ for (IcebergMvPartitionSnapshot.Partition partition :
snapshot.getPartitions()) {
+ ranges.put(partition.getName(), buildRange(partition.getName(),
partition.getValue(),
+ partition.getRangeTransform(), snapshot.getSourceType(),
snapshot.getUpdateTimeMicros(),
+ snapshot.getSnapshotId()));
}
- return allFields.size() == 1;
+ Set<String> survivors = new LinkedHashSet<>(ranges.keySet());
+ mergeOverlapPartitions(new ArrayList<>(ranges.values()), survivors);
Review Comment:
Fixed in daaf33c9433c8a322c86831cb2e66f6704c90413. Timestamp NULL merging
now uses the same one-microsecond interval as the FE successor; DATE keeps its
one-day interval. Real Iceberg tests cover NULL beside year-zero noon and
midnight hours for both timestamp types. The native adapter already uses actual
FE ranges and now has matching parity coverage in #71373. The SQL boundary case
is identical in both PRs.
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergPartitionUtils.java:
##########
@@ -940,38 +940,38 @@ static List<ConnectorPartitionInfo> listPartitions(Table
table, long pinnedSnaps
return partitions;
}
- /**
- * Port of master {@code IcebergExternalTable.isValidRelatedTable}: an
iceberg table is a valid MTMV related
- * table iff EVERY partition spec has exactly one field whose transform is
{@code year}/{@code month}/{@code
- * day}/{@code hour}, and the partition source column is stable across
partition evolution (a single distinct
- * source column over all specs). Failure -> the connector reports an
UNPARTITIONED view.
- */
+ /** Validates the current snapshot while retaining the original fast path
for time-transform-only tables. */
static boolean isValidRelatedTable(Table table) {
- Set<String> allFields = new HashSet<>();
- for (PartitionSpec spec : table.specs().values()) {
- if (spec == null) {
- return false;
- }
- List<PartitionField> fields = spec.fields();
- if (fields.size() != 1) {
- return false;
- }
- PartitionField partitionField = fields.get(0);
- Type sourceType =
spec.schema().findType(partitionField.sourceId());
- // Historical void partition fields can outlive their dropped
source column.
- if (sourceType == null || sourceType.typeId() ==
Type.TypeID.TIMESTAMP_NANO) {
- // Calendar boundaries and the NULL sentinel can exceed
TIMESTAMP_NS's domain.
- // Leave pruning to Iceberg instead of building invalid Doris
RANGE boundaries.
- return false;
- }
- String transformName = partitionField.transform().toString();
- if (!YEAR.equals(transformName) && !MONTH.equals(transformName)
- && !DAY.equals(transformName) &&
!HOUR.equals(transformName)) {
- return false;
- }
-
allFields.add(table.schema().findColumnName(partitionField.sourceId()));
+ return IcebergMvPartitionSnapshot.supportsAllSpecs(table)
+ || IcebergMvPartitionSnapshot.qualifies(table, -1);
+ }
+
+ private static ConnectorMvccPartitionView
buildEvolvedMvccPartitionView(Table table, long pinnedSnapshotId) {
+ IcebergMvPartitionSnapshot snapshot =
IcebergMvPartitionSnapshot.load(table, pinnedSnapshotId);
+ if (!snapshot.isSupported()) {
+ LOG.debug("Iceberg table {} is not eligible for a partitioned MV:
{}",
+ table.name(), snapshot.getUnsupportedReason());
+ return ConnectorMvccPartitionView.unpartitioned();
+ }
+ Map<String, RangeBuild> ranges = new java.util.TreeMap<>();
+ for (IcebergMvPartitionSnapshot.Partition partition :
snapshot.getPartitions()) {
+ ranges.put(partition.getName(), buildRange(partition.getName(),
partition.getValue(),
Review Comment:
Fixed in daaf33c9433c8a322c86831cb2e66f6704c90413 and synchronized to #71373
(5f900bb66cd317d131561ec9e98fcb833d93535f). Exclusive calendar endpoints beyond
year 9999 use MAXVALUE, and FE conversion recognizes it only for temporal
columns, preserving literal STRING bounds. Tests exercise DATE identity at
9999-12-31 through real manifests and actual FE range construction. The
pre-existing generic date_trunc/MAXVALUE rollup restriction remains unchanged.
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java:
##########
@@ -516,7 +515,11 @@ private void syncPartitionsIfNeeded(ConnectContext ctx,
List<TableIf> tableIfs)
if (mtmv.getMvPartitionInfo().getPartitionType() !=
MTMVPartitionType.SELF_MANAGE) {
Set<MTMVRelatedTableIf> pctTables =
mtmv.getMvPartitionInfo().getPctTables();
for (MTMVRelatedTableIf pctTable : pctTables) {
- if (!pctTable.isValidRelatedTable()) {
+ Optional<MvccSnapshot> snapshot = pctTable instanceof
MvccTable
+ ? Optional.ofNullable(snapshots.get(new
MvccTableInfo((MvccTable) pctTable)))
+ : Optional.empty();
+ // Qualification must describe the same files that
partition alignment and execution read.
+ if (!pctTable.isValidRelatedTable(snapshot)) {
Review Comment:
Fixed in daaf33c9433c8a322c86831cb2e66f6704c90413. Both descriptor
generators now pass lastResult.resolveSnapshot(table) to the new explicit
getPctColPos overload; tests check the captured columns with and without
partition_sync_limit. Local review also found schema reanalysis could replace
the task context and abandon its metadata-resource owner. Both PRs now restore
the caller and close temporary contexts on success and failure, preserving the
native adapter's pre-lock pin installation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]