hpcc-systems/HPCC-Platform — Issue #1805: OUTPUT(COUNT(ds)) works on hthor but not on Thor
Author: RichardTaylorHPCC
Created: 2012-03-08 16:49:35+00:00
State: open

The code below comes from this Forum thread: http://hpccsystems.com/bb/viewtopic.php?f=10&t=301&p=1282&sid=b79f8f6228bc265ca868c99569f70e70#p1282

I duplicated his problem on the 3.6 VMware release with this code:

IMPORT STD;
allfiles := std.file.logicalfilelist();

nameNfile := record
string name;
end;

outRec := record
string file;
dataset(nameNfile) nameNfile:=dataset([],nameNfile);
end;

outRec DoTransform(allfiles L):= transform, skip(not std.Str.startsWith(L.name, 'sample::'))

person:= record
string name {xpath('')};
end;

layout1:=record
dataset(person) person {xpath('A/PERSON')};
end;

B:= record
dataset(person) person {xpath('B/PERSON')}
end;

layout2:= record
dataset(B) B {xpath('A')};
end;

ds_layout1 := dataset('~'+l.name, layout1, xml('root'));
ds_layout2 := dataset('~'+l.name, layout2, xml('root'));

getDs:= map(exists(ds_layout1[1].person)=true => ds_layout1[1].person,
exists(ds_layout2[1].B[1].person)=true => ds_layout2[1].B[1].person);

self.nameNfile:= DATASET(SET(getDs,name),nameNfile);

self.file:=l.name;

end;

outDs:= project(allfiles, DoTransform(left));
output(outDs);
count(outDs); // Problem 2
// output(outDs,, '~sampleResult::outDs2'); // Problem 3
/* Input Files
file1.Xml(of layout1):

SMITH
JOHN
BRET

Logical path for this file is 'sample::file1'

file2.Xml(of layout2):

SMITH
JOHN
BRET

Logical path for this file is 'sample::file2'
*/