Skip to content

Commit 036af5f

Browse files
committed
Add check against duplicated IDs in MCC ETL
1 parent 475c925 commit 036af5f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

mcc/src/org/labkey/mcc/etl/PopulateIdsStep.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,34 @@ public RecordedActionSet run(@NotNull PipelineJob job) throws PipelineJobExcepti
4343
populateForDemographics(job);
4444
populateForKinship(job);
4545

46+
// Check for duplicate IDs and proactively error:
47+
performDuplicateCheck(job);
48+
4649
return new RecordedActionSet();
4750
}
4851

52+
private void performDuplicateCheck(PipelineJob job) throws PipelineJobException
53+
{
54+
// Query aggregated demographics:
55+
UserSchema sourceSchema = QueryService.get().getUserSchema(_containerUser.getUser(), _containerUser.getContainer(), MccSchema.NAME);
56+
if (sourceSchema == null)
57+
{
58+
throw new PipelineJobException("Unable to find source schema: " + MccSchema.NAME);
59+
}
60+
61+
TableInfo sourceTi = sourceSchema.getTable("duplicatedAggregatedDemographics");
62+
if (sourceTi == null)
63+
{
64+
throw new PipelineJobException("Unable to find table: duplicatedAggregatedDemographics");
65+
}
66+
67+
TableSelector ts = new TableSelector(sourceTi);
68+
if (ts.exists())
69+
{
70+
throw new PipelineJobException("There were duplicated IDs in aggregatedDemographics");
71+
}
72+
}
73+
4974
private void populateForDemographics(PipelineJob job) throws PipelineJobException
5075
{
5176
// Query aggregated demographics:

0 commit comments

Comments
 (0)