Jibing-Li commented on code in PR #44726:
URL: https://github.com/apache/doris/pull/44726#discussion_r1870952167


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergExternalTable.java:
##########
@@ -90,4 +188,200 @@ public long fetchRowCount() {
     public Table getIcebergTable() {
         return IcebergUtils.getIcebergTable(getCatalog(), getDbName(), 
getName());
     }
+
+    @Override
+    public void beforeMTMVRefresh(MTMV mtmv) throws DdlException {
+        Env.getCurrentEnv().getRefreshManager()
+            .refreshTable(getCatalog().getName(), getDbName(), getName(), 
true);
+    }
+
+    @Override
+    public Map<String, PartitionItem> 
getAndCopyPartitionItems(Optional<MvccSnapshot> snapshot) {
+        return 
Maps.newHashMap(getPartitionInfoFromCache().getNameToPartitionItem());
+    }
+
+    private IcebergPartitionInfo getPartitionInfoFromCache() {
+        makeSureInitialized();
+        Optional<SchemaCacheValue> schemaCacheValue = getSchemaCacheValue();
+        if (!schemaCacheValue.isPresent()) {
+            return new IcebergPartitionInfo();
+        }
+        return ((IcebergSchemaCacheValue) 
schemaCacheValue.get()).getPartitionInfo();
+    }
+
+    @Override
+    public PartitionType getPartitionType(Optional<MvccSnapshot> snapshot) {
+        return isSupportedPartitionTable() ? PartitionType.RANGE : 
PartitionType.UNPARTITIONED;
+    }
+
+    @Override
+    public Set<String> getPartitionColumnNames(Optional<MvccSnapshot> 
snapshot) throws DdlException {
+        return 
getPartitionColumnsFromCache().stream().map(Column::getName).collect(Collectors.toSet());
+    }
+
+    @Override
+    public List<Column> getPartitionColumns(Optional<MvccSnapshot> snapshot) {
+        return getPartitionColumnsFromCache();
+    }
+
+    private List<Column> getPartitionColumnsFromCache() {
+        makeSureInitialized();
+        Optional<SchemaCacheValue> schemaCacheValue = getSchemaCacheValue();
+        return schemaCacheValue
+                .map(cacheValue -> ((IcebergSchemaCacheValue) 
cacheValue).getPartitionColumns())
+                .orElseGet(Lists::newArrayList);
+    }
+
+    @Override
+    public MTMVSnapshotIf getPartitionSnapshot(String partitionName, 
MTMVRefreshContext context,
+                                               Optional<MvccSnapshot> 
snapshot) throws AnalysisException {
+        IcebergPartition icebergPartition = 
getPartitionInfoFromCache().getNameToPartition().get(partitionName);
+        if (icebergPartition == null) {
+            throw new AnalysisException("can not find partition: " + 
partitionName);
+        }
+        return new MTMVVersionSnapshot(icebergPartition.getLastSnapshotId());
+    }
+
+    @Override
+    public MTMVSnapshotIf getTableSnapshot(MTMVRefreshContext context, 
Optional<MvccSnapshot> snapshot)
+            throws AnalysisException {
+        return new MTMVVersionSnapshot(getLatestSnapshotIdFromCache());
+    }
+
+    public long getLatestSnapshotIdFromCache() throws AnalysisException {
+        makeSureInitialized();
+        Optional<SchemaCacheValue> schemaCacheValue = getSchemaCacheValue();
+        if (!schemaCacheValue.isPresent()) {
+            throw new AnalysisException("not present");
+        }
+        return ((IcebergSchemaCacheValue) 
schemaCacheValue.get()).getSnapshotId();
+    }
+
+    @Override
+    public boolean isPartitionColumnAllowNull() {
+        return true;
+    }
+
+    public boolean isSupportedPartitionTable() {
+        // TODO: Support IDENTITY transform.
+        PartitionSpec spec = table.spec();
+        if (spec == null) {
+            return false;
+        }
+        if (spec.fields().size() != 1) {
+            return false;
+        }
+        String transformName = spec.fields().get(0).transform().toString();

Review Comment:
   The class Year is protected, so we can't call instanceof Year in our code.



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to