Sub string projection

Projection – Abstract

Purpose: Returns a section from a string determined by a projection.

images/download/attachments/78258012/image-2023-10-16_9-47-13-version-1-modificationdate-1697442433234-api-v2.png

The Sub string projection returns a section from a string determined by the Projection.

The optional Begin index and Max. length parameters control which section of the return value from the projection is returned as a 'substring'.

Configuration


images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg CAUTIONimages/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg Depending on the database system used, the results of a Sub string projection can vary significantly. The user interface presented here technically allows parameterizations that only work on certain databases.

The documentation in the following section is limited to parameter combinations that provide the described results regardless of the database system used.

Different parameter combinations are technically feasible in practice, provided that the desired results are achieved in tests with the database system used.

However, it should be remembered that if the database system for an existing implementation is changed at a later date, or if solution components are exchanged between Lobster Data Platform / Orchestration systems that use different database systems, serious malfunctions and significant deviations from targeted processing logics may then occur, the cause of which may only be localizable with considerable effort and may not be completely remedied in the context of the 'alternative' database system.


In the following table, the green shaded cells refer to the use of the parameters, which should be guaranteed regardless of the database system.
The yellow shading, on the other hand, indicates references to the use of the parameters outside the 'strict' default.

Parameter

Type

Description

Name
optional


String

The Name parameter optionally defines an alias name for the projection. If no Name is specified, the name of the Projection with the static prefix 'substring of ' will be used as the name.

Projection
optional

String

A Projection (see Projections) of any type (e.g. also a Literal projection) can be used as a projection as long as it returns a String value.

  • If no Projection is defined, the Sub string projection returns an empty string ("") as a value, regardless of the other parameterization.

If the projection returns a data type other than a String, a type conversion to a String takes place or an error occurs, depending on the data type and the database system.
NOTE◄ If a database system does not accept the values of a data type other than the String supplied by a Projection at runtime, it may be possible to force an explicit type conversion to a String by concatenating the given projection configuration within a Concatenated projection with an empty string. This step can help in a specific application scenario to avoid a termination of the search with an error and may also achieve the desired result. However, the fact that this type conversion provides consistent results in the context of a different database system should not be assumed without being checked. The results of certain type conversions may additionally depend on settings for the specific database (e.g. a certain pattern for representing date values as a string).

Begin index
optional

Integer

The Begin index defines the position within the sequence obtained from the Projection via an Integer value, from which a substring is taken over for the return value.

  • A Begin index of 1 refers to the first character from the Projection.

  • The Begin index can point to a line item after the end of the sequence obtained from the Projection. Then an empty string ("") is returned.

A positive Integer value must be available as the Begin index at runtime so that the result of the Sub string projection does not depend on database-specific peculiarities.

  • By default, direct input is offered for a statically specified Integer constant (per Text field with numeric stepper).

  • To assign a dynamically specified Integer constant at runtime instead, it is possible to switch to the general value configuration (see small gray arrow in the Text field).
    IMPORTANT◄ The value configuration may only return the Integer data type. Even a long value is rejected as 'incorrect' depending on the database system. A concatenated Input object (type safe) resolver with the Integer type can be helpful.

  • In addition, a projection (Projections) can be used to define the Begin index within the search via a variable Integer value.
    NOTE◄ For Projections there is an option for an explicit type conversion to Integer. The options for an unrestricted projection for the Begin index are therefore mostly limited.

If there is no value ($null), the value 0, a negative value or a type other than Integer for the Begin index, it is not possible to assume a uniform result for different database systems.
NOTE◄ Some database systems interpret a negative Begin index as an offset from the end of the evaluated string.

Max. length
optional



Integer

The Max. length parameter defines an upper limit for the length of the string in the return value via an Integer value. However, the returned 'substring' ends with the last character from the Projection at the latest.

  • When waiving a value configuration, all characters starting from the item referenced by the Begin index are returned if a positive start index is present.

The same options and restrictions apply for the parameterization as for the Begin index.

If there is no value ($null), a negative value or any type other than Integer for the Begin index, it is not possible to assume a uniform result for different database systems.

Examples

Simple example: Concatenate country code and postal code area

Based on the 'country' (countryCode) and 'ZIP code' (zipcode) properties, a composite code for the REGION is formed in the context of a tuple search, by which the search result can be sorted or filtered, for example.

Specifically, the first two digits (or characters) of the 'ZIP code' are concatenated with the internal abbreviation for Country to obtain a four-digit code when both fields are properly populated.

The table on the right shows sample data for a selection of cities in Germany and Switzerland in the first column (REGION).

REGION,AREA,CITY
=====================================
CH20,Neuchâtel,Bevaix
CH90,Kanton St. Gallen,St. Gallen
DE17,Mecklenburg-Vorpommern,Meiersberg
DE27,Niedersachsen,Varrel
DE39,Sachsen-Anhalt,Holzhausen
DE46,Nordrhein-Westfalen,Xanten
DE54,Rheinland-Pfalz,Bruch
DE67,Rheinland-Pfalz,Fußgönheim
DE68,Nordrhein-Westfalen,Mannheim
DE77,Baden-Württemberg,Mühlenbach
DE82,Bayern,Huglfing
DE84,Bayern,Au in der Hallertau
DE84,Bayern,Schwindegg
DE92,Bayern,Kastl

Configuration:

The screenshot on the right shows the configuration for the projection of the first column (REGION):

  • In the second element of the Concatenated projection, the Sub string projection extracts the first two characters from the 'ZIP code' (zipcode) property:

    • The Projection uses a Property projection to read the ZIP code.

    • The Begin index refers to the first character (1).

    • The Max. length (2) limits the number of characters to be returned.

images/download/attachments/78258012/image-2023-10-16_9-49-3-version-1-modificationdate-1697442543506-api-v2.png

More complex example: A variable number of digits depending on the length of the ZIP code

Based on the previous use case, a variable number of leading digits from the ZIP code (zipcode) is now transferred to the identifier for the REGION, depending on the 'country' (countryCode),

Specifically, only the first digit of four-digit ZIP codes is transferred, and the first two characters of all other ZIP codes.

Configuration:

The screenshot shows the customized configuration for the ZIP code component within the Concatenated projection for the REGION column:

  • The Projection still uses a Property projection to read the ZIP code.

  • The Begin index statically refers to the first character (1).

  • The Max. length is determined this time via a Case projection individually for each evaluated ZIP code:

images/download/attachments/78258012/image-2023-10-16_9-51-49-version-1-modificationdate-1697442709091-api-v2.png

Runtime example:

REGION,AREA,CITY
======================================
AT2,Niederösterreich,Immendorf
CH2,Neuchâtel,Bevaix
CH9,Kanton St. Gallen,St. Gallen
DE27,Niedersachsen,Varrel
DE39,Sachsen-Anhalt,Holzhausen
DE46,Nordrhein-Westfalen,Xanten
DE54,Rheinland-Pfalz,Bruch
DE68,Nordrhein-Westfalen,Mannheim
DE77,Baden-Württemberg,Mühlenbach
DE84,Bayern,Schwindegg
ES30,Murcia,Gibraltar
ES36,Galicia,Vigo
FR54,Grand-Est,Nancy
FR69,Auvergne-Rhône-Alpes,Lyon
GBRG,England,Reading
IEF1,,Knock
IT02,Lazio,Collalto Sabino
IT16,Liguria,Genova
TR35,İzmir,Aliağa