Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix][Connector-V2] Fix maxcompute read with partition spec #8896

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
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 @@ -158,14 +158,12 @@ public CatalogTable getTable(TablePath tablePath, List<String> fieldNames)
}
Table odpsTable;
com.aliyun.odps.TableSchema odpsSchema;
boolean isPartitioned;
try {
Odps odps = getOdps(tablePath.getDatabaseName());
odpsTable =
MaxcomputeUtil.parseTable(
odps, tablePath.getDatabaseName(), tablePath.getTableName());
odpsSchema = odpsTable.getSchema();
isPartitioned = odpsTable.isPartitioned();
} catch (Exception ex) {
throw new CatalogException(catalogName, ex);
}
Expand Down Expand Up @@ -193,31 +191,6 @@ public CatalogTable getTable(TablePath tablePath, List<String> fieldNames)
.build();
return MaxComputeTypeConverter.INSTANCE.convert(typeDefine);
});
if (isPartitioned) {
buildColumnsWithErrorCheck(
tablePath,
builder,
odpsSchema.getPartitionColumns().stream()
.filter(
column ->
fieldNames == null
|| fieldNames.isEmpty()
|| fieldNames.contains(column.getName()))
.iterator(),
(column) -> {
BasicTypeDefine<TypeInfo> typeDefine =
BasicTypeDefine.<TypeInfo>builder()
.name(column.getName())
.nativeType(column.getTypeInfo())
.columnType(column.getTypeInfo().getTypeName())
.dataType(column.getTypeInfo().getTypeName())
.nullable(column.isNullable())
.comment(column.getComment())
.build();
partitionKeys.add(column.getName());
return MaxComputeTypeConverter.INSTANCE.convert(typeDefine);
});
}
TableSchema tableSchema = builder.build();
TableIdentifier tableIdentifier = getTableIdentifier(tablePath);
return CatalogTable.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ private Map<TablePath, SourceTableInfo> getSourceTableInfos(ReadonlyConfig reado
.orElse(readonlyConfig.get(PROJECT));
TablePath tablePath =
TablePath.of(project, subReadonlyConfig.get(TABLE_NAME));
String partitionSpec =
subReadonlyConfig
.getOptional(PARTITION_SPEC)
.orElse(readonlyConfig.get(PARTITION_SPEC));

if (subReadonlyConfig
.getOptional(ConnectorCommonOptions.SCHEMA)
.isPresent()) {
Expand All @@ -108,7 +113,7 @@ private Map<TablePath, SourceTableInfo> getSourceTableInfos(ReadonlyConfig reado
catalogTable.getTablePath(),
new SourceTableInfo(
catalogTable,
subReadonlyConfig.get(PARTITION_SPEC),
partitionSpec,
subReadonlyConfig.get(SPLIT_ROW)));
} else {
Integer splitRow =
Expand All @@ -120,7 +125,7 @@ private Map<TablePath, SourceTableInfo> getSourceTableInfos(ReadonlyConfig reado
new SourceTableInfo(
catalog.getTable(
tablePath, subReadonlyConfig.get(READ_COLUMNS)),
subReadonlyConfig.get(PARTITION_SPEC),
partitionSpec,
splitRow));
}
}
Expand Down
Loading