Skip to content

Commit 70ab4ad

Browse files
committed
Add additional properties when doing conversion for hudi
1 parent fc4d6e8 commit 70ab4ad

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

xtable-service/src/main/java/org/apache/xtable/service/ConversionService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.xtable.service;
2020

2121
import static org.apache.xtable.conversion.ConversionUtils.convertToSourceTable;
22+
import static org.apache.xtable.hudi.HudiSourceConfig.PARTITION_FIELD_SPEC_CONFIG;
2223
import static org.apache.xtable.model.storage.TableFormat.DELTA;
2324
import static org.apache.xtable.model.storage.TableFormat.HUDI;
2425
import static org.apache.xtable.model.storage.TableFormat.ICEBERG;
@@ -27,6 +28,7 @@
2728
import java.util.HashMap;
2829
import java.util.List;
2930
import java.util.Map;
31+
import java.util.Properties;
3032

3133
import lombok.extern.log4j.Log4j2;
3234

@@ -186,11 +188,19 @@ public ConversionService(
186188
* @return a ConvertTableResponse containing details of the converted target tables
187189
*/
188190
public ConvertTableResponse convertTable(ConvertTableRequest convertTableRequest) {
191+
192+
Properties sourceProperties = new Properties();
193+
String partitionSpec = convertTableRequest.getConfigurations().getOrDefault("partition-spec", null);
194+
if (partitionSpec != null) {
195+
sourceProperties.put(PARTITION_FIELD_SPEC_CONFIG, partitionSpec);
196+
}
197+
189198
SourceTable sourceTable =
190199
SourceTable.builder()
191200
.name(convertTableRequest.getSourceTableName())
192201
.basePath(convertTableRequest.getSourceTablePath())
193202
.formatName(convertTableRequest.getSourceFormat())
203+
.additionalProperties(sourceProperties)
194204
.build();
195205

196206
List<TargetTable> targetTables = new ArrayList<>();
@@ -200,6 +210,7 @@ public ConvertTableResponse convertTable(ConvertTableRequest convertTableRequest
200210
.name(convertTableRequest.getSourceTableName())
201211
.basePath(convertTableRequest.getSourceTablePath())
202212
.formatName(targetFormat)
213+
.additionalProperties(sourceProperties)
203214
.build();
204215
targetTables.add(targetTable);
205216
}

0 commit comments

Comments
 (0)