Sun Oct 25, 2020 10:12 am
Login Register Lost Password? Contact Us


DUPLIATE INDEX Build fails

Comments and questions related to the Enterprise Control Language

Sun Aug 02, 2020 12:29 pm Change Time Zone

Please help me understand the difference on why it fails on method 1

"message": "2305: The index record contains fields with no mappings - cannot build an index on it",
"

Code: Select all
Rec  := RECORD
   UNSIGNED1 id;
   STRING10 col1;
END;

ds1:= DATASET([{1,'a'}],Rec);

/* Method 1 - NOT WORKING */
//idx1:= BUILD(ds1,{ds1.id},{ds1},'~thor::test::file1::202007284_idx',OVERWRITE);
//idx1;
//idx2:= INDEX(ds1,{UNSIGNED1 id,STRING10 col1},rec,'~thor::test::file1::202007284_idx');
//idx2;
//newidx := INDEX(idx2,'~thor::test::file1::202007285_idx_new'); //DUPLICATE INDEX DEFN
//BUILDINDEX(newidx ); //FAILS

/* Method 2 WORKING */
idx_1:= INDEX(ds1,{id},{ds1},'~thor::test::file1::202007281_idx_1');
//build(idx_1);
newidx_1:= INDEX(idx_1,'~thor::test::file1::202007281_idx_2'); //DUPLICATE INDEX DEFN
BUILDINDEX(newidx_1); //WORKS
BalajiTS
 
Posts: 4
Joined: Fri May 29, 2020 2:50 am

Tue Aug 04, 2020 1:18 pm Change Time Zone

BalajiTS,

The first way doesn't work because the structure you defined for the INDEX does not match the structure you specified in your BUILD.

Code: Select all
idx1:= BUILD(ds1,{ds1.id},{ds1},'~RTtest::file1::202007284_idx',OVERWRITE);
idx1;
This BUILD is creating a payload INDEX with the id field as the search term and the col1 field as the only payload (because it's the only other field in the RECORD structure for ds1 that isn't already specified as a search term).

Code: Select all
idx2:= INDEX(ds1,{UNSIGNED1 id,STRING10 col1},rec,'~RTtest::file1::202007284_idx');
idx2;
But this INDEX declaration is not defining the same structure as the BUILD, because you have both the id and col1 fields defined as search terms. The rec "payload" parameter is irrelevant because all the fields are already defined as search terms.

To duplicate the result of your BUILD you need to define it like this:
Code: Select all
idx2:= INDEX(ds1,{UNSIGNED1 id},{STRING10 col1},'~RTtest::file1::202007284_idx');
idx2;
That makes the id field the only search term, and the col1 field the only payload, duplicating the file structure built by the BUILD.

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1560
Joined: Wed Oct 26, 2011 7:40 pm

Tue Aug 04, 2020 1:38 pm Change Time Zone

Thank you Richard for the clarification
BalajiTS
 
Posts: 4
Joined: Fri May 29, 2020 2:50 am


Return to ECL

Who is online

Users browsing this forum: No registered users and 2 guests

cron