Saturday, 16 March 2019 00:14

Altering AST in component-style IKM Featured

Written by
Rate this item
(0 votes)

As the name suggests, "SQL Structured Substitution API" provides a more straightforward and structured way of generating code using ODI knowledge modules. In the documentation and examples provided by Oracle, the following pattern is used to generate code:

  1. Variables are created and initialized using Groovy code in Groovy Task-local and/or Groovy KM-local sections of KM steps. In the Groovy code present on the examples, I have found that only read functions are used. I didn't find any example where the AST (i.e. the various objects exported using INSERT, QUERY and so on variables) is manipulated.
  2. The variables mentioned above are then used on the Command Text section of KM steps to generate the code.

Therefore when we need to change the statement generated by an IKM we can do it by writing our custom code in some Groovy variables and then use these variables in the Command Text section. It is also possible to write text directly in the Command Text section. There is also a third possibility which I want to illustrate in this blog: manipulating the AST structure. This means that we do not necessarily touch the Command Text section or create Groovy variables but make our changes directly in AST. Example of such changes could be:

  • create  predefined mapping expression for technical fields
  • add some tables in the FROM clause (i.e. adding a join with the table containing the surrogate keys)

Follow the link below to see how you can create a new component-style IKM on which the AST used to generate the code is modified:

Altering AST in component-style IKM

Read 2146 times Last modified on Saturday, 16 March 2019 10:22

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.