Skip to content

Commit 0ecd014

Browse files
committed
feat #OBS-I649 : update id the hudi spec exists or else create
1 parent e0979dc commit 0ecd014

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

api-service/src/services/DatasetService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,13 @@ class DatasetService {
458458
const draftDatasource = this.createDraftDatasource(draftDataset, "datalake");
459459
const dsId = _.join([draftDataset.dataset_id, "events", "datalake"], "_")
460460
const liveDatasource = await Datasource.findOne({ where: { id: dsId }, attributes: ["ingestion_spec"], raw: true }) as unknown as Record<string, any>
461-
const ingestionSpec = tableGenerator.getHudiIngestionSpecForUpdate(draftDataset, liveDatasource?.ingestion_spec, allFields, draftDatasource?.datasource_ref);
461+
let ingestionSpec = _.get(liveDatasource, "ingestion_spec");
462+
if (_.isEmpty(ingestionSpec)) {
463+
ingestionSpec = tableGenerator.getHudiIngestionSpecForCreate(draftDataset, allFields, draftDatasource.datasource_ref);
464+
}
465+
else {
466+
ingestionSpec = tableGenerator.getHudiIngestionSpecForUpdate(draftDataset, liveDatasource?.ingestion_spec, allFields, draftDatasource?.datasource_ref);
467+
}
462468
_.set(draftDatasource, "ingestion_spec", ingestionSpec)
463469
_.set(draftDatasource, "created_by", created_by);
464470
_.set(draftDatasource, "updated_by", updated_by);

0 commit comments

Comments
 (0)