Skip to content

Commit

Permalink
HPCC4J-691 DFSClient: Column pruner not correctly cloning field defs
Browse files Browse the repository at this point in the history
- Updated ColumnPruner to correctly clone child field defs

Signed-off-by: James McMullan [email protected]
  • Loading branch information
jpmcmu committed Feb 11, 2025
1 parent 0e9372f commit 07fc752
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private FieldDef pruneFieldDefinition(FieldDef originalRecordDef, String path)

if (fieldInfo.shouldCullChildren == false)
{
return originalRecordDef;
return new FieldDef(originalRecordDef);
}

// Datasets are a special case. They will not have a component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,43 @@ public final void testGetProjectedRecordDefinition() throws HpccFileException
Assert.assertEquals(3, projectedRecordDefinition.getNumDefs());
}

private boolean testFieldDefsNotEquals(FieldDef fieldDef1, FieldDef fieldDef2)
{
for (int i = 0; i < fieldDef1.getNumDefs(); i++)
{
if (fieldDef1.getDef(i) == fieldDef2.getDef(i))
{
return false;
}

if (!testFieldDefsNotEquals(fieldDef1.getDef(i), fieldDef2.getDef(i)))
{
return false;
}
}

return true;
}

@Test
public final void testProjectedRecordDefCloning() throws Exception
{
FieldDef recordDef = mockHPCCFile.getRecordDefinition();

String[] fieldNames = new String[recordDef.getNumDefs()];
for (int i = 0; i < recordDef.getNumDefs(); i++)
{
fieldNames[i] = recordDef.getDef(i).getFieldName();
}

String projectList = String.join(",", fieldNames);
mockHPCCFile.setProjectList(projectList);
FieldDef projectedRecordDefinition = mockHPCCFile.getProjectedRecordDefinition();

// Ensure the projected record definition is a clone and not modifying the original record definition
assert(testFieldDefsNotEquals(recordDef, projectedRecordDefinition));
}

@Test
public final void testIsIndex()
{
Expand Down

0 comments on commit 07fc752

Please sign in to comment.