Table of Contents

Search

  1. Preface
  2. Transformations
  3. Source transformation
  4. Target transformation
  5. Access Policy transformation
  6. Aggregator transformation
  7. B2B transformation
  8. Chunking transformation
  9. Cleanse transformation
  10. Data Masking transformation
  11. Data Services transformation
  12. Deduplicate transformation
  13. Expression transformation
  14. Filter transformation
  15. Hierarchy Builder transformation
  16. Hierarchy Parser transformation
  17. Hierarchy Processor transformation
  18. Input transformation
  19. Java transformation
  20. Java transformation API reference
  21. Joiner transformation
  22. Labeler transformation
  23. Lookup transformation
  24. Machine Learning transformation
  25. Mapplet transformation
  26. Normalizer transformation
  27. Output transformation
  28. Parse transformation
  29. Python transformation
  30. Rank transformation
  31. Router transformation
  32. Rule Specification transformation
  33. Sequence transformation
  34. Sorter transformation
  35. SQL transformation
  36. Structure Parser transformation
  37. Transaction Control transformation
  38. Union transformation
  39. Vector Embedding transformation
  40. Velocity transformation
  41. Verifier transformation
  42. Web Services transformation

Transformations

Transformations

Lookup SQL overrides for cached lookups

Lookup SQL overrides for cached lookups

In a cached lookup, you can override the default SQL query to change the ORDER BY clause, add a WHERE clause, or transform the data. The
mapping
task uses the override statement to build the lookup cache.
The default query contains a SELECT statement that includes all lookup fields in the mapping. The SELECT statement also contains an ORDER BY clause that orders all columns in the same order in which they appear in the Lookup transformation.
If you want to change the ORDER BY clause, add a WHERE clause, or transform the lookup data before it is cached, override the default query. For example, you might use database functions to adjust the data types or formats in the lookup table to match the data types and formats of fields that are used in the mapping. Or, you might override the default query to query multiple tables.
Override the default query on the
Advanced
tab of the Lookup transformation. Enter the entire SELECT statement in the
Lookup SQL Override
field. Use an alias for each column in the query. If you want to change the ORDER BY clause, append "
--
" to the end of the query to suppress the ORDER BY clause that the
mapping
task generates.

Example

A Lookup transformation returns the following fields from Microsoft SQL Server table ALC_ORDER_DETAILS:
The Return Fields tab of the Lookup transformation lists the following return fields from table ALC_ORDER_DETAILS: ORDERID, PRODUCTID, UNITPRICE, QUANTITY, and DISCOUNT.
The transformation uses the following lookup condition:
ORDERID=in_ORDERID
When you run the mapping task, the following query appears in the log file:
LKPDP_1> DBG_21097 [2018-11-07 14:11:33.509] Lookup Transformation [lkp_ALC_ORDER_DETAILS]: Default sql to create lookup cache: SELECT PRODUCTID,UNITPRICE,QUANTITY,DISCOUNT,ORDERID FROM "icsauto"."ALC_ORDER_DETAILS" ORDER BY ORDERID,PRODUCTID,UNITPRICE,QUANTITY,DISCOUNT
To override the ORDER BY clause and sort by PRODUCTID, enter the following query in the
Lookup SQL Override
field on the
Advanced
tab:
SELECT PRODUCTID AS PRODUCTID, UNITPRICE AS UNITPRICE, QUANTITY AS QUANTITY, DISCOUNT AS DISCOUNT, ORDERID AS ORDERID FROM "icsauto"."ALC_ORDER_DETAILS" ORDER BY PRODUCTID --
When you run the mapping task again, the following query appears in the log file:
LKPDP_1> DBG_21312 [2018-11-07 14:14:36.734] Lookup Transformation [lkp_ALC_ORDER_DETAILS]: Lookup override sql to create cache: SELECT PRODUCTID AS PRODUCTID, UNITPRICE AS UNITPRICE, QUANTITY AS QUANTITY, DISCOUNT AS DISCOUNT, ORDERID AS ORDERID FROM "icsauto"."ALC_ORDER_DETAILS" ORDER BY PRODUCTID -- ORDER BY ORDERID,PRODUCTID,UNITPRICE,QUANTITY,DISCOUNT

0 COMMENTS

We’d like to hear from you!