This application is related to U.S. patent application entitled “Classification And Sequencing Of Mixed Data Flows,” Ser. No. 11/372,540, filed on Mar. 10, 2006, which is incorporated by reference herein.
The present invention relates generally to data processing, and more particularly to generating code for an extract, transform, and load (ETL) data flow.
Data integration applications are commonly used to integrate data, e.g., due to mergers and acquisitions among businesses. Data integration can occur in other circumstances, such as when merging data from two different departments (or divisions) in a company, or integrating new data application software with a legacy application. Typical data integration applications are those types of applications in which data from multiple sources on varied data systems and repositories needs to be processed, combined, or otherwise transformed into data that is then loaded into multiple targets, again residing on different data systems and repositories. For example, in some cases, legacy data in text files or spreadsheets is best processed by a specialized extract, transform, and load (ETL) engine. Legacy data is any file, database, or software asset (such as a web service or business application) that has been previously deployed. Two kinds of ETL engines include a relational database engine (e.g., an Oracle or Microsoft Server engine) that can execute structured query language (SQL) statements, and proprietary engine (e.g., from Ascential) that can execute propriety language statements.
In an ETL environment in which a database server acts as an ETL engine, data integration typically begins with a user describing a data flow of an ETL process using a UI (user interface) tool. A data flow represents a logical transformation and flow of data. A code generation system generates code from the data flow, which generated code is then sent to the database server for execution. There are generally two basic requirements involved in code translation and generation—1) generation of correct code that reflects the semantics of an operator graph corresponding to the data flow, and 2) generation of optimized code that has the best performance (e.g., in terms of time and space efficiency) for the underlying ETL engine. Conventional SQL code generation systems, however, typically rely on the underlying ETL engine (or database server) to perform optimization and, therefore, such conventional code generation systems typically only directly translate an operator graph into SQL code. The quality of SQL code generated through such a direct translation approach can vary greatly and, therefore, users are required to be experts in order to verify and take advantage of the generated code. Further, while conventional ETL engines can be optimized for ETL processing, conventional ETL engines can typically only handle single-statement code, and fall short on generating an optimized plan for a much larger amount of multiple-statement code that is typically generated by a code generation system.
In general, in one aspect, this specification describes a computer-implemented method for generating code for an extract, transform, and load (ETL) data flow in an ETL system. The method includes receiving an ETL data flow representing a logical transformation and flow of data, placing a staging table at a pre-determined location in the ETL data flow to reduce a total number of staging tables required by the transformation, and generating code for the transformation based on the ETL data flow including the staging table placed at the pre-determined location.
Implementations can include one or more of the following features. Placing a staging table at a pre-determined location in the in the ETL data flow can include placing staging tables in the ETL data flow at one or more of the following locations: a user-specified location, an output of a data flow operator that requires two or more outputs, a data flow location that crosses databases, a location that serves as a connection of a row-based/set-based subflow, or a location corresponding to a persistent point for the ETL data flow that is used for error recovery purposes. The staging table placed in the ETL data flow can be initially assigned as a declared global temporary table. Generating code for the transformation can further include removing the staging table from the ETL data flow responsive to the staging table no longer being used in a subsequent transformation within the ETL data flow. Generating code for the transformation can further include building an index on a column of a staging table that appears in a JOIN condition following the staging table. Placing a staging table at a pre-determined location in the ETL data flow can include partitioning the staging table.
Implementations can further include one or more of the following features. The method can further include reducing a size of the ETL data flow using a data dependency graph. Generating code for the transformation can further include generating the code for the transformation using the reduced ETL data flow. Reducing a size of the ETL data flow can include removing a column from the ETL data flow that satisfies predetermined criteria. The predetermined criteria can include removing a column from the ETL data flow that does not have a path leading to a column in a data flow relevant column set, in which the data flow relevant column set includes columns in a target table of the ETL data flow and columns referred in a predicate of an operator in the ETL data flow. Removing a column from the ETL data flow can include determining whether to remove a column only from a source table or a staging table in the ETL data flow. Generating code for the transformation can include generating structured query language (SQL) code for the transformation.
In general, in another aspect, a computer program product, tangibly stored on a computer-readable medium is provided. The computer program product comprises instructions for causing a programmable processor to receive an ETL data flow representing a logical transformation and flow of data, place a staging table at a pre-determined location in the ETL data flow to reduce a total number of staging tables required by the transformation, and generate code for the transformation based on the ETL data flow including the staging table placed at the pre-determined location.
In general, in another aspect, this specification describes an extract, transform, and load (ETL) system including a code generation system to receive an ETL data flow representing a logical transformation and flow of data, a first engine (associated with the code generation system) to place a staging table at a pre-determined location in the ETL data flow to reduce a total number of staging tables required by the transformation, and a second engine (associated with the code generation system) to generate code for the transformation based on the ETL data flow including the staging table placed at the pre-determined location.
Implementations can provide one or more of the following advantages. Techniques for increasing the performance of data integration are provided below. In one aspect, a data processing system is provided that eliminates unnecessary columns within data to reduce the volume of data to be transformed. In another aspect, the data processing system reduces the number of staging tables required during a data transformation by requiring placement of staging tables at only pre-determined locations in an ETL data flow.
The details of one or more implementations are set forth in the accompanying drawings and the description below. Other features and advantages will be apparent from the description and drawings.
Like reference symbols in the various drawings indicate like elements.
The present invention relates generally to data processing, and more particularly to generating code for an extract, transform, and load (ETL) data flow. The following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements. The present invention is not intended to be limited to the implementations shown but is to be accorded the widest scope consistent with the principles and features described herein.
Running on the programmed computer 204 is an integrated development environment 208. The integrated development environment 208 is a software component that assists users (e.g., computer programmers) in developing, creating, editing, and managing code for target platforms. In one implementation, the integrated development environment 208 includes code generation system 210. In operation, a data flow 212 (e.g., an ETL data flow) is received by the code generation system 210, and the data flow is converted by the code generation system into an extended query graph model (EQGM graph) 214. The EQGM graph 214 is an internal data model used by the code generation system 210 for analysis and optimization as discussed below. After analysis, the EQGM 214 is converted into an extended plan graph 216. The extended plan graph 216 represents the code generated by the code generation system 210 and is sent to a runtime engine (e.g., an ETL engine) for execution.
The code generation system 210 includes (in one implementation) a data flow reduction engine 218 and a staging table engine 220 for optimizing code generated by the code generation system 208 (e.g., the extended plan graph 216). In one implementation, the data flow reduction engine 218 reduces the size of a data flow—e.g., data flow 212—by eliminating unnecessary columns within the data flow, as described in greater detail below. The elimination of unnecessary columns reduces the volume of data to be transformed. In one implementation, the staging table engine 208 reduces the number of staging tables required during a data transformation by requiring placement of staging tables at only pre-determined locations in a data flow as described in greater detail below.
In addition, in one implementation, the staging table engine 208 further assigns each internal staging table as type (DB2) declared global temporary table (DGTT) in order to attain the benefits of global declared temporary tables. Such benefits can include, for example, performance in terms of not having lock, log, etc., overhead as would an ordinary persistent table. In one implementation, when a declared temporary table is created, the data processing system 200 does not insert an entry into the system catalog tables; therefore, an associated server does not suffer from catalog contention issues. In comparison to regular tables, the data processing system 200 does not lock declared temporary tables or their rows, and, if a user specifies the NOT LOGGED parameter when upon creation of a declared temporary table, the data processing system 200 does not log declared temporary tables or their contents. Accordingly, declared temporary tables can be used instead of regular tables for those an application that creates tables to process large amounts of data and drops those tables once the application has finished manipulating that data.
Furthermore, applications that are written for concurrent users can take advantage of declared temporary tables. Unlike regular tables, declared temporary tables are not subject to name collision. For each instance of the application, the data processing system 200 can create a declared temporary table with an identical name. For example, to write an application for concurrent users that uses regular tables to process large amounts of temporary data, a user must typically ensure that each instance of the application uses a unique name for the regular table that holds the temporary data. Typically, a user would create another table that tracks the names of the tables that are in use at any given time. With declared temporary tables, a user can simply specify one declared temporary table name for temporary data. The data processing system 200 guarantees that each instance of the application uses a unique table.
Reducing Size of Data Flow
Once a data flow is received, a determination of the data flow relevant column set in the data flow is determined (e.g., by the data flow reduction engine 218) (step 304). In one implementation, the data flow relevant column set is a minimal set of columns that includes columns in a target table, and columns having values that determine a result of a transformation. By definition, such a set includes columns in the target table of a transformation, and columns referred to in predicates of an operator. Referring again to the example of
A data dependency graph from columns in the data flow is determined (e.g., by the data flow reduction engine 218) (step 306). A data dependency graph is a graph that describes the dependency of column data in a data flow. In one implementation, the nodes of the graph are the columns in the data flow, and the edges of the graph are defined as follows—if a column A is calculated/populated from a column B (i.e., the value of A depends (directly or indirectly) on the value of B), then there is an edge from node B to node A. In one implementation, a data dependency graph is determined for only columns associated with a source table or columns associated with a staging table. A source table is table from which column data is read. Referring to
Columns from the data flow that do not have a path leading to a column in the data flow relevant set as specified by the data dependency graph are eliminated (e.g., by the data flow reduction engine 218) (step 308). As shown in the data dependency graph 500, the columns {A.COL1, A.COL.2, B.COL2, A.COL3} each have a path that leads to a column in the data flow relevant set—e.g., a predicate or column in a target table. However, the column {A.COL4} does not have a path that leads to a column in the data flow relevant set and, therefore, the column {A.COL4} can be eliminated from the data flow as being an unnecessary column. Applying the method 300 to all the source columns in the data flow represented by the EQGM graph 400 reveals that columns {A.COL4, B.COL3, B.COL4, E.COL3} do not have a path that leads to a column in the data flow relevant set and are unnecessary for the transformation represented by the EQGM graph 400.
Optimal Placement of Staging Tables
In an ideal data transformation, data should flow freely and be stored in a staging table only when absolutely necessary. Generally, storing data in a staging table stalls a data pipeline and slows down the performance of a transformation. Therefore, in an optimal data flow, the number of staging tables (and the expense of staging) should be kept minimal. Accordingly, in one implementation, to keep the number of staging tables required in a transformation minimal, the staging table engine 220 (
Declared Global Temporary Tables
Further to achieve better performance, in one implementation, the staging table engine 220 implements DB2 declared global temporary tables (DGTTs) whenever possible. A created temporary table exists only as long as the process that uses the temporary table. Accordingly, because DB2 DGTTs cannot live through different processes (or sessions), in some situations the staging table engine 220 implements persistent tables instead of a DGTT.
Garbage Collection of Unused Staging Tables
In one implementation, if a temporary table is no longer used in a subsequent transformation, then the temporary table is dropped (or removed) (e.g., by the staging table engine 220) to save space. With respect to a data flow transformation graph, a table is live on an edge if there is a direct path from that edge to a use of that table that does not go through any definition of that table. A table is live-in on a transform node if that table is live in any of the in-edges of that transform node, and a table is live-out of a transform node if that table is live on any of the out-edges of that transform node. Any table that does not live-out of a transform node is dropped right after that transform node. The live-in and live-out for a transform node is calculated (in one implementation) as follows:
livein[n]=use[n]Y(liveout[n]−def[n]) (eq. 1)
liveout[n]=Ylivein[s],sεsuccessor[n] (eq. 2)
where def[n] is the data object (or table) defined in the node n, use[n] is the data object used in the node n.
In a data flow that has only one dimension, equations 1 and 2 above can be simplified as follows.
For all nodes except the last one,
livein[n]=use[n]Y(liveout[n]−def[n]) (eq. 3)
liveout[n]=Ylivein[n+1] (eq. 4)
And for the last node,
livein[n]=use[n] (eq. 5)
liveout[n]=φ (eq. 6)
Thus, referring to the to the example graph 800 shown in
In one implementation, the staging table engine 220 (
One or more of method steps described above can be performed by one or more programmable processors executing a computer program to perform functions by operating on input data and generating output. Generally, the invention can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment containing both hardware and software elements. In one implementation, the invention is implemented in software, which includes but is not limited to firmware, resident software, microcode, etc.
Furthermore, the invention can take the form of a computer program product accessible from a computer-usable or computer-readable medium providing program code for use by or in connection with a computer or any instruction execution system. For the purposes of this description, a computer-usable or computer readable medium can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
The medium can be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system (or apparatus or device) or a propagation medium. Examples of a computer-readable medium include a semiconductor or solid state memory, magnetic tape, a removable computer diskette, a random access memory (RAM), a read-only memory (ROM), a rigid magnetic disk and an optical disk. Current examples of optical disks include compact disk-read only memory (CD-ROM), compact disk-read/write (CD-R/W) and DVD.
Memory elements 904A-B can include local memory employed during actual execution of the program code, bulk storage, and cache memories that provide temporary storage of at least some program code in order to reduce the number of times the code must be retrieved from bulk storage during execution. As shown, input/output or I/O devices 908A-B (including, but not limited to, keyboards, displays, pointing devices, etc.) are coupled to data processing system 900. I/O devices 908A-B may be coupled to data processing system 900 directly or indirectly through intervening I/O controllers (not shown).
In one implementation, a network adapter 910 is coupled to data processing system 900 to enable data processing system 900 to become coupled to other data processing systems or remote printers or storage devices through communication link 912. Communication link 912 can be a private or public network. Modems, cable modems, and Ethernet cards are just a few of the currently available types of network adapters.
Various implementations for generating code based on an ETL data flow have been described. Nevertheless, various modifications may be made to the implementations described above, and those modifications would be within the scope of the present invention. For example, although the above techniques are described in the context of data processing applications (e.g., data warehousing applications), the techniques can be applied generally to a variety of other applications. Also, the general idea of reducing unnecessary data is applicable to most data processing systems, however, other techniques can be used to specifically identify the unnecessary data may be used other than those techniques discussed above. Accordingly, many modifications may be made without departing from the scope of the present invention.
| Number | Name | Date | Kind |
|---|---|---|---|
| 4901221 | Kodosky et al. | Feb 1990 | A |
| 5497500 | Rogers et al. | Mar 1996 | A |
| 5577253 | Blickstein | Nov 1996 | A |
| 5850548 | Williams | Dec 1998 | A |
| 5920721 | Hunter et al. | Jul 1999 | A |
| 5966532 | McDonald et al. | Oct 1999 | A |
| 6014670 | Zamanian et al. | Jan 2000 | A |
| 6044217 | Brealey et al. | Mar 2000 | A |
| 6098153 | Fuld et al. | Aug 2000 | A |
| 6208990 | Suresh et al. | Mar 2001 | B1 |
| 6282699 | Zhang et al. | Aug 2001 | B1 |
| 6434739 | Branson et al. | Aug 2002 | B1 |
| 6449619 | Colliat et al. | Sep 2002 | B1 |
| 6480842 | Agassi et al. | Nov 2002 | B1 |
| 6604110 | Savage et al. | Aug 2003 | B1 |
| 6772409 | Chawla et al. | Aug 2004 | B1 |
| 6795790 | Lang et al. | Sep 2004 | B1 |
| 6839724 | Manchanda et al. | Jan 2005 | B2 |
| 6850925 | Chaudhuri et al. | Feb 2005 | B2 |
| 6968326 | Johnson et al. | Nov 2005 | B2 |
| 6968335 | Bayliss et al. | Nov 2005 | B2 |
| 6978270 | Carty et al. | Dec 2005 | B1 |
| 7003560 | Mullen et al. | Feb 2006 | B1 |
| 7031987 | Mukkamalla et al. | Apr 2006 | B2 |
| 7035786 | Abu El Ata et al. | Apr 2006 | B1 |
| 7076765 | Omori | Jul 2006 | B1 |
| 7103590 | Murthy et al. | Sep 2006 | B1 |
| 7209925 | Srinivasan et al. | Apr 2007 | B2 |
| 7499917 | Purcell et al. | Mar 2009 | B2 |
| 20020046301 | Shannon et al. | Apr 2002 | A1 |
| 20020116376 | Iwata et al. | Aug 2002 | A1 |
| 20020170035 | Casati et al. | Nov 2002 | A1 |
| 20030033437 | Fischer et al. | Feb 2003 | A1 |
| 20030037322 | Kodesky et al. | Feb 2003 | A1 |
| 20030051226 | Zimmer et al. | Mar 2003 | A1 |
| 20030101098 | Schaarschmidt | May 2003 | A1 |
| 20030110470 | Hanson et al. | Jun 2003 | A1 |
| 20030149556 | Riess | Aug 2003 | A1 |
| 20030154274 | Nakamura | Aug 2003 | A1 |
| 20030172059 | Andrei | Sep 2003 | A1 |
| 20030182651 | Secrist et al. | Sep 2003 | A1 |
| 20030233374 | Spinola et al. | Dec 2003 | A1 |
| 20040054684 | Geels | Mar 2004 | A1 |
| 20040068479 | Wolfson et al. | Apr 2004 | A1 |
| 20040254948 | Yao | Dec 2004 | A1 |
| 20050044527 | Recinto | Feb 2005 | A1 |
| 20050055257 | Senturk et al. | Mar 2005 | A1 |
| 20050091664 | Cook et al. | Apr 2005 | A1 |
| 20050097103 | Zane et al. | May 2005 | A1 |
| 20050137852 | Chari et al. | Jun 2005 | A1 |
| 20050174988 | Bieber et al. | Aug 2005 | A1 |
| 20050188353 | Hasson et al. | Aug 2005 | A1 |
| 20050216497 | Kruse et al. | Sep 2005 | A1 |
| 20050227216 | Gupta | Oct 2005 | A1 |
| 20050240354 | Mamou et al. | Oct 2005 | A1 |
| 20050240652 | Crick | Oct 2005 | A1 |
| 20050243604 | Harken et al. | Nov 2005 | A1 |
| 20050256892 | Harken | Nov 2005 | A1 |
| 20060036522 | Perham | Feb 2006 | A1 |
| 20060047709 | Belin et al. | Mar 2006 | A1 |
| 20060074621 | Rachman | Apr 2006 | A1 |
| 20060074730 | Shukla et al. | Apr 2006 | A1 |
| 20060112109 | Chowdhary et al. | May 2006 | A1 |
| 20060167865 | Andrei | Jul 2006 | A1 |
| 20060206869 | Lewis et al. | Sep 2006 | A1 |
| 20060212475 | Cheng | Sep 2006 | A1 |
| 20060218123 | Chowdhuri et al. | Sep 2006 | A1 |
| 20070061305 | Azizi | Mar 2007 | A1 |
| 20070157191 | Seeger et al. | Jul 2007 | A1 |
| 20070169040 | Chen | Jul 2007 | A1 |
| 20070203893 | Krinsky et al. | Aug 2007 | A1 |
| 20070214111 | Jin et al. | Sep 2007 | A1 |
| 20070214171 | Behnen et al. | Sep 2007 | A1 |
| 20070214176 | Rao et al. | Sep 2007 | A1 |
| 20070244876 | Jin et al. | Oct 2007 | A1 |
| Number | Date | Country | |
|---|---|---|---|
| 20080092112 A1 | Apr 2008 | US |