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 @@ -31,6 +31,7 @@
import com.aliyun.odps.Partition;
import com.aliyun.odps.Project;
import com.aliyun.odps.account.Account;
import com.aliyun.odps.account.AccountFormat;
import com.aliyun.odps.account.AliyunAccount;
import com.aliyun.odps.security.SecurityManager;
import com.aliyun.odps.table.configuration.RestOptions;
Expand Down Expand Up @@ -78,6 +79,8 @@ public class MaxComputeExternalCatalog extends ExternalCatalog {

public boolean dateTimePredicatePushDown;

AccountFormat accountFormat = AccountFormat.DISPLAYNAME;

private static final Map<String, ZoneId> REGION_ZONE_MAP;
private static final List<String> REQUIRED_PROPERTIES = ImmutableList.of(
MCProperties.PROJECT,
Expand Down Expand Up @@ -211,6 +214,14 @@ protected void initLocalObjectsImpl() {
this.odps = new Odps(account);
odps.setDefaultProject(defaultProject);
odps.setEndpoint(endpoint);

String accountFormatProp = props.getOrDefault(MCProperties.ACCOUNT_FORMAT, MCProperties.DEFAULT_ACCOUNT_FORMAT);
if (accountFormatProp.equals(MCProperties.ACCOUNT_FORMAT_NAME)) {
accountFormat = AccountFormat.DISPLAYNAME;
} else if (accountFormatProp.equals(MCProperties.ACCOUNT_FORMAT_ID)) {
accountFormat = AccountFormat.ID;
}
odps.setAccountFormat(accountFormat);
Credentials credentials = Credentials.newBuilder().withAccount(odps.getAccount())
.withAppAccount(odps.getAppAccount()).build();

Expand Down Expand Up @@ -427,6 +438,14 @@ public void checkProperties() throws DdlException {
+ MCProperties.SPLIT_ROW_COUNT + "must be an integer");
}

String accountFormatProp = props.getOrDefault(MCProperties.ACCOUNT_FORMAT, MCProperties.DEFAULT_ACCOUNT_FORMAT);
if (accountFormatProp.equals(MCProperties.ACCOUNT_FORMAT_NAME)) {
accountFormat = AccountFormat.DISPLAYNAME;
} else if (accountFormatProp.equals(MCProperties.ACCOUNT_FORMAT_ID)) {
accountFormat = AccountFormat.ID;
} else {
throw new DdlException("property " + MCProperties.ACCOUNT_FORMAT + "only support name and id");
}

try {
connectTimeout = Integer.parseInt(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public class MCProperties extends BaseProperties {
"mc.datetime_predicate_push_down";
public static final String DEFAULT_DATETIME_PREDICATE_PUSH_DOWN = "true";

// The account systems for Alibaba Cloud China and International are different. If the primary account is an
// International user, specify ACCOUNT_FORMAT as ACCOUNT_FORMAT_ID. Otherwise, specify ACCOUNT_FORMAT_NAME.
public static final String ACCOUNT_FORMAT = "mc.account_format";
public static final String ACCOUNT_FORMAT_NAME = "name";
public static final String ACCOUNT_FORMAT_ID = "id";
public static final String DEFAULT_ACCOUNT_FORMAT = ACCOUNT_FORMAT_NAME;

public static CloudCredential getCredential(Map<String, String> props) {
return getCloudCredential(props, ACCESS_KEY, SECRET_KEY, SESSION_TOKEN);
}
Expand Down
Loading