morrySnow commented on code in PR #63068:
URL: https://github.com/apache/doris/pull/63068#discussion_r3339399801
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergExternalCatalog.java:
##########
@@ -133,6 +141,90 @@ protected void initLocalObjectsImpl() {
metadataOps = ops;
}
+ @Override
+ protected List<String> listDatabaseNames() {
+ return super.listDatabaseNames();
+ }
+
+ protected List<String> listDatabaseNames(SessionContext ctx) {
+ if (isIcebergRestUserSessionPropertyEnabled()) {
+ return ((IcebergMetadataOps) metadataOps).listDatabaseNames(ctx);
+ }
+ return super.listDatabaseNames();
+ }
+
+ @Override
+ public List<String> getDbNames() {
Review Comment:
should impl in `IcebergRestExternalCatalog`
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergExternalCatalog.java:
##########
@@ -133,6 +141,90 @@ protected void initLocalObjectsImpl() {
metadataOps = ops;
}
+ @Override
+ protected List<String> listDatabaseNames() {
+ return super.listDatabaseNames();
+ }
+
+ protected List<String> listDatabaseNames(SessionContext ctx) {
+ if (isIcebergRestUserSessionPropertyEnabled()) {
+ return ((IcebergMetadataOps) metadataOps).listDatabaseNames(ctx);
+ }
+ return super.listDatabaseNames();
Review Comment:
why `super.listDatabaseNames()` not `listDatabaseNames()`?
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java:
##########
@@ -1641,7 +1664,58 @@ private static Optional<SchemaCacheValue>
loadTableSchemaCacheValue(ExternalTabl
}
}
}
- return Optional.of(new IcebergSchemaCacheValue(schema, tmpColumns));
+ return new IcebergSchemaCacheValue(schema, tmpColumns);
+ }
+
+ private static IcebergSnapshotCacheValue
loadSnapshotCacheValue(ExternalTable dorisTable, Table icebergTable) {
+ if (!(dorisTable instanceof MTMVRelatedTableIf)) {
+ throw new RuntimeException(String.format("Table %s.%s is not a
valid MTMV related table.",
+ dorisTable.getDbName(), dorisTable.getName()));
+ }
+ try {
+ MTMVRelatedTableIf table = (MTMVRelatedTableIf) dorisTable;
+ IcebergSnapshot latestIcebergSnapshot =
IcebergUtils.getLatestIcebergSnapshot(icebergTable);
+ IcebergPartitionInfo icebergPartitionInfo;
+ if (!table.isValidRelatedTable()) {
+ icebergPartitionInfo = IcebergPartitionInfo.empty();
+ } else {
+ icebergPartitionInfo =
IcebergUtils.loadPartitionInfo(dorisTable, icebergTable,
+ latestIcebergSnapshot.getSnapshotId(),
latestIcebergSnapshot.getSchemaId());
+ }
+ return new IcebergSnapshotCacheValue(icebergPartitionInfo,
latestIcebergSnapshot);
+ } catch (AnalysisException e) {
+ throw new RuntimeException(ExceptionUtils.getRootCauseMessage(e),
e);
+ }
+ }
+
+ private static Table loadIcebergTableWithSession(ExternalTable dorisTable)
{
+ IcebergExternalCatalog catalog = (IcebergExternalCatalog)
dorisTable.getCatalog();
+ IcebergMetadataOps ops = (IcebergMetadataOps) catalog.getMetadataOps();
+ return ops.loadTable(currentSessionContext(),
dorisTable.getRemoteDbName(), dorisTable.getRemoteName());
+ }
+
+ private static View loadIcebergViewWithSession(ExternalTable dorisTable) {
+ IcebergExternalCatalog catalog = (IcebergExternalCatalog)
dorisTable.getCatalog();
+ IcebergMetadataOps ops = (IcebergMetadataOps) catalog.getMetadataOps();
+ return (View) ops.loadView(currentSessionContext(),
dorisTable.getRemoteDbName(), dorisTable.getRemoteName());
+ }
+
+ private static boolean useSessionCatalog(ExternalTable dorisTable) {
+ if (!(dorisTable.getCatalog() instanceof IcebergExternalCatalog)) {
Review Comment:
why not IcebergRestExternalCatalog
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java:
##########
@@ -1641,7 +1664,58 @@ private static Optional<SchemaCacheValue>
loadTableSchemaCacheValue(ExternalTabl
}
}
}
- return Optional.of(new IcebergSchemaCacheValue(schema, tmpColumns));
+ return new IcebergSchemaCacheValue(schema, tmpColumns);
+ }
+
+ private static IcebergSnapshotCacheValue
loadSnapshotCacheValue(ExternalTable dorisTable, Table icebergTable) {
+ if (!(dorisTable instanceof MTMVRelatedTableIf)) {
+ throw new RuntimeException(String.format("Table %s.%s is not a
valid MTMV related table.",
+ dorisTable.getDbName(), dorisTable.getName()));
+ }
+ try {
+ MTMVRelatedTableIf table = (MTMVRelatedTableIf) dorisTable;
+ IcebergSnapshot latestIcebergSnapshot =
IcebergUtils.getLatestIcebergSnapshot(icebergTable);
+ IcebergPartitionInfo icebergPartitionInfo;
+ if (!table.isValidRelatedTable()) {
+ icebergPartitionInfo = IcebergPartitionInfo.empty();
+ } else {
+ icebergPartitionInfo =
IcebergUtils.loadPartitionInfo(dorisTable, icebergTable,
+ latestIcebergSnapshot.getSnapshotId(),
latestIcebergSnapshot.getSchemaId());
+ }
+ return new IcebergSnapshotCacheValue(icebergPartitionInfo,
latestIcebergSnapshot);
+ } catch (AnalysisException e) {
+ throw new RuntimeException(ExceptionUtils.getRootCauseMessage(e),
e);
+ }
+ }
+
+ private static Table loadIcebergTableWithSession(ExternalTable dorisTable)
{
+ IcebergExternalCatalog catalog = (IcebergExternalCatalog)
dorisTable.getCatalog();
+ IcebergMetadataOps ops = (IcebergMetadataOps) catalog.getMetadataOps();
+ return ops.loadTable(currentSessionContext(),
dorisTable.getRemoteDbName(), dorisTable.getRemoteName());
+ }
+
+ private static View loadIcebergViewWithSession(ExternalTable dorisTable) {
+ IcebergExternalCatalog catalog = (IcebergExternalCatalog)
dorisTable.getCatalog();
+ IcebergMetadataOps ops = (IcebergMetadataOps) catalog.getMetadataOps();
+ return (View) ops.loadView(currentSessionContext(),
dorisTable.getRemoteDbName(), dorisTable.getRemoteName());
+ }
+
+ private static boolean useSessionCatalog(ExternalTable dorisTable) {
+ if (!(dorisTable.getCatalog() instanceof IcebergExternalCatalog)) {
+ return false;
+ }
+ SessionContext sessionContext = currentSessionContext();
+ return sessionContext.hasDelegatedCredential()
+ && ((IcebergExternalCatalog)
dorisTable.getCatalog()).isIcebergRestUserSessionEnabled();
+ }
+
+ private static SessionContext currentSessionContext() {
+ ConnectContext context = ConnectContext.get();
+ if (context == null) {
+ return SessionContext.empty();
+ }
+ SessionContext sessionContext = context.getSessionContext();
+ return sessionContext == null ? SessionContext.empty() :
sessionContext;
Review Comment:
see this code block more than once in different files
--
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]