Professional Documents
Culture Documents
com +917411642061
Lab 6
Flat File Wizard and Filter Transformation
Lab at a Glance................................................................2 Objectives..............................................................2 Summary................................................................2 Duration.................................................................3 Exercises.........................................................................4 Exercise 1: Import Source and Target....................4 Exercise 2: Create the Mapping.............................6 Exercise 3: Create and Run the Workflow............11
6-1
Lab at a Glance
The exercises in this lab are designed to walk the student through the process of importing and analyzing a flat file source using the Flat File Wizard. The student will also learn how to use the Filter transformation.
Objectives
After completing the lab, the student will be able to: Use the Flat File wizard. Create a Filter transformation.
Summary
In this lab, the student will create a mapping (and associated workflow) to extract data from a flat file that contains date records. An example of data from the flat file follows:
The mapping must transform the data and load it into a target table as follows:
In addition, the mapping must filter the data for only those dates after 12/04/1999.
6-2
Duration
This lab should take approximately 40 minutes.
6-3
Exercises
Exercise 1: Import Source and Target
Step 1. Import the file.
6-4
In the Designer, open the Source Analyzer by clicking the Source Analyzer
Analyzer.
Select Sources | Import From File. The Open Flat File dialog box appears.
Change the Files of type: to All Files(*.*). Locate the directory where the flat file resides typically C:\pmfiles\SrcFiles, although your instructor can confirm. Select the flat tile TIME.txt. Click OK. The Flat File Import Wizard appears. Ensure the Delimited radio button is selected (default). Select the Import field names from first line checkbox.
The first row in the TIME.txt file contains the column names. When this option is checked, the import automatically starts at row 2 and assumes that future extracts will start at row 2.
6-5
Step 2. Import the target table. Open the Warehouse Designer by clicking the Warehouse
Designer
Select Targets | Import From Database. Connect to the target ODBC connection (tdbuxx - where xx is the assigned student number). Expand the TDBUxx schema and TABLES node. Select ODS_TIME. Click OK. The ODS_TIME target table should look as follows:
6-6
Double-click on the header of the Expression transformation. The Edit Transformations dialog appears. Click the Rename button. Enter exp_ODS_TIME in the Transformation Name field and click the OK button. Click on the Ports tab. Highlight the third port, QUARTER, then add the following ports by clicking the Add Port
button:
DATE_ID, Datatype=date/time, Prec=19(default), Port Type=Output Only MONTH_out, Datatype=string, Prec=3, Port Type=Output Only QUARTER_out, Datatype=string, Prec=2, Port Type=Output Only YEAR_out, Datatype=string, Prec=4, Port Type=Output Only
Since the last 2 new ports listed are close in datatype, port-type and formula to MONTH_out, you may optionally copy the MONTH_out port and paste-in 2 copies. Use the copy and paste icons to the right of the 'Add a new column' button. Be sure to alter the newly copied ports for port name, precision and formula, to be accurate for QUARTER_out and YEAR_out.
An expression will be needed for each of the above ports to derive the values. Open the Expression Editor and add expressions for each port as follows:
DATE_ID TO_DATE(DATE,DD-MON-YYYY) MONTH_out SUBSTR(DATE,4,3) QUARTER_out SUBSTR(QUARTER,6,1) YEAR_out SUBSTR(QUARTER,1,4)
Change the ports, DATE and QUARTER, to input only ports. The Ports tab of the exp_ODS_TIME expression should look as follows:
6-7
Step 4. Create a Filter transformation. Click on the Filter Transformation Transformation toolbar. button on the
Click and drag the pointer (which appears as crosshairs in the workspace) to the right of the exp_ODS_TIME expression. Drag and drop the following ports in the order specified from exp_ODS_TIME to the FILTRANS window:
DATE_ID DAY_OF_WEEK MONTH_out QUARTER_out YEAR_out
Double-click on the Filter transformation. The Edit Transformations dialog box appears. Click the Rename button and enter fil_ODS_TIME. Click on the Ports tab and rename the following ports:
MONTH_out = MONTH = QUARTER = YEAR
QUARTER_out YEAR_out
6-8
To define a new filter condition, remove the default text, TRUE. Open the Expression Editor and click on the Ports tab to the right of the Functions tab.
Double-click on DATE_ID. Click the greater than or equals operator keypad. button on the
Click the Functions tab, expand the Conversion folder and double-click on To_Date. To complete the expression, type '12/04/1999', 'MM/DD/YYYY' between the parentheses. The final expression should look as follows:
DATE_ID >=TO_DATE('12/04/1999', 'MM/DD/YYYY')
Click on the Validate button to validate the filter condition. Click OK twice to save changes. The Filter transformation should look as follows:
6-9
Step 5. Link the Target transformation. Right-click in the workspace and select Autolink Select fil_ODS_TIME in the From Transformation field and ODS_TIME in the To Transformations field. Make sure that the Name radio button is selected in the By field:
Click OK. All ports should be linked between these two transformations:
Validate the mapping by selecting Mapping |Validate. Remember to check the Validate tab in the Output window for the results. Save the repository. The completed mapping should look as follows:
6 - 10
Select the Mapping tab. In the Navigator window, select the source SQ_TIME. Under Properties, TIME File Reader, Source filename, enter TIME.txt.
In the Navigator window, select the target ODS_TIME. Under Connections, click on the down arrow select native_target_xx and click OK. ,
defaulted to Normal. Scroll down to select the Truncate target table option.
Save, validate and start the workflow. Monitor and review the results for s_m_ODS_TIME_xx in the Workflow Monitor. Step 3. Verify results - session properties. By using the date 12/04/1999 as a filter, the ODS_TIME_xx table should contain 1489 rows:
Step 5. Verify results preview data. Return to the Designer and go to the Warehouse
6 - 12
Designer. Right-click the ODS_TIME target definition header and select Preview Data The Preview Data dialog box appears.
Select the odbc_target ODBC data source connection from the pull-down list. Enter the username and password assigned by the instructor should be tdbuxx/tdbuxx (where xx is the assigned student number). Click on Connect. The results appear in the bottom half of the dialog box. The default number of returned rows is 100. By default, 100 rows are returned. In this Lab Guide, only some rows are shown. Here is an excerpt from the middle of the results.
6 - 13
6 - 14