Create a SQL View in a Transformation Flow on File

Create an SQL view transform to combine and transform data in a powerful SQL editor. You can choose between writing a standard SQL query using SELECT statements and operators such as JOIN and UNION. You can drag sources from the Repository, and easily view the columns defined for your output structure in the side panel.

Context

If you are not comfortable with SQL, you can still build a view transform by using the Graphical View Editor, which lets you compose SQL code using an intuitive graphical interface. For more information, see Create a Graphical View in a Transformation Flow.

You cannot save and deploy the view transform (the secondary editor) separately from the transformation flow (the primary editor). To exit the view transform editor, click the (Navigate Back) button in the editor toolbar.

Procedure

  1. On the New Transformation Flow screen, click the View Transform node.
  2. Create a new SQL View Transform for your transformation flow by clicking the SQL View Transform button. The system displays the SQL View Editor.
    The only language available is SQL (Apache Spark SQL). See SQL (Apache Spark SQL) Syntax Support in Transformation Flow Operators.
  3. Enter your code in the SQL View Editor. You can:
    • Access auto-complete suggestions for keywords and object names including source tables by typing.

    • Instruct AI to write SQL for you. See Generate SQL Code with AI in a File Space.

    • Drag source objects to the SQL View Editor.

    • Add comments to document your code:

      • Comment out a single line or the rest of a line with a double dash: -- Your comment here.

      • Comment out multiple lines or part of a line with: /* Your comment here */.

      This example contains various forms of comments:

      /*  
      									This is a multi-line comment to
      									introduce this view 
      									*/
      									
      									SELECT `ID`,
      									`Date`,
      									--	`Sales Person`, comment out a line
      									`City`, -- comment at end of line
      									`Net Sales`
      									FROM /* mid-line comment */ `Sales`
    • Format your SQL code by clicking Format.

    • Validate your code and update the display of your output structure in the side panel at any time by clicking (Validate).

      SQL errors and warnings are shown in the Errors pane at the bottom of the editor. Problems with the output structure are shown on the Validation Messages button in the side panel header.
  4. Review the list of columns (see Columns).
  5. Click the (Navigate Back) button to save your work and return to the Transformation Flow Editor. You can then add or create a target table for the transformation flow. For more information, see Create or Add a Target Table to a Transformation Flow.