SemQL language
SemQL is a language used to express declarative rules in xDM, in the form of SQL-like clauses.
It is used to define:
-
Enrichers, matchers, validations, and survivorship rules involved in the certification process.
-
Conditions in workflow definitions.
-
Composite and transformed attributes in an application’s forms and collections.
-
Filters when browsing data in the data hub.
Main characteristics
The characteristics of SemQL include:
-
Its syntax mirrors that of the SQL language, with most SemQL functions aligning with database functions.
-
SemQL is dynamically converted and executed by the data hub database.
-
SemQL uses qualified attribute names instead of column names, which makes the SemQL code independent from underlying implementations.
SQL-like clauses
The SemQL language allows users to define SQL-like clauses. Depending on the context, clauses can be:
-
Conditions: clauses that return a boolean result from the evaluation of expressions using operators. A condition can be used for filtering or validating data records. For example, if the clause is false, then the record is filtered out or considered invalid.
-
Expressions: clauses that return a value. In the context of a SemQL enricher, an expression transforms, standardizes and enriches source attributes.
-
ORDER BY
clauses: clauses used for sorting records. In consolidation rules, they are used to manage conflicts. For example, in a consolidation by "most frequent value", SemQL in the ranking expression determines the value used when multiple values occur with equal frequency.
SemQL exclusively handles expressions, conditions, and ORDER BY clauses. The language does not support SELECT , UPDATE , and INSERT queries nor joins, sub-queries, aggregates, in-line views, and set operators.
|
Even though SemQL looks like SQL, SemQL expressions are entirely parsed and rewritten by the Semarchy xDM platform as SQL before their execution by the hub database. A simple SemQL expression may result in a complex SQL statement. Hence, it is not recommended to inject SQL statements within SemQL expressions. |
Attributes, variables, and parameters
SemQL clauses manipulate attributes, variables, and parameters defined in objects of the Semarchy xDM model.
For example:
-
The
firstName
attribute of thecustomer
entity. -
The
productFamilyName
parameter of thesearchProductByFamily
search form.
Attributes are accessed through an unambiguous qualified attribute name. The qualified attribute name is the path to an attribute from the entity being processed.
This path allows you to navigate the references that link the entities of a model. For example, manager.lastName
returns the last name of the manager of an employee record.
Functions
Built-in functions are available in SemQL, most of which directly correspond to functions of the hub’s database. Other functions, like matching functions, are specific to Semarchy xDM.
Additionally, customized functions implemented in the database can be used in SemQL.
SemQL editor
The SemQL editor is used in both the Application Builder and Workflow Builder.
SemQL editor in the Application Builder
In the Application Builder, the SemQL editor is used for writing SemQL conditions, expressions, and clauses.
The editor lists the attributes, variables, and parameters, as well as all built-in and customized SemQL functions with their syntax.
The editor is organized as follows:
-
Attributes that can be included in an expression are listed in the left panel.
Double-click an attribute to add it to the expression. -
Functions declared in SemQL are displayed in the left bottom panel and categorized into function groups.
Double-click a function to add it to the expression. -
Variables that can be included in an expression are listed in the bottom center panel.
-
Messages are displayed in the right bottom panel, showing parsing errors and warnings.
-
A description of the selected function or attribute appears at the bottom of the editor.
-
The toolbar allows indenting the code, hide or display the various panels of the editor, and undo or redo code edits.
SemQL Editor in the Workflow Builder
In the Workflow Builder, the SemQL editor is used to write SemQL conditions and expressions.
The editor lists the attributes and variables, as well as all built-in and customized SemQL functions with their syntax.
The editor is organized as follows:
-
Attributes, functions, and variables available for the current statement appear in the left panel.
Double-click an element to add it to the condition or the expression.To switch between attributes, functions, and variables, select the corresponding element in the action menu above the tree view. You can enter text in the input field to search among elements of the selected type. -
Problems appear in the right bottom panel, showing parsing errors and warnings.
SemQL conditions are used in user tasks, routers, and parallel blocks. SemQL expressions are used in automations. |