WsSQL ESP Web Service GuideBoca Raton Documentation TeamWe welcome your comments and feedback about this document via
email to docfeedback@hpccsystems.com Please include
Documentation Feedback in the subject
line and reference the document name, page numbers, and current Version
Number in the text of the message.LexisNexis and the Knowledge Burst logo are registered trademarks
of Reed Elsevier Properties Inc., used under license. Other products,
logos, and services may be trademarks or registered trademarks of their
respective companies. All names and example data used in this manual are
fictitious. Any similarity to actual persons, living or dead, is purely
coincidental.HPCC SystemsIntroductionThe WsSQL Web service is an add-on service that provides an SQL
interface into HPCC Systems. The Web service accepts a subset of prepared
and standard SQL queries. This provides access to most HPCC data and
published queries over HTTP or HTTPS using SOAP or REST interfaces.The WsSQL service maps HPCC logical files to RDBMS tables. HPCC
Published Queries are exposed as RDBMS Stored Procedures.The WsSQL service also provides convenient methods to obtain system
information, metadata, and results from previously run queries.This service is intended to be used in a programmatic fashion (for
example, via database drivers), but can also be used in an interactive
fashion by users who are more comfortable using SQL than ECL. This makes
it possible to submit ad-hoc queries without learning ECL.The service exposes HPCC logical files as RDB tables.HPCC Logical File <-> RDB TableHPCC Record Fields <-> RDB Table ColumnsHPCC Published query <-> RDB Stored ProcedureProvides HPCC system and data RDB metadataSupports subset of SQL syntaxNon-transactionalProvides means for utilizing HPCC index files for faster
reads.Supported File TypesThe WsSQL service supports all HPCC file types except :XMLFiles with Nested Child DatasetsFiles without record layout in its metadata.The WsSQL service only supports files
which contain the record definition in the logical file's
metadata. Sprayed files do not contain this metadata.
This metadata exists on any file or index which is written to the
HPCC Distributed File System (DFS). Sprayed data files typically
undergo some processing and an OUTPUT of the transformed data to
disk before use, so this should not interfere with the service's
usefulness. You can use the
CreateTableAndLoad method to produce a usable
file from a sprayed file or one on a landing zone. See CreateTableAndLoad for
details.SetupThe WsSQL service is included in the HPCC Platform. Prior to version 7.0, WsSQL was an add-on product and was
installed separately. If you have a system configured with WsSQL prior
to version 7.0, you should uninstall WsSQL before upgrading the
platform.Configuration We recommend taking the time to read this manual in its entirety;
however, the following is a quick start summary of steps.Configure Using WizardOnce Configuration Manager is running:Create a new environment using the wizard.The WsSQL service is automatically added and its service
binding is created in the ESP Server's configuration.Save the environment file.Copy your environment.xml file to all servers.# for example
sudo -u hpcc cp /etc/HPCCSystems/source/NewEnvironment.xml /etc/HPCCSystems/environment.xmlExit Configuration manager.Restart the system.Access the WsSQL interface in your browser (port
8510).Run the Echo method to confirm connectivity. See
Echo.Configure ManuallyThis method is useful when adding the WsSQL service to an
existing system that did not have a service configured or to add an
additional WsSql service.Once Configuration Manager is running:Open an environment file (*.xml) in Advanced Mode.If you are adding WsSQL to an existing system, open an
environment file that matches the live environment.xml. It is
highlighted.Check the Write Access box.Right-click on the Software portion of the tree in the left
panel, and select New ESP
Service > ws_sql
.This adds a definition for the service.Select the ESP component,
then select the ESP Service Bindings tab.Provide the name of the service to bind and the port.
(Default port is 8510)Save the environment file.Copy your environment.xml file to all servers# for example
sudo -u hpcc cp /etc/HPCCSystems/source/NewEnvironment.xml /etc/HPCCSystems/environment.xmlExit Configuration manager.Restart the system.Access the WsSQL interface in your browser:Using http://nnn.nnn.nnn.nnn:pppp
(where nnn.nnn.nnn.nnn is your ESP Server's IP Address and pppp
is the WsSQL service port. The default port is 8510)Run the Echo method to confirm connectivity. See
Echo.Using HPCC Files as a data sourceOnce installed and configured, the WsSQL service will process
submitted SQL statements and generate dynamic ECL code. The code is
submitted to and executed by your HPCC Platform. The result set is
returned to your application.Note:The WsSQL service only supports files
which contain the record definition in the logical file's
metadata. Sprayed files do not contain this metadata.
This metadata exists on any file or index which is written to the
HPCC Distributed File System (DFS). Sprayed data files typically
undergo some processing and an OUTPUT of the transformed data to
disk before use, so this should not interfere with the service's
usefulness. You can use the
CreateTableAndLoad method to produce a usable
file from a sprayed file or one on a landing zone. See CreateTableAndLoad for
details.In addition, you can utilize indexes on the HPCC in one of two
ways:Provide SQL hints to tell service to use a specific index for
your query.For example:USEINDEX(TutorialPersonByZipIndex)Specify the related indexes in the HPCC logical file
description.Index AnnotationsThe WsSQL service attempts to perform index based reads whenever
possible. However, in order to take advantage of index reads, the target
HPCC files need to be annotated with the pertinent index file names.
This is accomplished by adding the following key/value entry on the
file's description using ECL Watch.From a logical file's details page, enter the information in the
Description entry box, then press the Save
Description button.This information is used by the service to decide if an index
fetch is possible for a query on the base file.On source file:XDBC:RelIndexes=
[fullLogicalFilename1;
fullLogicalFilename2]Example:XDBC:RelIndexes=[tutorial::yn::peoplebyzipindex;
tutorial::yn::peoplebyzipindex2;
tutorial::yn::peoplebyzipindex3]In this example, the source file has three indexes
available.You can add annotations using the SetRelatedIndexes method.On the index file:XDBC:PosField=[indexPositionFieldName]Example:XDBC:PosField=[fpos]The FilePosition field (fpos) can have any name, so it must be
specified in the metadata so the service knows which field is the
fileposition.Simply enter the information in the description entry box, then
press the Save Description
button.Note:You should enter this information BEFORE publishing any
query using the data file or indexes. Published queries lock the
file and would prevent editing the metadata.MethodsThese methods are included in the WsSQL service interface:EchoThis method is provided to test end-to-end communication. The
Input string is echoed in response.GetDBSystemInfoYou can use this method to gather version information from the
HPCC Platform.GetMetadataThis method provides metadata you can use to create a view or
model of the target HPCC system as a SQL accessible DB. You can
request Tables, Stored Procedures, and/or Targetclusters.ExecuteSQLUse this method to submit standard (non-prepared) SQL queries.
This method accepts free-hand SQL text (see supported grammar
below).GetRelatedIndexesThis method retrieves information from a logical file's
description about related indexes.GetResultsThis method provides results from previously executed
queries.PrepareSQLThis method provides the ability to submit a free-hand SQL
request for later use as a parameterized query. It compiles the query
and returns the Workunit ID (WUID). This WUID is later used to execute
the query with provided input parameters using the ExecutePreparedSQL
method. This is ideal for queries which are executed many times with
different values.ExecutePreparedSQLThis method executes a previously created parameterized SQL
query. The query is referenced using a Workunit ID (WUID), which is
returned from the PrepareSQL method. The caller can specify sequence
of input parameters as key-value pairs, which are bound to the
precompiled query.CreateTableAndLoadThis method reads a logical file or a file on a landing zone and
creates a new table and loads the data from the source file creating a
table (logical file) that WsSQL can use. This function is intended to
use when you have a logical file without metadata or to import a new
file into an HPCC platform.SetRelatedIndexesThis method adds information to a logical file's description
that WsSQL uses as an annotation of a related index.EchoThis function takes an input string and "echoes" the value in its
result.This function is intended for end-to-end connectivity testing. A
successful response indicates a good connection to the server hosting
the Ws-SQL Web service. This function is designed for connectivity
testing.We recommend using this function as a first step of the
application development process.Sample Input XML<soap:Envelope>
<soap:Body>
<EchoRequest>
<Request>StringToEcho</Request>
</EchoRequest>
</soap:Body>
</soap:Envelope>
Request Tag DescriptionsTag NameReq?DescriptionEchoRequestNStructure containing the request RequestNString to echo in resultResponse Tag DescriptionsTag NameDescriptionEchoResponseStructure containing response ResponseResponseGetDBSystemInfoThis method allows you to get HPCC System version
information.Sample Input XML<soap:Envelope>
<soap:Body>
<GetDBSystemInfoRequest>
<IncludeAll>1</IncludeAll>
</GetDBSystemInfoRequest>
</soap:Body>
</soap:Envelope>
Request Tag DescriptionsTag NameReq?DescriptionGetDBSystemInfoRequestYStructure containing the request IncludeAllNIf set to 1 or true, all available information is
returnedResponse Tag DescriptionsTag NameDescriptionGetDBSystemInfoResponseStructure containing response ExceptionsStructure containing exceptions. See Exceptions Structure in
Common Structures NameName. FullVersionFull Version of HPCC Platform MajorMajor of HPCC Platform MinorMinor of HPCC Platform PointPoint of HPCC Platform ProjectProject of HPCC Platform MaturityMaturity of HPCC Platform WsSQLFullVersionFull Version of WsSQL WsSQLMajor Major of WsSQL WsSQLMinor Minor of WsSQL WsSQLPoint Point of WsSQL WsSQLProject Project of WsSQL WsSQLMaturityMaturity of WsSQLGetDBMetaDataThis methods allows you to query the HPCC Platform and get
metadata to use to create a view or model of the target HPCC system as a
SQL accessible DB.You can request one or more of the followinfg:Tables (Logical files in the HPCC Cluster)Stored Procedures (Published Queries)TargetClustersSample Input XML<soap:Envelope>
<soap:Body>
<GetDBMetaDataRequest>
<IncludeTables>1</IncludeTables>
<TableFilter/>
<IncludeStoredProcedures>1</IncludeStoredProcedures>
<QuerySet/>
<IncludeTargetClusters>1</IncludeTargetClusters>
<ClusterType/>
</GetDBMetaDataRequest>
</soap:Body>
</soap:Envelope>Request Tag DescriptionsTag NameReq?DescriptionGetDBMetaDataRequestYStructure containing the request IncludeTablesNIf set to 1 or true, available tables are included in
response TableFilterNFilter for table results IncludeStoredProceduresNIf set to 1 or true, available Stored Procedures are
included in response QuerySetNQuerySet to use as filter for Stored procedures to
return IncludeTargetClustersNIf set to 1 or true, available Target Clusters are
included in response ClusterTypeNCluster type to use as filterResponse Tag DescriptionsTag NameDescriptionGetDBMetaDataResponseStructure containing response ExceptionsStructure containing exceptions. See Exceptions Structure in
Common Structures TableCountCount of available tables TablesStructure containing one or more tables TableStructure containing one table NameTable name ColumnsStructure containing one or more columns ColumnColumn NameColumn name TypeColumn data type (e.g., unsigned8, string3) ECLECL Definition for the table FormatTable format (e.g., FLAT, KEYED, etc) ContentTypeContent Type DescriptionDescription IsKeyedBoolean indicator: Is this an index? IsSuperBoolean indicator: Is this a superfile? CsvQuoteQuote character (only valid for CSV files) CsvSeparateSeparator character (only valid for CSV
files) CsvTerminateRecord terminator character (only valid for CSV
files) GroupGroup MaxRecordSizeMaximum record size ModifiedDate modified NumPartsNumber of file parts OwnerOwner name QuerySetsStructure containing one or more Query Sets QuerySetStructure containing one Query Set NameQuery Name QuerySetQueriesStructure containing one or more
QuerySetQueries QuerySetQueryStructure containing one QuerySetQuery NameQuery Name IdQuery ID (for internal use and informational purposes
only) WuidWorkunit ID SuspendedBoolean indicator: Is the query suspended? SignatureQuery Signature InParamsStructure containing one or more Input
parameters InParamStructure containing one Input parameter NameParameter name TypeParameter data type (e.g., string) ResultSetsStructure containing one or more Result Sets (Only
the first result set is returned from a WsSQL service
request) ResultSetStructure containing one Result Set NameResult set name OutParamsStructure containing one or more output
parameters OutParamStructure containing one output parameter NameParameter name TypeParameter data type (e.g., string) QuerySetAliasesStructure containing one or more
QuerySetAliases QuerySetAliasStructure containing one QuerySetAlias NameQuery name IdQuery Id ClusterNamesStructure containing one or more
TargetClusters ClusterNameStructure containing one TargetClusterExecuteSQLUse this method to submit standard (non-prepared) SQL queries. The
SqlText input tag accepts free hand SQL
text (see Supported SQL grammar below).If you are executing SQL using a SELECT or SELECT JOIN, you must
specify the TargetCluster.If you are executing SQL that uses a CALL to a stored procedure,
you must either fully qualify the procedure name (For example:
Roxie.FindPeopleByZip) or specify the TargetQuerySet here. Parameters must be passed in
order, not by name. You can retrieve the order using
GetDBMetaData.To exclude the result schema in the result, set the SuppressXmlSchema option to 1 or true.For result set paging, you can limit the total query results and
the initial page returned (ResultWindowStart, ResultWindowCount).Sample Input XML<soap:Envelope>
<ExecuteSQLRequest>
<SqlText>SELECT * from tutorial::yn::tutorialperson where lastname='JONES'</SqlText>
<UserName>Emily</UserName>
<!-- Use either TargetCluster or TargetQuerySet, not both --><!-- If stored procedure was fully qualified, you can omit TargetQuerySet -->
<TargetCluster>thor</TargetCluster>
<TargetQuerySet></TargetQuerySet>
<SuppressResults>1</SuppressResults>
<SuppressXmlSchema>0</SuppressXmlSchema>
<resultLimit>100</resultLimit>
<!-- For page loading -->
<ResultWindowStart>0</ResultWindowStart>
<ResultWindowCount>50</ResultWindowCount>
</ExecuteSQLRequest>
</soap:Envelope>
Request Tag DescriptionsTag NameReq?DescriptionExecuteSQLRequestYStructure containing the request SqlTextYFree-hand SQL text (see Supported SQL grammar
below) UserNameNUser Name to pass to HPCC. This is used as the job
owner name in HPCC TargetClusterY *If you are executing prepared SQL using a SELECT or
SELECT JOIN, you must specify the TargetCluster. TargetQuerySetY *If you are executing prepared SQL that uses a CALL to
a stored procedure, you must either fully qualify the
procedure name in the prepared SQL (For example:
Roxie.FindPeopleByZip) or specify the TargetCluster
here. SuppressResultsNIf set to 1 or true, query results are not included
in response SuppressXmlSchemaNIf set to 1 or true, the query result schema is not
included in response WaitNTimeout value in milliseconds. Use -1 for no
timeout resultLimitNIf set, the results can contain as many records as
this limit ResultWindowStartNFor use with page-loading, the starting record to
return ResultWindowCountNFor use with page-loading, the number of records to
include from the ResultWindowStart* One or the other is
requiredResponse Tag DescriptionsTag NameDescriptionExecuteSQLResponseStructure containing response ExceptionsStructure containing exceptions. See Exceptions Structure in
Common Structures ParentWuIdThe Workunit Id for the parent workunit (the one with
the prepared SQL) ResultThe query result WorkunitStructure containing Workunit details. See Workunit Structure in Common
Structures resultLimitThe submitted resultLimit ResultWindowStartThe submitted ReslutWindowStart ResultWindowCountThe submitted ResultWindowCountGetResultsThis method allows you to get results from previously executed
queries. Use the Wuid returned from
ExecuteSQL or PrepareSQL. This method is ideal for results
paging.Sample Input XML<soap:Envelope>
<soap:Body>
<GetResultsRequest>
<WuId>W20140529-161930</WuId>
<SuppressXmlSchema>1</SuppressXmlSchema>
<ResultWindowStart>0</ResultWindowStart>
<ResultWindowCount>0</ResultWindowCount>
</GetResultsRequest>
</soap:Body>
</soap:Envelope>Request Tag DescriptionsTag NameReq?DescriptionGetResultsRequestYStructure containing the request WuIdYWorkunit Id (WUID) SuppressXmlSchemaNIf set to 1 or true, the query result schema is not
included in response ResultWindowStartNFor use with page-loading, the starting record to
return ResultWindowCountNFor use with page-loading, the number of records to
include from the ResultWindowStartResponse Tag DescriptionsTag NameDescriptionGetResultsResponseStructure containing response ExceptionsStructure containing exceptions. See Exceptions Structure in
Common Structures ResultThe query result ResultWindowStartThe submitted starting record ResultWindowCountThe submitted record count WorkunitStructure containing Workunit details. See Workunit Structure in Common
StructuresPrepareSQLUse this method to submit a free-hand SQL request for later use as
a parameterized query. This compiles the query and returns the Wuid. This Wuid
is later used to execute the query with provided input parameters using
the ExecutePreparedSQL method.This is ideal for queries which are executed many times with
different values.The prepared SQL can contain any supported SQL grammar.If you are executing SQL using a SELECT or SELECT JOIN, you must
specify the TargetCluster.If you using a CALL to a stored procedure, you must either fully
qualify the procedure name in the SQL (For example:
Roxie.FindPeopleByZip) or specify the TargetQuerySet here. Parameters must be passed in
order, not by name. You can retrieve the order using
GetDBMetaData.Create parameters using a ? as a placeholder.Example:select * from tutorial::yn::tutorialperson where lastname=?Later
you would submit a request to ExecutePreparedSQL providing a value to use for
lastname as shown in the following example:<soap:Envelope >
<soap:Body>
<ExecutePreparedSQLRequest>
<WuId>W20140724-135811</WuId>
<TargetCluster>thor</TargetCluster>
<SuppressResults>0</SuppressResults>
<SuppressXmlSchema>1</SuppressXmlSchema>
<resultLimit>100</resultLimit>
<Variables>
<NamedValue>
<Name>lastname</Name>
<Value>JONES</Value>
</NamedValue>
</Variables>
</ExecutePreparedSQLRequest>
</soap:Body>
</soap:Envelope>Sample Input XML<soap:Envelope >
<soap:Body>
<PrepareSQLRequest>
<SqlText>select * from tutorial::yn::tutorialperson where lastname=?</SqlText>
<!-- Use either TargetCluster or TargetQuerySet, not both --><!-- If stored procedure is fully qualified, you can omit TargetQuerySet -->
<TargetCluster>thor</TargetCluster>
</PrepareSQLRequest>
</soap:Body>
</soap:Envelope>Request Tag DescriptionsTag NameReq?DescriptionPrepareSQLRequestNStructure containing request SqlTextYFree-hand SQL text (see Supported SQL grammar
below) TargetClusterY *If you are executing prepared SQL using a SELECT or
SELECT JOIN, you must specify the TargetCluster TargetQuerySetY *If you are executing prepared SQL that uses a CALL to
a stored procedure, you must either fully qualify the
procedure name in the prepared SQL (For example:
Roxie.FindPeopleByZip) or specify the TargetCluster
here WaitNTimeout value in milliseconds. Use -1 for no
timeout* One or the other is
requiredResponse Tag DescriptionsTag NameDescriptionPrepareSQLResponseStructure containing response ExceptionsStructure containing exceptions. See Exceptions Structure in
Common Structures WorkunitStructure containing Workunit details. See Workunit Structure in Common
Structures ResultStructure containing result (if any)ExecutePreparedSQLThis method executes a previously created parameterized SQL
query.The target compiled query is referenced using a Workunit ID
(Wuid), which is returned from the
PrepareSQL method. The caller can
specify sequence of input parameters as key-value pairs, which are bound
to the precompiled query.The prepared SQL can contain any supported SQL grammar.If you are executing prepared SQL using a SELECT or SELECT JOIN,
you can supply a TargetCluster to
override the one specified when you submitted the PrepareSQL request;
however, it must be a cluster of the same type.If you want to limit the number of results, you must use a LIMIT
clause in you SQL query.For result set paging, you can limit the total query results and
the initial page returned (ResultWindowStart, ResultWindowCount).Sample Input XML<soap:Envelope>
<soap:Body>
<ExecutePreparedSQLRequest>
<WuId>W20140529-161930</WuId>
<UserName>EmilyKate</UserName>
<!-- You can override the TargetCluster used in original PrepareSQL query, -->
<!-- but it must be of the same type -->
<TargetCluster>Thor</TargetCluster>
<SuppressResults>0</SuppressResults>
<SuppressXmlSchema>1</SuppressXmlSchema>
<Wait>-1</Wait>
<!-- For page loading -->
<ResultWindowStart>0</ResultWindowStart>
<ResultWindowCount>50</ResultWindowCount>
<!-- Paramaters using name/value pairs -->
<Variables>
<NamedValue>
<Name>firstname</Name>
<Value>Jim</Value>
</NamedValue>
<NamedValue>
<Name>lastname</Name>
<Value>JONES</Value>
</NamedValue>
</Variables>
</ExecutePreparedSQLRequest>
</soap:Body>
</soap:Envelope>
Request Tag DescriptionsTag NameReq?DescriptionExecutePreparedSQLRequestNStructure containing the request WuIdYThe Workunit ID (WUID) UserNameNThe username to use as the job's ownername in the
HPCC platform TargetClusterYIf you are executing prepared SQL using a SELECT or
SELECT JOIN, you can specify the TargetCluster, but it must
be the same type as the one on which it was prepared SuppressResultsNIf set to 1 or true, query results are not included
in response SuppressXmlSchemaNIf set to 1 or true, the query result schema is not
included in response WaitNTimeout value in milliseconds. Use -1 for no
timeout. ResultWindowStartNFor use with page-loading, the starting record to
return ResultWindowCountNFor use with page-loading, the number of records to
include from the ResultWindowStart VariablesNIf your prepared SQL has parameters, supply them as
name/value pairs inside this structure NamedValueNA structure containing one Name/Value pair NameNName ValueNValueResponse Tag DescriptionsTag NameDescriptionExecutePreparedSQLResponseStructure containing response ExceptionsStructure containing exceptions. See Exceptions Structure in
Common Structures ParentWuIdThe Workunit ID for the parent workunit (the one with
the prepared SQL) ResultThe query result ResultWindowStartThe submitted starting record ResultWindowCountThe submitted record count WorkunitStructure containing Workunit details. See Workunit Structure in Common
StructuresCreateTableAndLoadThis method creates a table (HPCC logical file) which can
subsequently be accessed using WsSQL. The table is assigned the layout
as specified in the request ECLFields section. The table is then
populated with data from an existing file. The source data file can
either reside on the HPCC Landing Zone after being uploaded, or it can
already have been sprayed on to the system.Sample Input XML<CreateTableAndLoadRequest>
<TableName>JIM::MyNewTable</TableName>
<TableDescription>My Description of the new table</TableDescription>
<Overwrite>1</Overwrite>
<EclFields>
<EclField>
<FieldName>PersonName</FieldName>
<EclFieldType>
<!-- Valid types are: BOOLEAN, INTEGER,UNSIGNED, REAL, DECIMAL, STRING, -->
<!-- QSTRING, UNICODE, DATA, VARSTRING, or VARUNICODE -->
<Type>STRING</Type>
<Locale></Locale>
<Length>20</Length>
<Precision></Precision>
</EclFieldType>
</EclField>
<EclField>
<FieldName>PersonID</FieldName>
<EclFieldType>
<Type>INTEGER</Type>
<Locale></Locale>
<Length>2</Length>
<Precision></Precision>
</EclFieldType>
</EclField>
</EclFields>
<TargetCluster>thor</TargetCluster>
<Owner>Jimmy</Owner>
<DataSource>
<!-- Use either SprayedFileName -->
<SprayedFileName>Tutorial::JD::OriginalPerson</SprayedFileName>
<!-- or full Landing Zone details, not both -->
<LandingZoneIP>127.0.0.1</LandingZoneIP>
<LandingZonePath>/var/lib/HPCCSystems/mydropzone</LandingZonePath>
<LandingZoneFileName>OriginalPerson</LandingZoneFileName>
</DataSource>
<DataSourceType>
<!-- Valid types are: FLAT, CSV, JSON, or XML -->
<Type>FLAT</Type>
<Params>
<Param>
<Name></Name>
<Values>
<Value></Value>
<Value></Value>
</Values>
</Param>
</Params>
</DataSourceType>
<Wait>-1</Wait>
</CreateTableAndLoadRequest>
Request Tag DescriptionsTag NameReq?DescriptionTableNameYThe name of the table to create in the HPCC
Platform's distributed file system. TableDescriptionNYour description of the file. OverwriteNBoolean indicator to specify whether to allow the new
file to overwrite an existing file of the same name. EclFieldsYStructure containing details for the file's record
layout. This must match layout of the source data
file EclFieldYStructure containing details for one field FieldName YField Name EclFieldTypeYStructure containing Data Type details TypeYField type. Valid types are: BOOLEAN, INTEGER,
UNSIGNED, REAL, DECIMAL, STRING, QSTRING, UNICODE, DATA,
VARSTRING, or VARUNICODE Locale NLocale LengthY*Field length PrecisionNField precision (decimal places) TargetClusterYThe Target cluster where the job will run. OwnerNOwner name for the file DataSourceYStructure containing Data Source details. Either
SprayedFileName or LandingZone File details must be
provided, not both. SprayedFileNameY**Logical filename of sprayed data file LandingZoneIPY**IP address or hostname of the HPCC Landing
Zone LandingZonePathY**Path to the datafile on the Landing Zone LandingZoneFileNameY**Physical filename DataSourceTypeNStructure containing DataSource Type details. TypeYValid types are: FLAT, CSV, JSON, or XML ParamsNStructure containing one or more type parameters that
describe the DataSource. For example, CSV Terminator =
\n ParamNStructure containing one type parameter. NameNName ValuesNStructure containing one or more values. ValueNValue WaitNTimeout value in milliseconds. Use -1 for no
timeout* Field length is only required for fixed
width fields (FLAT files)** Either SprayedFileName or LandingZone
File details must be provided, not bothResponse Tag DescriptionsThe response structure contains many tags which provide useful
information for development and debugging of ECL code. Most of them
are outside of the scope of this document. Only those that are useful
when using the WsSQL service are listed below.Tag NameDescriptionCreateTableAndLoadResponseStructure containing response TableNameName of the created table SuccessBoolean indicator of success [1 = success] EclRecordDefinitionSupplied record definition in ECL format WorkunitStructure containing Workunit details. See Workunit Structure in Common
StructuresSetRelatedIndexesThis function adds a description to a logical file to be used as
an annotation indicating an index file which is related to a data file.
This makes it available to WsSQL for use in an indexed fetch.Sample Input XML<SetRelatedIndexesRequest>
<RelatedIndexSets>
<RelatedIndexSet>
<FileName>Tutorial::JD::TutorialPerson</FileName>
<Indexes>
<Index>Tutorial::JD::TutorialPersonByName</Index>
<Index>Tutorial::JD::TutorialPersonByZIP</Index>
</Indexes>
</RelatedIndexSet>
<RelatedIndexSet>
</SetRelatedIndexesRequest>
Request Tag DescriptionsTag NameReq?DescriptionSetRelatedIndexesRequestStructure containing request RelatedIndexSetsYStructure containing one or more related index
sets RelatedIndexSetYStructure containing one related index set FileNameYLogical filename to which the annotation is
added IndexesYStructure containing one or more indexes to add to
annotation IndexYIndex to add to annotationResponse Tag DescriptionsTag NameDescriptionSetRelatedIndexesResponseStructure containing response RelatedIndexSetsStructure containing one or more related index
sets RelatedIndexSetStructure containing one related index set FileNameLogical filename to which the annotation was
added IndexesStructure containing one or more indexes added to
annotation IndexIndex added to annotationGetRelatedIndexesThis function retrieves information from logical file descriptions
about annotations indicating an index file which is related to a data
file.Sample Input XML<GetRelatedIndexesRequest>
<FileNames>
<FileName>Tutorial::JD::TutorialPerson</FileName>
</FileNames>
</SetRelatedIndexesRequest>
Request Tag DescriptionsTag NameReq?DescriptionSetRelatedIndexesRequestStructure containing request FileNamesYStructure containing one or more related index
sets FileNameYLogical filename to which the annotation is
addedResponse Tag DescriptionsTag NameDescriptionGetRelatedIndexesResponseStructure containing response RelatedIndexSetsStructure containing one or more related index
sets RelatedIndexSetStructure containing one related index set FileNameLogical filename to which the annotation was
added IndexesStructure containing one or more indexes added to
annotation IndexIndex added to annotationCommon StructuresThese structures are returned in several methods.Exceptions StructureTag NameDescriptionExceptionsStructure containing one or more exceptions ExceptionStructure containing one exception CodeCode AudienceAudience SourceSource component MessageError messageWorkunit StructureThe workunit structure contains many tags which provide useful
information for development and debugging of ECL code. Most of them
are outside of the scope of this document. Only those that are useful
when using the WsSQL service are listed here.Tag NameDescriptionWorkunitStructure containing Workunit details WuidWorkunit Id (WUID) OwnerJob Owner (if any) ClusterTarget Cluster JobnameJob Name (If any) StateIDState ID StateState (compiled, failed, etc) ProtectedBoolean indicator: Is Workunit protected? SnapshotSnapshot IsPausingBoolean indicator of pause state ThorLCRBoolean indicator EventScheduleBoolean indicator TotalCLusterTimeTime taken to process on cluster QueryQuery ResultStructure containing result (if any)Supported SQL GrammarCALLCall
queryName
([paramList])queryNameThe published query name or aliasparamListThe parameters exposed by the published query
(comma-separated)Call executes a published ECL query as if it were a stored
procedure.Example:Call SearchPeopleByZipService ('33024')SELECTselect [distinct]colummListfromtableList [USE
INDEX(indexFileName | NONE
)][wherelogicalExpression][group bycolumnList1][havinglogicalExpression2][order bycolumnList1[asc |
desc]] [LIMIT limitNumber]NOTE:Identifiers can be unquoted or within double quotes, literal
string values must be single quoted.columnListcolumnreference1[,columnreference2,columnreference3,...,columnreferencen]The column(s) to return (comma-separated list). In
addition, these aggregate functions are supported : COUNT,
SUM, MIN, MAX, and AVG. These work in a similar manner as
their ECL counterpartscolumnreference[tablename.]columnname[ [AS] alias ]distinct[distinct] col1, col2,...
colnThe result set will only contain distinct (unique)
valuestableListtableref1[,tableref2,tableref3,...,tablerefn]One or more tables, separated by commas.NOTE: A table list
with multiple tables creates an (one or more) implicit inner
join using the where clause logical expression as the join
condition which must contain an equality conditiontablereftableName[ [AS] alias ]The Name of the table as referenced, optionally
defining its aliasaliasThe alias used to refer to the corresponding table or
field reference.logicalExpressionLogical expression based on standard SQL filtering
syntax.BOOLEAN Only supports True or
False, do not use Y, N, 0, or 1Valid
operators:= Equal (e.g., age=33)<> Not equal (e.g., age <>33)> Greater than (e.g., age >55)< Less than (e.g., age < 18)>= Greater than or equal (e.g., age >=21)<= Less than or equal (e.g., age <=21)IN(value1,value2,...,valuen) where
values are comma separated homogeneous typesNOT IN(value1,value2,...,valuen)
where values are comma separated homogeneous typesLIKE pattern where the pattern
uses SQL LIKE operators with % and _ wildcards.NOT LIKE pattern where the pattern
uses SQL LIKE operators with % and _ wildcards.limitNumberThe number of rows to return. This overrides the
default configuration attribute (EclResultLimit ) but cannot
be set to ALL1Aliasing not
supported2Can only contain references to
aggregate functionsif used with
having clause.Aggregate functions can only be expressed in logicalExpressions by
using Group byand
havingExamples:Select * from tableList where Sum(F1 > 100) /* is NOT SUPPORTED */
Select * from tableList Group by F1 Having Sum (F1 > 100) /* IS SUPPORTED */Example:Select fname, lname, state from TutorialPerson where
state='FL' OR (lname='Smith' and fname='Joe')
//returns data that looks like this:
John Doe FL
Jim Smith FL
Jane Row FL
Joe Smith CA
Select fname, lname, state from TutorialPerson where state='FL' AND lname <> 'Smith'
//returns data that looks like this:
John Doe FL
Jane Row FL
Select fname, lname, state from TutorialPerson where state='FL' AND lname like 'Smi%'
//returns data that looks like this:
Jim Smith FL
Select fname, lname, state from TutorialPerson where
state='FL' OR (lname='Smith' and fname='Joe') AND fname NOT LIKE 'Ji%'
//returns data that looks like this:
John Doe FL
Jane Row FL
Joe Smith CA
The interface supports SQL index hints, which gives the SQL user
the option to specify the most appropriate HPCC index for the current
SQL query. This also allows you to disable the use of an index.select
columnList from
tableName USE
INDEX(hpcc::index::file::name) where logicalExprssions
USE INDEX(none) forces the system
to avoid seeking an index for the current query.Example:Select fname, lname, zip, state from TutorialPerson
USEINDEX(TutorialPersonByZipIndex)where zip='33024'
//returns data that looks like this:
John Doe FL 33024
Jim Smith FL 33024
Jane Row FL 33024
A Select query returns two dataset outputs per request. The second
dataset (named WsSQLCount) provides the total result count. This is
useful when paging results.Example:<Dataset name='WsSQLResult'>
<Row>
<yearbuilt>1203</yearbuilt>
<id>4</id></Row>
<Row>
<yearbuilt>2003</yearbuilt>
<id>5</id></Row>
</Dataset>
<Dataset name='WsSQLCount'>
<Row>
<WSSQLSelectQueryResultCount>2</WSSQLSelectQueryResultCount>
</Row>
</Dataset>SELECT JOINselect
colummListfromtableName [as alias][<outer | inner > JOIN join TableName
[ as
alias] on
joinCondition][USE INDEX(indexFileName | NONE
)][wherelogicalExpression] [group
byfieldName][order bycolumnNames
[asc | desc]] [LIMIT limitNumber]columnListcolumnreference1[,columnreference2,columnreference3,...,columnreferencen]The column(s) to return (comma-separated list). In
addition, these aggregate functions are supported : COUNT,
SUM, MIN, MAX, and AVG. These work in a similar manner as
their ECL counterparts.columnreference[tablename.]columnname[ [AS] alias ]distinct[distinct] col1, col2,...
colnThe result set will only contain distinct (unique)
values.aliasThe alias used to refer to the corresponding table or
field reference.outer | innerThe type of JOIN to use. Note: The WsSQL service
currently supports INNER JOIN or OUTER Joins. An OUTER JOIN is
converted to a FULL OUTER JOIN internally.joinTableNameThe JOIN file to use.joinConditionSpecifies the relationship between columns in the
joined tables using logical expression.logicalExpressionLogical expression based on standard SQL filtering
syntax.BOOLEAN Only supports True or
False, do not use Y, N, 0, or 1.Valid
operators:= Equal (e.g., age=33)<> Not equal (e.g., age <>33)> Greater than (e.g., age >55)< Less than (e.g., age < 18)>= Greater than or equal (e.g., age >=21)<= Less than or equal (e.g., age <=21)IN(value1,value2,...,valuen) where
values are comma separated homogeneous types.NOT IN(value1,value2,...,valuen)
where values are comma separated homogeneous types.LIKE pattern where the pattern
uses SQL LIKE operators with % and _ wildcards.NOT LIKE pattern where the pattern
uses SQL LIKE operators with % and _ wildcards.limitNumberOptional. The number of rows to return. This overrides
the default configuration attribute (EclResultLimit ) but cannot be set to
ALL.1Aliasing not supported2Can only contain references to
aggregate functionsif used with
having clause.Aggregate functions can only be expressed in logicalExpressions by
using Group byand
havingExamples:Select * from tableList where Sum(F1 > 100) /* is NOT SUPPORTED */
Select * from tableList Group by F1 Having Sum (F1 > 100) /* IS SUPPORTED */Example:Select t1.personname, t2.address
from persontable as t1 inner join addresstable as t2
on (t1.personid = t2.personid AND
(t1.firstname = 'jim' AND
t1.lastname = 'smith' )) The interface does not convert parameter list or column list
values to string literals.String values should be single quote encapsulated. Field
identifier can be left unquoted or double quoted.For example, the table persons
has columns lastname(String) and Zip (numeric)Select Firstname from persons where lastname = 'Jones' and zip > 33445 /* works */
Select Firstname from persons where lastname = 'Jones' and "zip" > 33445 /* also works */
Select Firstname from persons where lastname = Jones and zip > 33445 /* doesn't work */
Select Firstname from persons where lastname = 'Jones' and zip > '33445' /* doesn't work */CREATE / LOADcreate table[if not exists]newtablename'('(fieldname(fieldtype[fieldlen[,precision]][UNSIGNED][,]
))+')'[comment 'commenttext'][;]load data infile
'sourcetablename' [connection 'landingzoneIP'
directory
'landingzonepath']into tablenewtablename
[(fields | columns) [ terminated by
'fieldDelimiter']
[ enclosed by 'quoteChar'] [ escaped by
'escapeChar']]][lines [ terminated by
'recordDelimiter']][;]The CREATE TABLE and LOAD DATA SQL statements allow you to create
a file in an HPCC cluster that is accessible via WsSQL. You can populate
the new file from data in a logical file already on the HPCC cluster or
one that is on a landing zone.All Create requests MUST be accompanied by a Load request. You
cannot create a table with the intention to load or insert data
later.newtablenameThe logical filename to create on the HPCC cluster.
Note: Create and Load must
target the same file.commenttextA text comment to add to the logical file's
descriptionsourcetablenameThe source file from which to extract data to load into
the new table. This can be a logical file on an HPCC cluster
or a physical file on a landing zone. For a landing zone file,
you MUST provide a connection
'landingzoneIP' and a directory
'landingzonepath' (the path to the file).
For a landing zone file, be sure to use matching case for the
filename.landingzoneIPThe IP Address or hostname of the HPCC Landing
ZonelandingzonepathThe path to the datafile on the Landing ZonebutfieldDelimiterString value for field delimiterquoteCharString Value for the quote characterescapeCharString Value for the escape characterrecordDelimiterString value for record delimiterExamples:CREATE TABLE newCustomerFile (id DECIMAL( 30, 5), mytint INT(9),
mydouble DOUBLE (5,3) UNSIGNED)
COMMENT 'this file created via WsSQL and populated from file on lz';
LOAD DATA INFILE 'CustomerData' CONNECTION '127.0.0.1'
DIRECTORY '/var/lib/HPCCSystems/mydropzone'
INTO TABLE newCustomerFile;
CREATE TABLE newCustomerFile2 (id DECIMAL( 30, 5), mytint INT(9),
mydouble DOUBLE (5,3) UNSIGNED)
COMMENT 'this file created via WsSQL and populated from sprayed file';
LOAD DATA INFILE 'thor::customerdata::customers' INTO TABLE newCustomerFile2
CREATE TABLE IF NOT EXISTS newCustomerFile3 (id DECIMAL( 30, 5), mytint INT(9),
mydouble DOUBLE (5,3) UNSIGNED)
COMMENT 'won't overwrite';
LOAD DATA INFILE 'thor::customerdata::customers' INTO TABLE newCustomerFile3
CREATE TABLE newCustomerFile4CSV (id DECIMAL( 30, 5), mytint INT(9),
mydouble DOUBLE (5,3) UNSIGNED)
COMMENT 'Loading CSV data';
LOAD DATA INFILE 'somecsvfile.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY 'n'
INTO TABLE newCustomerFile4CSV
Supported Aggregate FunctionsCOUNT([DISTINCT]columnName)DISTINCT(columnName)SUM(columnName)MIN(columnName)MAX(columnName)AVG(columnName)These aggregate functions are supported. They behave as their ECL
counterparts. See the ECL Language
Reference for details.COUNTCounts the occurrences of columnName in the result,
always an integer.DISTINCTReturns only distinct values of columnName in the
result, output type is dependent on input type.SUMReturns the sum of the values of columnName in the
result, output type is dependent on input type.MINReturns the minimum value for of columnName in the
result, output type is dependent on input type.MAXReturns the minimum value for of columnName in the
result, output type is dependent on input type.AVGReturns the average of the values of columnName in the
result, always a real number.columnNameThe column to aggregate.Example:Select fname, lname, state, COUNT(zip) from TutorialPerson where zip='33024'Supported String ModifiersUPPER(columnName)LOWER(columnName)UPPERReturns with all lower case characters converted to
upper case.LOWERReturns with all upper case characters converted to
lower case.columnNameThe column to aggregateSpecial considerationsSince this service uses both ECL and SQL, there are a few
special considerations when designing the backend databases and stored
procedures.Reserved SQL KeywordsYour HPCC identifiers (field names, Stored Procedure names,
etc) cannot use SQL reserved words such as:ADD ALL ANY AS ASC AT AVG BETWEEN BOOL BOOLEAN BY CALL COLUMN CONTAINS COUNT
DESC DISTINCT FALSE FOR FROM GROUP HAVING IN INDEX INNER IS JOIN KEY KEYS LAST
LEFT LIKE LIMIT LOWER MAX MIN MOD NOT NULL OFFSET ON ORDER OUT OUTER POWER SELECT
SUM TABLE TRUE UPPER USE WHERE XOR DIV MOD OR ANDSpecial CharactersYour HPCC filenames should avoid special characters other
than:( 'A'..'Z' | 'a'..'z' | '' | '$') ( 'A'..'Z' | 'a'..'z' | '' | '$' | '0'..'9' )
File names can be prefixed with a ~ (tilde) or .::
If a filename is not supported, it will not be returned when
interrogating the system using GetDBMetaData.