1 資料加載基礎
1.1 資料加載文法格式
GBase 8a MPP Cluster支援通過SQL接口進行資料加載。
文法格式:
LOAD DATA INFILE ‘file_list’ INTO TABLE [dbname.]tbl_name [options]
options:
[CHARACTER SET charset_name]
[DATA_FORMAT number [HAVING LINES SEPARATOR]]
[NULL_VALUE ‘string’]
[FIELDS
[TERMINATED BY ‘string’]
[ENCLOSED BY ‘string’]
[PRESERVE BLANKS]
[AUTOFILL]
[LENGTH ‘string’]
[TABLE_FIELDS ‘string’]
]
[LINES
[TERMINATED BY ‘string’]
]
[MAX_BAD_RECORDS number]
[DATETIME FORMAT format]
[DATE FORMAT format]
[TIMESTAMP FORMAT format]
[TIME FORMAT format]
[TRACE number]
[TRACE_PATH ‘string’]
[NOSPLIT]
[PARALLEL number]
[MAX_DATA_PROCESSORS number]
[MIN_CHUNK_SIZE number]
[SKIP_BAD_FILE number]
[SET col_name = value[,…]]
[IGNORE NUM LINES]
[FILE_FORMAT format]
參數說明 :
FILE_LIST : 待加載檔案清單,或待加載資料檔案所在的目錄。支援URL的方式指定資料檔案路徑,以逗号(’,’)作為多個檔案/目錄的分隔符。
scheme://host:port/path, scheme://host:port/path
OPTIONS :
CHARACTER SET : 用來指定待加載資料檔案的編碼格式,目前支援GBK和UTF8兩種格式。省略時,認為不需要轉碼。
DATA_FORMAT : 用來指定使用哪種方式解析資料檔案并加載。指定為3,表示使用文本方式加載。指定為4,表示使用定長方式加載。如果某列資料可能包含了行分隔符,則需要在SQL中輸入’HAVING LINES SEPARATOR’子句。指定為5,表示使用文本檔案寬松模式,即資料源檔案為包圍符中含有換行符和包圍符文本檔案,或多列少列文本檔案。
NULL_VALUE : 用于指定空值字元,支援不超過15個任意字元的組合,參數值以引号包圍,指定方式與字段包圍符一樣。
FIELDS :
TERMINATED BY : 用于指定字段分隔符,支援不超過15個任意字元的組合,支援任意字元,參數值以引号包圍,僅當使用文本方式加載時有效。可使用字元本身(僅限可見字元,如 : “|”)、 C風格轉義字元(如 : “\a”)、 \xhh十六進制(如 : “\xFF”)或x’‘十六進制(如 : "x’09’")四種方式指定。例如 : ‘|’,表示用|作為分隔字元。
ENCLOSED BY : 用于指定字段包圍符,支援任意單字元,參數值以單引号包圍,僅當使用文本方式加載時有效。可使用字元本身(僅限可見字元,如 : “|”)、 C風格轉義字元(如 : “\a”)、 \xhh十六進制(如 : “\xFF”)或x’‘十六進制(如 : "x’09’")四種方式指定。
PRESERVE BLANKS : 用于設定是否保留字段内容兩端的空格,預設不保留白格。
AUTOFILL : 用于設定是否啟用缺失列自動補齊功能,啟用該參數後,對缺失分割符的字段資料按照default值或者NULL值進行加載,預設不自動補齊。
DEFINER : 在使用定長模式加載時,用于設定字段長度的參數。定長格式資料導入時,設定每個字段的長度,有多個字段時,用逗号分隔。
LENGTH : 在使用定長模式加載時,用于設定字段長度的參數。定長格式資料導入時,設定每個字段的長度,有多個字段時,用逗号分隔。
TABLE_FIELDS : 用于指定列加載,對于日期時間類型可以設定每一列的格式。
SET : 指定列值加載,加載系統将待加載檔案和指定加載列值加載到叢集系統的表中。輸入的類型應為常量,包括字元串、整數值、浮點值和NULL。
1、 支援指定所有列類型加載值;
2、 指定列值為常量值(包括NULL),包括字元串(單引号包圍)、十進制數值(10)、浮點值(10.9)、 NULL、 16進制表示的字元串(0xbac3)、科學計數法(10e4);
3、 支援多列同時指定加載值。最多可SET表列數-1 ,如果設定的列數與表定義中的列數一緻将報錯 : Specified all fields .
4、 支援format=3、 format=4以及format=5;
使用限制說明 :
1、 輸入除常量值外的其他值,如列名、表達式等會報錯,報錯資訊為Column ‘addr’ should be const value;
2、 指定的列不能存在于TABLE_FIELDS中,否則報錯;
3、 如果沒有指定AUTOFILL,指定值的列數+資料中列數之和必須等于表定義或者TABLE_FIELDS (若指定了TABLE_FIELDS)中的列數,否則會産生錯誤資料;如果指定了AUTOFILL,則可以小于表定義的列數,缺少的列會自動補全。如果TABLE_FIELDS列數+SET列數小于表定義的列數,能夠正常加載,沒有涉及的列按照default值補齊;
4、 同一列在SQL中不能重複指定,否則報錯。
LINES :
TERMINATED BY : 行分隔符,支援任意單字元,參數值以引号包圍。 指定方式與包圍符一樣。 預設行分隔符為’\n’。
MAX_BAD_RECORDS : 在每次加載的任務中,設定錯誤資料行數的上限。當本次加載任務産生的錯誤資料行數大于max_bad_records設定的值時,加載任務復原,加載工具報錯退出。不指定該參數表示不限制錯誤條數,指定該參數時,此參數取值範圍為 : [0, 4294967295]。 0表示隻要有錯誤資料就報錯退出。最大加載錯誤數的計算方式 : 所有叢集節點獨立計算,一旦有一個節點加載時錯誤資料達到本限制,則終止所有節點的加載任務。叢集加載送出之前檢查總錯誤條數是否超出限制,如果超出限制,放棄送出,報錯退出。
DATE FORMAT : 用來指定date列類型的預設格式,如’%Y-%m-%d’。
DATETIME FORMAT : 用來指定datetime列的預設格式,如’%Y-%m-%d %H:%i:%s’。
TIMESTAMP FORMAT : 用來指定timestamp列的預設格式,如’%Y-%m-%d %H:%i:%s’。
TIME FORMAT : 用來指定time列的預設格式,如’%H:%i:%s’。
TRACE : 用來訓示本次加載是否儲存錯誤資料溯源。如果指定為0, 則不溯源。如果指定為1,則進行溯源。預設值為1。溯源資訊包括 : 錯誤資料所在的檔案,所在行号。
TRACE_PATH : 用來指定本次加載過程中産生的錯誤資料和日志存放路徑。 在禁用日志彙總功能時, 該參數才能起作用, 預設值為加載節點的‚/opt/gnode/log/gbase/loader_logs‛中。
NOSPLIT : 用來指定本次加載任務中是否禁用分塊加載功能,指定該參數将禁用分塊加載功能。不指定該參數,在叢集加載時,将自動啟動分塊加載功能,按照資料量和參與運算的加載節點數對資料進行均勻分塊,以均衡資料伺服器和資料處理節點的負載,優化加載性能。
PARALLEL : 用來控制叢集加載并行度,取值範圍[0,1024]。預設值為0,表示并行度取值是線程池最大可用線程數。
MAX_DATA_PROCESSORS : 用來指定本次加載任務中參與資料解析的處理的最大節點數,取值範圍[1, 4294967295],預設值16。
MIN_CHUNK_SIZE : 用來指定本次加載任務中資料分塊的最小粒度,取值範圍[1,4294967295],預設值64M。
SKIP_BAD_FILE: 用來指定本次加載任務中是否忽略不存在或沒有讀取權限的資料檔案繼續加載。如果指定為0,則加載報錯終止。如果指定為1,則忽略異常檔案繼續加載。預設值為0。
IGNORE NUM LINES : 配置該參數加載工具會将本次加載指定的所有資料檔案的表頭進行過濾,跳過每個檔案的前NUM行(表頭所占行數), NUM取值範圍為[0,MAX_UINT]。
FILE_FORMAT:用來指定被加載檔案的格式。枚舉型參數,取值為UNDEFINED、UNCOMPRESSED、 GZIP、 SNAPPY、 LZO,預設為UNDEFINED。 指定為UNDEFINED,表示不指定格式,按檔案字尾自動判斷檔案格式; 指定為UNCOMPRESSED,表示按普通文本方式加載檔案;指定為GZIP,表示按GZIP格式加載檔案;指定為SNAPPY,表示按SNAPPY格式加載檔案; 指定為LZO,表示按LZO格式加載檔案。
1.2 資料加載使用限制
1.當使用定長加載模式時,必須指定FIELDS DEFINER的值。
2.當使用文本加載模式時,NULL_VALUE的預設值為’\N’。
3.當使用文本加載方式時,行分隔符預設為’\n’。
4.當使用文本加載方式時,如果某列資料可能包含了行分隔符,則需要在SQL中輸入’HAVING LINES SEPARATOR’子句,同時需要輸入入’ENCLOSED BY’指定字段包圍符
5.當在加載檔案清單的 URL 中的使用者名(user)、密碼(password)、主機名(host)或檔案路徑(path)中包含下表所列的特殊字元時,對特殊字元需要用百分号編碼代替。
URL : scheme://[user:password@]host[:port]/path
百分号編碼 = % + 特殊字元的兩字元十六進制值
1.3 資料加載權限說明
1.加載表的insert的權限grant insert on test.tmp_abc_1117_test to abc;
2.File權限 grant file on . to abc;
1.4 資料加載狀态監控
資料加載監控表information_schema.load_status
字段名稱 字段說明
SCN SCN
DB_NAME 庫名
TB_NAME 表名
IP 加載機IP
STATE 加載狀态
START_TIME 加載啟動時間
ELAPSED_TIME 加載結束時間
AVG_SPEED 加載速度
PROGRESS 加載進度
TOTAL_SIZE 檔案總長度
LOADED_SIZE 已加載資料量
LOADED_RECORDS 已加載資料條數
SKIPPED_RECORDS 跳過資料條數
DATA_SOURCE 資料源
SQL_CMD 加載任務的SQL
注 : [1]gcluster層看到的load_status是全部的load data 加載任務
[2]gnode層隻能看到自己節點上運作的load data 加載任務
1.5 加載錯誤資料與溯源資訊檢索
支援文法形式對于錯誤資料與溯源資訊檢索功能,具體文法如下:
show [ gcluster ] load logs task_id LIMIT {[offset,] row_count}
查詢結果資訊表定義如下:
字段 含義 類型 長度
TASK_ID 加載 ID varchar 64
DB_NAME 加載庫名 varchar 64
TB_NAME 加載表名 varchar 64
ERR_DATA_IP 産生錯誤資料的節點 IP varchar 20
FILE_NAME 加載檔案名 varchar 64
FILE_OFFSET 錯誤資料偏移量 varchar 64
RECORD_LEN 錯誤資料行長 varchar 64
ERR_COLUMN 錯誤資料列号 varchar 64
ERR_REASON 錯誤資料具體原因 varchar 1024
ERR_DATA 錯誤資料 varchar 4096
具體說明:
- show 文法查詢預設是傳回 offset 從 0 到 length 10 的 10 條錯誤資料與溯源資訊查詢,如果想查詢更多的資料可以調整 offset,length。
- show 文法查詢目前 coordinator 節點錯誤資料與溯源資訊進行檢索使用 show load logs task_id limit offset, row_count 進行查詢,傳回 row_count 條查詢結果。
- 查詢所有 coordiantor 節點錯誤資料與溯源資訊進行檢索使用 show gcluster load logs task_id limit offset, row_count 進行查詢,傳回 row_count 條查詢結果。
- ERR_DATA 的長度定義為 4096 個位元組。可以涵蓋絕大多數場景,對于超過長度的錯誤資料,顯示時做截斷處理,實際讀取 4096 個位元組。
- show 查詢功能,隻能查詢目前彙總目錄内的加載錯誤資料與溯源資訊。即如果使用者對 gbase_loader_logs_dir 做了變更後,将查詢不到原指定目錄中的資料。
-
Show 文法增加使用者查詢權限控制功能,預設僅能查詢目前使用者指定加載任務的錯誤資料與溯源資訊,有 process 權限的使用者可以查詢其他使用者指定加載任務的錯誤資料與溯源資訊。
1.6 資料加載使用示例
1.6.1 特定檔案加載
以文本方式加載位于ftp伺服器上的檔案lineorder1.tbl,預設行分隔符,指定|為列分隔符
LOAD DATA INFILE
‘ftp://gbase:[email protected]//opt/SSB/data/lineorder1.tbl’ INTO TABLE ssbm.lineorder1
data_format 3
fields terminated by ‘|’;
1.6.2 通配符加載
以文本方式加載位于ftp伺服器上的檔案*.tbl,預設行分隔符,指定|為列分隔符
LOAD DATA INFILE
‘ftp://gbase:[email protected]//opt/SSB/data/*.tbl’
INTO TABLE ssbm.lineorder1
data_format 3
fields terminated by ‘|’;
1.6.3 日期格式字段加載
文本檔案加載,預設行分隔符,指定逗号為列分隔符,指定null value,指定date、time、datetime日期格式,指定最大錯誤行數
load data infile 'ftp://gbase:[email protected]//home/gbase/1.txt ’
into table test.tmp_abc_0621_test
data_format 3
fields terminated by ‘,’
null_value ‘’
date format ‘%Y-%m-%d’
time format ‘%H:%i:%s’
datetime format ‘%Y-%m-%d %H:%i:%s’
max_bad_records 0;
1.6.4 多個不同類型協定資料檔案加載
LOAD DATA INFILE
‘http://gbase:[email protected]/1.txt,
ftp://gbase:[email protected]/1.txt’
INTO TABLE test.tmp_abc_0513_test
DATA_FORMAT 3;
Query OK, 5 rows affected (Elapsed: 00:00:00.25)
Task 288 finished, Loaded 5 records, Skipped 0 records
1.6.5 定長文本資料加載
定長文本加載,指定fields definer,table_fields
load data infile
‘ftp://gbase:[email protected]//home/gbase/1.txt’
into table provag.stg_d_evnt_4g_gprs_voice_12300_20161123
data_format 4
FIELDS definer
‘8,15,6,3,40,14,8,14,14,9,1,17,10,32,10,40,10,10’
TABLE_FIELDS ‘RECORD_NUM,MSISDN,VISIT_POSITION,ROAM_TYPE_CODE,APN_NET_ID,CALL_START_TIME,CALL_DUR,LAST_LINE_DATE_FLOW,NEXT_LINE_DATE_FLOW,TOTAL_FEE,GPRS_NET_TYPE,IMEI,BUSI_CODE,ITEM_IP_ADDRESS,GPRS_BILL_ID,IMS_BILL_ID,TAC_ID,CELL_ID’;
1.6.6 定長文本日期格式加載
load data infile
‘ftp://gbase:[email protected]//home/gbase/load_date.txt’
into table test.tmp_abc_1124_datetime_test
data_format 4
FIELDS length ‘19,10,8’
TABLE_FIELDS ‘create_time,v_date,v_time’;
1.6.7 資料加載預設去除兩邊空格
load data infile
‘ftp://gbase:[email protected]//home/gbase/load_blank.txt’ into table test.tmp_abc_1124_load_blank_test
data_format 4
FIELDS length ‘7’
TABLE_FIELDS ‘id’;
-
資料加載保留兩邊空格
load data infile
‘ftp://gbase:[email protected]//home/gbase/load_blank.txt’ into table test.tmp_abc_1124_load_blank_test
data_format 4
FIELDS length ‘7’
TABLE_FIELDS ‘id’
PRESERVE BLANKS;
1.6.8 表列數少于資料列數
通過table_fields 字段指定需要加載的字段 ,字段名以資料檔案順序為準,略過的資料列用 filler 替代。
資料格式 : 1,2
表結構 : create table “tmp_abc_1130_test2” ( “id” int(11) )
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/fill.txt’ into table test.tmp_abc_1130_test2 fields terminated by ‘,’ table_fields ‘filler,id’
-> ;
Query OK, 1 row affected (Elapsed: 00:00:01.70)
Task 340095 finished, Loaded 1 records, Skipped 0 records
gbase> select * from tmp_abc_1130_test2;
±-----+
| id |
±-----+
| 2 |
±-----+
1 row in set (Elapsed: 00:00:00.06)
1.6.9 表列數多于資料列數
通過table_fields字段指定需要加載的字段,指定字段個數與資料列數相同即可加載成功
資料格式 : 1,2
表結構 : create table “tmp_abc_1130_test3” ( “id1” int(11) , “id2” int(11) , “id3” int(11) )
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/fill.txt’ into table test.tmp_abc_1130_test3 fields terminated by ‘,’ table_fields ‘id1,id2’;
Query OK, 1 row affected (Elapsed: 00:00:01.51)
Task 340111 finished, Loaded 1 records, Skipped 0 records
gbase> select * from test.tmp_abc_1130_test3;
±-----±-----±-----+
| id1 | id2 | id3 |
±-----±-----±-----+
| 1 | 2 | NULL |
±-----±-----±-----+
1 row in set (Elapsed: 00:00:00.06)
1.6.10 skip_bad_file跳過錯誤檔案加載
skip_bad_file :
0 : 遇到錯誤檔案中斷加載
1 : 跳過錯誤檔案繼續加載
預設值是0,表示遇到錯誤檔案中斷加載
不設定skip_bad_file,10.17.5.225//opt/SSB/data/part1.tbl不存在,加載報錯
gbase> LOAD DATA INFILE ‘ftp://gbase:[email protected]//opt/SSB/data/part.tbl,ftp://gbase:[email protected]//opt/SSB/data/part1.tbl’ INTO TABLE ssbm.part data_format 3 fields terminated by ‘|’;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: I/O operation on ftp://gbase:@10.17.5.225//opt/SSB/data/part1.tbl failed with error - Remote file not found, 550 Could not get file size., File name ftp://gbase:@10.17.5.225//opt/SSB/data/part1.tbl
設定skip_bad_file=1,10.17.5.225//opt/SSB/data/part1.tbl不存在,加載報錯
gbase> LOAD DATA INFILE ‘ftp://gbase:[email protected]//opt/SSB/data/part.tbl,ftp://gbase:[email protected]//opt/SSB/data/part1.tbl’ INTO TABLE ssbm.part data_format 3 fields terminated by ‘|’ skip_bad_file 1;
Query OK, 0 rows affected (Elapsed: 00:00:00.98)
Task 262148 finished, Loaded 0 records, Skipped 2000000 records
1.6.11 預設值加載
load data infile ‘ftp://gbase:[email protected]//home/gbase/1.txt’ into table test.tmp_abc_0608_test data_format 3 fields terminated by ‘|’ table_fields ‘id’ set op_time=‘2017-06-08’;
1.6.12 使用CHARACTER SET加載資料檔案
load data infile ‘http://192.168.153.32/1.txt’ into table test_8 character set gbk fields terminated by ‘|’;
1.6.13 使用MAX_BAD_RECORDS加載資料檔案
load data infile ‘http://192.168.153.32/1.txt’ into table test_2 fields
terminated by ‘|’ max_bad_records 1;
1.7 資料加載常見錯誤
1.7.1 Login denied uri
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/*.tbl’ into table test.tmp_abc_1212_test data_format 3;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: Expanding wildcard operation failed with error - Login denied uri : ftp://gbase:@192.168.12.1//home/gbase/%2a.tbl.
錯誤原因 : gbase使用者密碼錯誤
1.7.2 Couldn’t connect to server
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/1.txt’ into table test.tmp_abc_1212_test data_format 3;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: I/O operation on ftp://gbase:@192.168.12.1//home/gbase/1.txt failed with error - Couldn’t connect to server, File name ftp://gbase:@192.168.12.1//home/gbase/1.txt
報錯原因 : ip位址錯誤或者vsftpd服務沒有啟動
1.7.3 failed to get table distribution information.
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/1.txt’ into table test.tmp_abc_0621_test data_format 3;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: failed to get table distribution information.
報錯原因 : 所涉及加載表不存在
1.7.4 550 Could not get file size.
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/4.txt’ into table test.tmp_abc_1212_test data_format 3;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: I/O operation on ftp://gbase:@192.168.12.1//home/gbase/4.txt failed with error - 550 Could not get file size., File name ftp://gbase:**@192.168.12.1//home/gbase/4.txt
錯誤原因 : /home/gbase/4.txt 這個檔案不存在
1.7.5 Remote file not found uri
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/*.tbl’ into table test.tmp_abc_1212_test data_format 3;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: Expanding wildcard operation failed with error - Remote file not found uri : ftp://gbase:*****@192.168.12.1//home/gbase/%2a.tbl.
錯誤原因 : /home/gbase/*.tbl 沒有比對到檔案,通配符檔案不存在
1.7.6 Access denied to remote resource
測試用例 :
gbase> load data infile ‘ftp://gbase:[email protected]/home/gbase/2.txt’ into table test.tmp_abc_1212_test data_format 3 max_bad_records 0;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: I/O operation on ftp://gbase:@192.168.12.1/home/gbase/2.txt failed with error - Access denied to remote resource, File name ftp://gbase:@192.168.12.1/home/gbase/2.txt
錯誤原因 : /home/gbase/2.txt路徑錯誤
1.7.7 Too many bad records
測試用例 :
load data infile ‘ftp://gbase:[email protected]//home/gbase/2.txt’
into table test.tmp_abc_1212_test data_format 3 max_bad_records 0;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: Task 262162 failed, 172.16.128.12:5050Failed to query in gnode:
DETAIL: (GBA-01-600) Gbase internal error: Task 262162, Too many bad records!
錯誤原因 : 錯誤資料行數超過max_bad_records指定值
1.7.8 read operation timeout
測試用例 :
2016-12-15 14:52:47.253 [SQLDISP][ERROR][S:83876][Q:696407]:Query failed, THD(0x4b9f6000) HOST(10.17.6.52:5050->50885) reason: (GBA-01-600) Gbase internal error: I/O operation on ftp://doubass:*********@10.255.219.24//data3/asiainfo/interface/12300/data/s_12300_BAS_04002_20161214_011_00_016.dat failed with error - read operation timeout
錯誤原因 : 如果填充一個資料塊(8M)的時間超過[gbase_loader_read_timeout]參數值,加載任務将報錯停止
1.7.9 Timeout was reached
測試用例 :
2016-12-15 15:49:52.221 [SQLDISP][ERROR][S:191527][Q:1487078]:
Query failed, THD(0x429ae000) HOST(10.17.6.95:5050->110938) reason: (GBA-01-600)
Gbase internal error: Task 622072, I/O operation on
ftp://doubass:*********@10.255.219.26//data6/asiainfo/interface/12900/data/a_12900_BAS_01002_20161214_00.verf failed with error - Timeout was reached
錯誤原因 : ftp伺服器端逾時
1.7.10 Line length is more than gbase_loader_max_line_length
測試用例:
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/024123_0’ into table test.tmp_abc_1220_test data_format 3;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: Task 393223 failed, 172.16.128.12:5050Failed to query in gnode:
DETAIL: (GBA-01-600) Gbase internal error: Line length 8388608 is more than gbase_loader_max_line_length ( 4194304 ) in file ‘ftp://gbase:*****@192.168.12.1//home/gbase/024123_0’
錯誤原因 : 行長度超過參數gbase_loader_max_line_length值。
1.7.11 validate error
測試用例1 : 字元串加載到數字類型字段
[1]資料内容 :
[[email protected] gbase]# cat 1.txt
1
2
3
a
[2]表結構 : create table tmp_abc_1212_test(id int);
[3]加載sql :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/1.txt’ into table test.tmp_abc_1212_test data_format 3;
Query OK, 3 rows affected (Elapsed: 00:00:01.32)
Task 393224 finished, Loaded 3 records, Skipped 1 records
[4]存在一條skip資料,檢視trc日志 :
[[email protected] gbase]# ls -lrt /opt/gclustrer/log/gcluster/loader_logs/393224*
-rw-rw---- 1 gbase gbase 146 12月 20 04:43 /opt/gclustrer/log/gcluster/loader_logs/393224_test_tmp_abc_1212_test_n1_192.168.12.1_20161220044343.trc
-rw-rw---- 1 gbase gbase 2 12月 20 04:43 /opt/gclustrer/log/gcluster/loader_logs/393224_test_tmp_abc_1212_test_n1_192.168.12.1_20161220044343.err
[[email protected] gbase]# cat
/opt/gclustrer/log/gcluster/loader_logs/393224_test_tmp_abc_1212_test_n1_192.168.12.1_20161220044343.trc
file_name | file_offset | record_len | column | reason
ftp://gbase:*****@192.168.12.1//home/gbase/1.txt|6|2|1|validate error
測試用例2 : yyyymmdd日期格式資料加載到date字段
[1]資料内容
[[email protected] gbase]# cat date.txt
20161212
[2]表結構 : create table tmp_abc_1212_date_test(v_date date);
[3]加載sql :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/date.txt’ into table test.tmp_abc_1220_date_test data_format 3 max_bad_records 0;
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: Task 393227 failed, 192.168.12.1:5050Failed to query in gnode:
DETAIL: (GBA-01-600) Gbase internal error: Task 393227, Too many bad records!
[4] 檢視trc日志 :
[[email protected] ~]# cat /opt/gclustrer/log/gcluster/loader_logs/393226_test_tmp_abc_1220_date_test_n1_172.16.128.12_20161220225132.trc
file_name | file_offset | record_len | column | reason
ftp://gbase:*****@192.168.12.1//home/gbase/date.txt|0|9|1|validate error
1.7.12 text parser error
測試用例 : 表列數與檔案列數不一緻,檔案列數多于表列數
[1]資料内容 :
[[email protected] gbase]# cat 1212.txt
1,2
[2]表結構 : create table tmp_abc_1212_test(id int);
[3]加載sql :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/1212.txt’ into table test.tmp_abc_1212_test data_format 3 fields terminated by ‘,’;
Query OK, 0 rows affected (Elapsed: 00:00:00.63)
Task 393231 finished, Loaded 0 records, Skipped 1 records
[4]存在一條skip資料,檢視trc日志 :
[[email protected] gbase]# ls -lrt /opt/gclustrer/log/gcluster/loader_logs/393231*
-rw-rw---- 1 gbase gbase 152 12月 20 23:40 /opt/gclustrer/log/gcluster/loader_logs/393231_test_tmp_abc_1212_test_n1_172.16.128.12_20161220234049.trc
-rw-rw---- 1 gbase gbase 4 12月 20 23:40 /opt/gclustrer/log/gcluster/loader_logs/393231_test_tmp_abc_1212_test_n1_172.16.128.12_20161220234049.err
[[email protected] ~]# cat /opt/gclustrer/log/gcluster/loader_logs/393231_test_tmp_abc_1212_test_n1_172.16.128.12_20161220234049.trc
file_name | file_offset | record_len | column | reason
ftp://gbase:*****@192.168.12.1//home/gbase/1212.txt|0|4|2|text parser error
1.7.13 data column size less than defined size
測試用例 : 表列數與檔案列數不一緻,檔案列數少于表列數
[1]資料内容 :
[[email protected] gbase]# cat 1.txt
1
[2]表結構 : create table tmp_abc_1212_test1(id int,name varchar(10));
[3]加載sql :
gbase> load data infile ‘ftp://gbase:[email protected]//home/gbase/1.txt’ into table test.tmp_abc_1212_test1 data_format 3;
Query OK, 0 rows affected (Elapsed: 00:00:00.38)
Task 393233 finished, Loaded 0 records, Skipped 4 records
[4]存在4條skip資料
[[email protected] gbase]# ls -lrt /opt/gclustrer/log/gcluster/loader_logs/393233*
-rw-rw---- 1 gbase gbase 459 12月 20 23:47 /opt/gclustrer/log/gcluster/loader_logs/393233_test_tmp_abc_1212_test1_n1_172.16.128.12_20161220234703.trc
-rw-rw---- 1 gbase gbase 8 12月 20 23:47 /opt/gclustrer/log/gcluster/loader_logs/393233_test_tmp_abc_1212_test1_n1_172.16.128.12_20161220234703.err
[[email protected] ~]# cat
/opt/gclustrer/log/gcluster/loader_logs/393233_test_tmp_abc_1212_test1_n1_172.16.128.12_20161220234703.trc
file_name | file_offset | record_len | column | reason
ftp://gbase:*****@192.168.12.1//home/gbase/1.txt|0|2|1|data column size less than defined size