LOAD DATA

Function

This command is used to load user data of a particular type, so that CarbonData can provide good query performance.

Only the raw data on HDFS can be loaded.

Syntax

LOAD DATA INPATH 'folder_path' INTO TABLE [db_name.]table_name OPTIONS(property_name=property_value, ...);

Parameter Description

Table 1 LOAD DATA parameters

Parameter

Description

folder_path

Path of the file or folder used for storing the raw CSV data.

db_name

Database name. If this parameter is not specified, the current database is used.

table_name

Name of a table in a database.

Precautions

The following configuration items are involved during data loading:

Scenarios

To load a CSV file to a CarbonData table, run the following statement:

LOAD DATA INPATH 'folder path' INTO TABLE tablename OPTIONS(property_name=property_value, ...);

Examples

The data in the data.csv file is as follows:

ID,date,country,name,phonetype,serialname,salary
4,2014-01-21 00:00:00,city1,aaa4,phone2435,ASD66902,15003
5,2014-01-22 00:00:00,city1,aaa5,phone2441,ASD90633,15004
6,2014-03-07 00:00:00,city1,aaa6,phone294,ASD59961,15005

CREATE TABLE carbontable(ID int, date Timestamp, country String, name String, phonetype String, serialname String,salary int) STORED AS carbondata;

LOAD DATA inpath 'hdfs://hacluster/tmp/data.csv' INTO table carbontable

options('DELIMITER'=',');

System Response

Success or failure will be recorded in the driver logs.