Defining Expressions and Conditions

1. Understanding Expressions and Conditions

  • Expressions and conditions are used to map attributes between components.
  • Component types determine the default expressions and conditions converted into code for mapping.
  • Example: A target component has an expression for each attribute. Filter, join, or lookup components use code (like SQL) to create appropriate expressions.

2. Highlighting Function for Valid Cross References

  • When an expression is set on the target, any referenced source attributes are highlighted in magenta.
  • Example: If an expression emp.empno is on the target column tgt_empno, selecting tgt_empno highlights the empno attribute in the source.
  • This helps to quickly verify that each target attribute has valid cross-references to the source.

3. Common Issues with Cross-References

  • If there is an error in the expression, such as a misspelled source attribute, the cross-reference will be invalid.
  • In this case, no source attribute will be highlighted when clicking on the target attribute.

4. Modifying Expressions and Conditions

  • Expressions and conditions can be modified by editing the code in property fields.
  • Tip: It’s recommended to use the expression editor rather than manually editing expressions. The expression editor ensures valid cross-references by selecting the source attribute, minimizing errors.

5. Types of Expressions and Conditions

  • Expression Result Type: It can be VARCHAR, NUMERIC, etc.
  • Condition Result Type: It is always boolean (TRUE or FALSE).
  • Components for Conditions: Filter, join, and lookup components require conditions.
  • Components for Expressions: Datastore, aggregate, and distinct components use expressions for transformations or mappings.
  • Every projector component can have expressions on its attributes. Some components, like the Set component, may have multiple expressions on an attribute.
  • If an expression is modified, an "f" icon appears next to the attribute in the logical diagram.

6. Defining a Target Attribute Mapping

  • In the mapping editor, select the attribute to display its properties in the Property Inspector.
  • Modify the Expression or Condition field(s) in the Target or Condition tab, respectively.
  • Tip: You can drag and drop any component's attribute from the diagram into an expression field to add its fully-qualified name automatically.
  • Optionally, click the gear icon to open the advanced Expression Editor.

7. Scope of Attributes in Expression Editor

  • The attributes shown in the Expression Editor are only those in scope (i.e., those already connected in the diagram).
  • If there are no upstream or downstream connections to a component with attributes, no attributes will be listed.

8. Validation of Mapping

  • After modifying expressions or conditions, you can validate the mapping to check for errors.
  • Click the green check mark icon in the top of the logical diagram to perform validation.
  • Validation Checks:
    • Ensure input/output connectors are connected to other components.
    • Verify that the expression is not empty.
    • Check that filter conditions do not reference window or analytical functions (since window functions are not valid in filter conditions).

No comments:

Post a Comment