Fri Dec 03, 2021 3:08 am
Login Register Lost Password? Contact Us


Creating Boolean Definitions

Comments and questions related to the Enterprise Control Language

Sun Oct 02, 2011 2:25 am Change Time Zone

I've just started to learn ECL, and i would like to know the steps in creating an EXPORT and local Boolean definitions. I read the HPCC Data tutorial, however, i'm still lost. Can someone get me started?

Thank you.
rondav9
 
Posts: 2
Joined: Sun Oct 02, 2011 2:16 am

Mon Oct 03, 2011 1:55 pm Change Time Zone

Hello,

Creating a Boolean definitions is pretty simple. Go to your Repository window, and right-click in your target folder and select Insert File. Give the file a name for the Boolean definition that you wish to export. For example, if I wanted to create a Boolean definition named IsFloridian, that will be the name of my file. The ECL IDE will create a helper line of code for you that looks like this:

EXPORT IsFloridian := 'todo';

Now, just change it to add your Boolean expression like this:

EXPORT IsFloridian := Person.per_st = 'FL';

...and you'll probably need to import from your repository the reference to the dataset, like this:

IMPORT $;
EXPORT IsFloridian := $.Person.per_st = 'FL';

That's all you need, please reply back if you have any additional questions.

Regards,

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1005
Joined: Wed Jun 29, 2011 7:13 pm

Mon Oct 03, 2011 8:09 pm Change Time Zone

Bob,

Thank you!
rondav9
 
Posts: 2
Joined: Sun Oct 02, 2011 2:16 am

Tue Oct 04, 2011 9:00 am Change Time Zone

I have a question about this. I have local boolean definitions that define the boolean i export. When i run check i get no errors but when i try to execute i get error.
my code is

IMPORT $;
Persons := $.Persons;
BOOLEAN IsFloridian := Persons.State = 'FL';
BOOLEAN IsMale := Persons.Gender='M';
BOOLEAN IsBorn80 := Persons.BirthDate>='1980' AND Persons.BirthDate!=' ';

EXPORT BOOLEAN IsYougMaleFloridian := IsFloridian AND IsMale AND IsBorn80;

The Error i get is.
Error: persons.state - no specified row for Table persons (3, 1), 2131, TrainingKirilAlexandrov\IsYougMaleFloridian.ecl

In other executions i have no problem referencing persons for example
IMPORT $;
Persons := $.Persons;
florida :=Persons(State='FL');
COUNT(florida);

Runs fine
Prabulg
 
Posts: 2
Joined: Wed Sep 21, 2011 12:20 am

Tue Oct 04, 2011 12:32 pm Change Time Zone

Hi Prabulg,

That error is expected, when you Submit the IsYougMaleFloridian code, there is really no action that the workunit can perform (it's just a Boolean expression, and is not referencing a recordset to return).

Try this: Open a new builder window and then enter:

IMPORT TrainingYourName AS X;
X.Persons(X.IsYougMaleFloridian);

That will get you some good results :-)

Regards,

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1005
Joined: Wed Jun 29, 2011 7:13 pm

Tue Oct 04, 2011 9:05 pm Change Time Zone

Cool Thanks a lot for the clarification.
Prabulg
 
Posts: 2
Joined: Wed Sep 21, 2011 12:20 am


Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest