SemQL Language
SemQL is a language to express declarative rules in Semarchy 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 form and collections appearing in the applications.
-
Filters when browsing data in the data hub.
Main Characteristics
The characteristics of the SemQL language are:
-
The syntax of the SemQL language is similar to that of the SQL language. Most SemQL functions map to database functions.
-
SemQL is converted on the fly and is executed by the data hub database.
-
SemQL uses qualified attribute names instead of column names. This makes the SemQL code independent from the underlying implementation.
SQL-Like Clauses
The SemQL language allows users to define SQL-like clauses. Depending on the context, the 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 to sort records. In consolidation rules, such clauses are used to manage consolidation conflicts. For example, consider a consolidation made by Most Frequent Value. When multiple values occur with equal frequency, the SemQL in the Ranking Expression determines the value that is used.
SemQL is only used for expressions, conditions and order by clauses. The language neither supports the 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
You can use built-in functions in SemQL. Most of these functions map directly to functions of the hub’s database. Other functions (for example, matching functions) are specific to Semarchy xDM.
In SemQL, you can also use customized functions implemented in the database.
SemQL Editor
The SemQL editor is used in the Application Builder and Workflow Builder.
SemQL Editor in the Application Builder
In the Application Builder, the SemQL editor is used to write 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 available for the expression appear in the left panel. Double-click an attribute to add it to the expression.
-
Functions declared in SemQL appear in the left bottom panel, grouped in function groups. Double-click a function to add it to the expression.
-
Variables available for the expression appear in the bottom center panel.
-
Messages appear 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 to indent the code or hide/display the various panels of the editor and to undo/redo code edits.
SemQL Editor in the Workflow Builder
In 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. |