2

I'm new to ECL and having trouble trying to understand RIGHT and LEFT keywords (used in DEDUP, GROUP and other functions). How do they work? The ECL reference guide has a single paragraph about what it's supposed to do.

for example, what is it doing in this code?

MyRec := RECORD
    STRING1 Value1;
    STRING1 Value2;
END;

SomeFile := DATASET([{'C','G'},
                     {'C','C'},
                     {'A','X'},
                     {'B','G'},
                     {'A','B'}], MyRec);

Dedup2 := DEDUP(Val2Sort, LEFT.Value2 = RIGHT.Value2);
ocarlos-
  • 41
  • 2
  • 1
    you used the "ecl" tag, which refers to a common lisp implementation. Could you edit the tags to delete it or use another tag (I don't know which ECL you are talking about) – coredump Apr 14 '20 at 14:24
  • 1
    thanks, I was talking about HPCC-ECL. – ocarlos- Apr 15 '20 at 20:36

3 Answers3

2

Apparently the problem was the way I was seeing the data. I formatted the DATASET as a column to make it easier to understand and ended up messing my viewing. LEFT and RIGHT are each registry in the DATASET, which should be viewed like this:

DATASET([{'C','G'},{'C','C'},{'A','X'},{'B','G'},{'A','B'}])

This way, on it's first iteration, {'C','G'} (LEFT) would be compared to {'C','C'} (RIGHT), and so on.

ocarlos-
  • 41
  • 2
2

LEFT and RIGHT is a standard naming convention in ECL when dealing with two recordsets at the same time. With statements like DEDUP, ROLLUP and ITERATE, LEFT and RIGHT refer to record pairs in the same recordset, LEFT is the first record in the pair and RIGHT the second.

In a JOIN statement, the LEFT and RIGHT can be different recordsets. As you explore ECL, the language has powerful data transformation functions, aptly named TRANSFORM functions. In those functions, you will see another keyword named SELF which represents the output of any transformation.

So in a typical JOIN you can have a "left", "right", and "self" record in memory at the same time. The keywords therefore help the compiler distinguish which field in the record you are referencing when the field name is the same (example- an "address" field).

m.rp
  • 718
  • 8
  • 22
Bob Foreman
  • 164
  • 7
0

All the RIGHT and LEFT keyword are doing in this context is indicating which dataset you want in the right and in the left. In other context in ECL it can mean that you want to keep the data on the RIGHT or LEFT after procedure is done.
Not here.

greybeard
  • 2,249
  • 8
  • 30
  • 66
Maurice
  • 13
  • 1