Skip to content
HPCCSystems Solutions Lab
HPCCSystems Solutions Lab

OUTPUT

OUTPUT is an action that allows user to view results. OUTPUT can be used to save dataset result in a file. There are a few ways to generate output.

Following examples show how you can simply view results. ‘NAMED’ allows you to label your outputs, and it’s very useful when you have many outputs.

Example


/*
OUTPUT Examples.
*/

// Outputting numeric value
OUTPUT(100 + 200, NAMED('myFirst'));

// Assigning a STRING value to an attribute
someVal := 'My First String';

// Outputting the attribute
OUTPUT(someVal, NAMED('someVal'));

Try Me

SQL vs. ECL

OUTPUT is similar to SELECT in SQL.

SQLECL
SELECT * From PeopleDSeDS;OUTPUT(peopleDS);
SELECT name, address FROM PeopleDS;OUTPUT(TABLE(common.PeopleDSeDS, {name, address}));

Syntax

OUTPUT(dataset_name/attr_name);
OUTPUT(dataset_name/attr_name, Named('display-name'));

ValueDefinition
OUTPUTRequired.
dataset_nameDataset name.
attr_nameAttribute.
NAMEDOptional, recommended when multiple outputs are being viewed. NAMED specifies the label for the result. Given name can’t start with numbers and shouldn’t include spaces or -

Demo Dataset

JobCategoryCityStateAvg_SalaryLowerBandUpperband
ManagerITAtlantaGA8700062000114000
DirectorITAtlantaGA11900084000156000
DirectorArt-EntertainmentAtlantaGA10000070000133000
CIOITTampaFL11200069000131000
SalesGeneralChicagoIL5500032000121000

Example


/*
OUTPUT Examples.
Outputting a dataset.
*/

// Defining record layout
SalaryAvg_Layout := RECORD
    STRING    Job;
    STRING    Category;
    STRING    City;
    STRING2   State;
    INTEGER   Avg_Salary;
    INTEGER   LowerBand;
    INTEGER   Upperband;
END;

// Creating the dataset
SalaryAvg_DS := DATASET([
                    {'Manager', 'IT', 'Atlanta', 'GA', 87000, 62000, 114000},
                    {'Director', 'IT', 'Atlanta', 'GA', 119000, 84000, 156000},
                    {'Director', 'Art-Entertainment', 'Atlanta', 'GA', 100000, 70000, 133000},
                    {'CIO', 'IT', 'Tampa', 'FL', '112000', '69000', 131000},
                    {'Sales', 'General', 'Chicago', 'IL', 55000, 32000, 121000}], 
                    SalaryAvg_Layout);

/*
 Output with no label
 Note: When you have multiple  outputs with no labels(NAMED option), 
it might be difficult to identify them.
*/

OUTPUT(SalaryAvg_DS);
SalaryAvg_DS;

// Using NAMED
OUTPUT(SalaryAvg_DS, NAMED('SalaryAvg_DS'));

Try Me