Data Ingestion Framework for Hadoop
This version of the Data Ingestion Framework is a Script Engine you can use to ingest data from any database, data files (both fixed width and delimited) into Hadoop environment. This lets you get started, ingest the data in a matter of days. If you are looking for a solution beyond Data Ingestion, please take a look at accel-DS for Data Integration. This solution let you ingest, clean and Transform data from a variety of data sources into Hadoop and vice versa.
Objective
To provide a simple, easy to use the framework to ingest data into Hadoop from a variety of data sources.
Framework
This is a set of shell script to which you can pass various parameters, such as source database or files details, target (Hadoop) details, target table name etc., This framework has a very small footprint and you can start ingesting data from day one.
Benefits
- Ingest from a variety of data sources - database, data files (both fixed width and delimited)
- Target Tables, Data Types are created by the Framework
- Load multiple data files with a single call to the engine.
How to Ingest Data
- Download the Data Ingestion Framework.
- Follow the instructions to copy it to your Hadoop environment.
- Change Directory to the location where you have copied the scripts
- Use any of the Data Ingestion commands listed under Sample Scripts section, to ingest data into Hadoop.
Note
Sample Scripts
In this article, sample scripts are provided for the following scenarios:
- Create and Insert - Delimited File.
- Create and Insert - Fixed width File.
- Create and Insert - Table.
- Create and Insert - SQL.
- Create and Insert - XML File.
- Insert only - Delimited File.
- Insert only - Fixed Width File.
- Insert only - Table.
- Insert only - Query.
- Insert only - XML File.
1. Create and Insert - Delimited File
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create".Create & Insert option will create table and load data into the created table. #Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Type_Of_Create | Options "External, Managed". If External is chosen, then the table created will be EXTERNAL HIVE table. #If Managed is chosen, then the table created will be HIVE MANAGED table. |
3 | Data_Base_Name | Enter the Database name in which the table needs to be created. |
4 | Target_Table | Enter the table name to create and load. |
5 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File and Table. Choose Delimited, if the Source File is a delimited file. Choose Fixed width, #if the Source File is fixed width data file. Choose Table, if data needs to be imported from another database to hive. |
6 | Table_Layout_Path | Enter Table layout file path and name. #If the #Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited. If the #Type_Of_Table is the Fixed width, then the Table Layout file should have column names, their data types, column start position and column end position, it must be tab delimited. |
7 | Table_Delimiter | Enter the Table delimiter. |
8 | File_Delimiter | Enter the column delimiter used in Source File. |
9 | Load_Data_Path | Enter the Source File path with name. If you need to load multiple files, enter all the file names with path delimited by a comma. |
10 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. |
11 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. |
12 | Table_Delete_Flag | Enter 'Delete Target Table', if you need to delete the target table, in case it exists. |
13 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example
Example:( Transpose )
2. Create and Insert - Fixed width File.
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create".Create & Insert option will create table and load data into the created table. #Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Type_Of_Create | Options "External, Managed". If External is chosen, then the table created will be EXTERNAL HIVE table. #If Managed is chosen, then the table created will be HIVE MANAGED table. |
3 | Data_Base_Name | Enter the Database name in which the table needs to be created. |
4 | Target_Table | Enter the table name to create and load. |
5 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File and Table. Choose Delimited, if the Source File is a delimited file. Choose Fixed width, #if the Source File is fixed width data file. |
6 | Convert_Fixed_delimited_Flag | Options are Y or N. Enter Y, if you want to convert the fixed width data file to delimited data file. Enter N, #if you want to load data in fixed width format. |
7 | Fixed_Delimiter | Enter the delimiter, if you choose 'Y' for #Convert_Fixed_delimited_Flag. #This delimiter will be used to create the delimited data file. |
8 | Load_Data_Path | Enter Table layout file path and name. #If the #Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited.If the #Type_Of_Table is the Fixed width, then the Table Layout file should have column names, their data types, column start position and column end position, it must be tab delimited. |
9 | Load_Data_Path | Enter the Source File path with name. If you need to load multiple files, enter all the file names with path delimited by a comma. |
10 | Table_Delete_Flag | =Enter 'Delete Target Table', if you need to delete the target table, in case it exists. |
11 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example :(If Arg Convert_Fixed_delimited_Flag = "Y")
Example :(If Arg Convert_Fixed_delimited_Flag = "N")
3. Create and Insert - Table.
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create".Create & Insert option will create table and load data into the created table. #Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Type_Of_Create | Options "External, Managed". If External is chosen, then the table created will be EXTERNAL HIVE table. #If Managed is chosen, then the table created will be HIVE MANAGED table. |
3 | Data_Base_Name | Enter the Database name in which the table needs to be created. |
4 | Target_Table | Enter the table name to create and load. |
5 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File and Table. Choose Delimited, if the Source File is a delimited file. Choose Fixed width, #if the Source File is fixed width data file. |
6 | Create_Layout_Flag | Options are Y or N. Enter Y, if you want to create layout file automatically. Enter N, if you give layout file. |
7 | Table_Layout_Path | Enter layout file path and name, if you chose 'N' for #Create_Layout_Flag otherwise enter 'NA'. |
8 | Column_Name_Query | If you chose 'Y' for #Create_Layout_Flag, provide a Metadata SQL that can return the Source Table's, #column names, data type, precision, and scale. This will be used to build a comparable table in Hive. |
9 | Mapping_Data_Path | Enter the Source to Hive Data Type mapping file path and name. #This file will be used to convert Source Column Data Types to appropriate Hive Columns. Refer to supplied Oracle2HiveDataTypeMapping.txt. |
10 | Load_Data_Path | Enter source table connection string, username, password file path, source tablename and hdfs file path where the data from The #source table will be stored. This information should be entered and delimited by ','(comma) in the same order. |
11 | Table_Delimiter | Enter the table delimiter. |
12 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. #This option is not applicable if (Arg) Create_Layout_Flag is 'Y' |
13 | Audit_Columns | Enter the Audit Column details. It should contain audit column name, audit column datatype and function name,. #all details should be '~' delimited. Each audit column details should be delimited by ','. |
14 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. This option is not applicable if (Arg) Create_Layout_Flag is 'Y'. |
15 | Table_Delete_Flag | Enter 'Delete Target Table', if you need to delete the target table, in case it exists. |
16 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example :(Auto creates the Table layout)
Example :(User provided Table layout)
4. Create and Insert - SQL
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create". Create & Insert option will create table and load data into the created table. #Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Type_Of_Create | Options "External, Managed". If External is chosen, then the table created will be EXTERNAL HIVE table. #If Managed is chosen, then the table created will be HIVE MANAGED table. |
3 | Data_Base_Name | Enter the Database name in which the table needs to be created. |
4 | Target_Table | Enter the table name to create and load. |
5 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File and Table. Choose Delimited, if the Source File is a delimited file. #Choose Fixed width of the Source File is fixed width data file. Choose Table, if data needs to be imported from another database to hive. |
6 | Table_Layout_Path | Enter Table layout file path and name. #If the #Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited. |
7 | Source_SQL_Query | Enter the Source SQL query in which data will be exported to target table. |
8 | Load_Data_Path | Enter source table connection string, username, password file path and hdfs file path where the data from source table will be stored. #this information should be entered and delimited by ','(comma) in the same order. |
9 | Table_Delimiter | Enter the table delimiter. |
10 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. |
11 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. |
12 | Table_Delete_Flag | Enter 'Delete Target Table', if you need to delete the target table, in case it exists. |
13 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example
5. Create and Insert - XML File.
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create". Create & Insert option will create table and load data into the created table. #Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Type_Of_Create | Options "External, Managed". If External is chosen, then the table created will be EXTERNAL HIVE table. #If Managed is chosen, then the table created will be HIVE MANAGED table. |
3 | Data_Base_Name | Enter the Database name in which the table needs to be created. |
4 | Target_Table | Enter the table name to create and load. |
5 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File and Table. Choose Delimited, if the Source File is a delimited file. #Choose Fixed width of the Source File is fixed width data file. Choose Table, if data needs to be imported from another database to hive. |
6 | Table_Layout_Path | Enter Table layout file path and name. #If the #Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited. If the #Type_Of_Table is the Fixed width, then the Table Layout file should have column names, their data types, column start position and column end position, it must be tab delimited. |
7 | Table_Delimiter | Enter the Table delimiter. |
8 | Load_Data_Path | Enter the Source File path with name. If you need to load multiple files, enter all the file names with path delimited by a comma. |
9 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. |
10 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. |
11 | Table_Delete_Flag | Enter 'Delete Target Table', if you need to delete the target table, in case it exists. |
12 | Log_File | Log file path and name. Stores the logs generated by this tool. |
13 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example
6. Insert only - Delimited File
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create". Create & Insert option will create table and load data into the created table. #Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Data_Base_Name | Enter the Database name in which the table needs to be created. |
3 | Target_Table | Enter the table name to create and load.. |
4 | Type_Of_Table | Enter Table layout file path and name. #If the #Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited. |
5 | Table_Layout_Path | Enter Table layout file path and name. If the #Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited |
6 | Table_Delimiter | Enter the Table delimiter. |
7 | File_Delimiter | Enter the column delimiter used in Source File. |
8 | Load_Data_Path | Enter the Source File path with name. If you need to load multiple files, enter all the file names with path delimited by a comma. NOTE: The column delimiter in this Source file should match with the delimiter configured in the target table. |
9 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. |
10 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. |
11 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example
Example:(Transpose)
7. Insert only - Fixed Width File
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create". Create & Insert option will create table and load data into the created table. Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Data_Base_Name | Enter the Database name in which the table needs to be created. |
3 | Target_Table | Enter the table name to create and load.. |
4 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File and Table. Choose Delimited, if the Source File is a delimited file.Choose Fixed width, if the Source File is fixed width data file. Choose Table, if data needs to be imported from another database to hive. |
5 | Convert_Fixed_delimited_Flag | Options are Y or N. Enter Y, if you want to convert the fixed width data file to delimited data file. Enter N, if you want to load data in fixed width format. |
6 | Fixed_Delimiter | Enter the delimiter, if you chose 'Y' for # Arg Convert_Fixed_delimited_Flag. This delimiter will be used to create the delimited data file. |
7 | Table_Layout_Path | Enter Table layout file path and name. If the # Arg Convert_Fixed_delimited_Flag is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited. If the # Arg Convert_Fixed_delimited_Flag is the Fixed width, then the Table Layout file should have column names, their data types, column start position and column end position, it must be tab delimited. |
8 | Load_Data_Path | Enter the Source File path with name. If you need to load multiple files, enter all the file names with path delimited by a comma. NOTE: The Fixed width layout in this Source file should match with the Fixed width or delimiter configured in the target table. |
9 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example:(If Arg Convert_Fixed_delimited_Flag = "Y")
Example:(If Arg Convert_Fixed_delimited_Flag = "N")
8. Insert only - Table
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create". Create & Insert option will create table and load data into the created table. Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Data_Base_Name | Enter the Database name in which the source table is available. |
3 | Target_Table | Enter the table name to create and load.. |
4 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File and Table. Choose Delimited, if the Source File is a delimited file.Choose Fixed width, if the Source File is fixed width data file. Choose Table, if data needs to be imported from another database to hive. |
5 | Load_Data_Path | Enter source table connection string, username, password file path, source tablename and hdfs file path where the data from The source table will be stored. This information should be entered and delimited by ','(comma) in the same order. |
6 | Table_Delimiter | Enter the Column Delimiter to create the Target table. |
7 | Create_Layout_Flag | Options are Y or N. Enter Y if you want to create Table layout file automatically. Enter N, if you will provide the Table layout file. |
8 | Table_Layout_Path | Enter layout file path and name, if you chose 'N' for #Table_Layout_Path, otherwise enter 'NA'. |
9 | Column_Name_Query | If you chose 'Y' for #Create_Layout_Flag, provide a Metadata SQL that can return the Source Table's column names, datatype, precision and scale. This will be used to build a comparable table in Hive. |
10 | Mapping_Data_Path | Enter the Source to Hive Data Type mapping file path and name. This file will be used to convert Source Column Data Types to appropriate Hive Columns. NOTE : Refer to supplied Oracle2HiveDataTypeMapping.txt. |
11 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. This option is not applicable if #Create_Layout_Flag is 'Y'. |
12 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. |
13 | Audit_Columns | Enter the additional columns that you like to ingest. It should contain the column name, data type, and function name, Functions supported are UNIQUE_VALUE, DEFAULT- |
14 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example:(If Arg Convert_Fixed_delimited_Flag = "Y")
9. Insert only - Query.
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create". Create & Insert option will create table and load data into the created table. Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Data_Base_Name | Enter the Database name in which the source table is available. |
3 | Target_Table | Enter the target table name to load. |
4 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File, Table and SQL. Choose Delimited, if the Source File is a delimited file. Choose Fixed width of the Source File is fixed width data file.Choose Table, if whole table data needs to be imported from another database to hive. Choose SQL if you are passing SQL as a data source. In this case, you need to provide the Table Layout file as well. |
5 | Load_Data_Path | Enter source table connection string, username, password file path and hdfs file path where the data from The source table will be stored.This information should be entered and delimited by ','(comma) in the same order |
6 | Table_Delimiter | Enter the Column Delimiter to create the Target. |
7 | Table_Layout_Path | Enter Table layout file path and name. If the Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited. |
8 | Source_SQL_Query | Enter the Source SQL query in which data will be exported to target table. |
9 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. |
10 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. |
11 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Example
Example:(Transpose)
10. Insert only - XML File.
Command Template
# | Key Name | Description |
---|---|---|
1 | Type_Of_Ingestion | Options are "Create & Insert, Insert, Create". Create & Insert option will create table and load data into the created table. Insert option will load data into the specified table. Create option will only create the table without loading any data. |
2 | Data_Base_Name | Enter the Database name in which the source table is available. |
3 | Target_Table | Enter the target table name to load. |
4 | Type_Of_Table | Options are: Delimited, Fixed width, XML_File, Table and SQL. Choose Delimited, if the Source File is a delimited file. Choose Fixed width of the Source File is fixed width data file.Choose Table, if whole table data needs to be imported from another database to hive. Choose SQL if you are passing SQL as a data source. In this case, you need to provide the Table Layout file as well. |
5 | Table_Layout_Path | Enter Table layout file path and name. If the Type_Of_Table is Delimited or Table, then the Table Layout File should have column names and their data types, tab delimited. |
6 | Table_Delimiter | Enter the Column Delimiter to create the Target table. |
7 | Load_Data_Path | Enter the Source File path with name.If you need to load multiple files, enter all the file names with path delimited by a comma. NOTE: The column delimiter in this Source file should match with the delimiter configured in the target table. |
8 | Transpose_Flag | Flag for Transpose. Enter 'Y' if you want to load data using Transpose Ingest. |
9 | Null_Insert_Flag | Enter 'Y' if you don't want to insert null data into target table. |
10 | Log_File | Log file path and name. Stores the logs generated by this tool. |
Great article. My question is about the difference between data ingestion and the ETL process. How do you think both differ from each other and what is the right way?
ReplyDelete