github-actions[bot] commented on code in PR #64119:
URL: https://github.com/apache/doris/pull/64119#discussion_r3370731613
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalCatalog.java:
##########
@@ -227,12 +240,111 @@ protected void initLocalObjectsImpl() {
boolean enableNamespaceSchema = Boolean.parseBoolean(
props.getOrDefault(MCProperties.ENABLE_NAMESPACE_SCHEMA,
MCProperties.DEFAULT_ENABLE_NAMESPACE_SCHEMA));
mcStructureHelper = McStructureHelper.getHelper(enableNamespaceSchema,
defaultProject);
+ validateMaxComputeConnection(enableNamespaceSchema);
initPreExecutionAuthenticator();
metadataOps = new MaxComputeMetadataOps(this, odps);
transactionManager =
TransactionManagerFactory.createMCTransactionManager(this);
}
+ protected void validateMaxComputeConnection(boolean enableNamespaceSchema)
{
+ if (enableNamespaceSchema) {
+ validateMaxComputeProjectAndNamespaceSchema();
+ } else {
+ validateMaxComputeProject();
+ }
+ }
+
+ private void validateMaxComputeProject() {
+ try {
+ if (!maxComputeProjectExists(defaultProject)) {
+ throw new RuntimeException("MaxCompute project '" +
defaultProject
+ + "' does not exist or is not accessible");
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to validate MaxCompute project
'" + defaultProject
+ + "'. Check " + MCProperties.PROJECT + ", " +
MCProperties.ENDPOINT
+ + " and credentials. Cause: " + e.getMessage());
+ }
+ }
+
+ private void validateMaxComputeProjectAndNamespaceSchema() {
+ try {
+ if (!isMaxComputeProjectThreeTierModel(defaultProject)) {
+ throw new RuntimeException("MaxCompute project '" +
defaultProject
+ + "' does not support namespace schema");
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to validate MaxCompute project
'" + defaultProject
+ + "' with GetProject. Check " + MCProperties.PROJECT + ",
" + MCProperties.ENDPOINT
+ + ", credentials and namespace schema support. Cause: " +
e.getMessage());
+ }
+ }
+
+ protected boolean maxComputeProjectExists(String projectName) throws
OdpsException {
+ return odps.projects().exists(projectName);
+ }
+
+ protected boolean isMaxComputeProjectThreeTierModel(String projectName)
throws Exception {
+ GetProjectRequest request = new GetProjectRequest()
+ .setVerbose(false)
+ .setWithQuotaProductType(false)
+ .setWithStorageTierInfo(false);
+ GetProjectResponse response =
createMaxComputeOpenApiClient().getProject(projectName, request);
+ GetProjectResponseBodyData data = response.getBody() == null ? null :
response.getBody().getData();
+ if (data == null || data.getThreeTierModel() == null) {
+ throw new RuntimeException("MaxCompute GetProject did not return
threeTierModel");
+ }
+ return Boolean.TRUE.equals(data.getThreeTierModel());
+ }
+
+ private com.aliyun.maxcompute20220104.Client
createMaxComputeOpenApiClient() throws Exception {
+ // Use public fields to avoid Alibaba SDK setter return-type ABI
differences at runtime.
Review Comment:
This validation path ignores the endpoint that the catalog was configured to
use. `generatorEndpoint()` supports private/intranet endpoints such as
`service.<region>-vpc...` / `-intranet` / `aliyun-inc`, and all normal ODPS
calls above are configured with that `endpoint`. For namespace-schema catalogs,
however, this new OpenAPI client is created with only `regionId`, so the
Alibaba SDK resolves its default endpoint instead of the user-provided
`mc.endpoint`. A deployment that can reach MaxCompute only through the
configured private endpoint will now fail `makeSureInitialized()` before any
normal ODPS operation, even though the catalog configuration is valid. Please
configure the OpenAPI endpoint consistently with `mc.endpoint` (or validate
three-tier support through the same ODPS endpoint) rather than relying on
region-only endpoint resolution.
--
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]