您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關hive如何正則建表,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
日志如下 192.168.244.35 - - [03/Dec/2015:23:22:11 +0800] "POST /touch/appService.hotwave HTTP/1.0" 200 77 "-" "Apache-HttpClient/4.1.3 (java 1.5)" "-" 120.132.34.5 "touch.cut.hotwave.com" 15 - - - - - 20fe3051-56bd-46f5-9964-e07202cbff07 建表 drop table if exists access_log_data; CREATE external TABLE access_log_data ( host STRING, identity STRING, user STRING, time STRING, methon string, request STRING, httpversion string, status STRING, size STRING, referer STRING, agent STRING, qunarglobal STRING, realip STRING, reqHost STRING, processTime STRING, qn48 STRING, clickid STRING, it STRING, et STRING ) partitioned by( dt string, server string ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe' WITH SERDEPROPERTIES ( "input.regex" = "([^ ]*) ([^ ]*) ([^ ]*) \\[([^\\]]*)\\] \"(GET|POST) ([^ ]*) ([^ ]*)\" (-|[0-9]*) (-|[0-9]*) \"([^ ]*|-)\"\\s\"((?:[^\"])+)\"\\s\"((?:[^\"])+)\"\\s([^ ]*|-)(?:, [^ ])?\\s\"([^ ]*)\"\\s([^ ]*) ([^ ]*|-) ([^ ]*|-) ([^ ]*|-) ([^ ]*|-)", "output.format.string" = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s %10$s %11$s %12$s %13$s %14$s %15$s %16$s %17$s %18$s %19$s" ) STORED AS TEXTFILE LOCATION '/user/searcher/access-log/access-test/'; 修改表 alter table hotwave_log_data set serdeproperties ( 'input.regex'="([^ ]*) ([^ ]*) ([^ ]*) \\[([^\\]]*)\\] \"(GET|POST) ([^ ]*) ([^ ]*)\" (-|[0-9]*) (-|[0-9]*) \"([^ ]*|-)\"\\s\"((?:[^\"])+)\"\\s\"((?:[^\"])+)\"\\s([^ ]*|-)(?:, [^ ])?\\s\"([^ ]*)\"\\s([^ ]*) ([^ ]*|-) ([^ ]*|-) ([^ ]*|-) ([^ ]*|-) ([^ ]*|-) ([^ ]*|-)", 'output.format.string'="%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s %10$s %11$s %12$s %13$s %14$s %15$s %16$s %17$s %18$s %19$s %20$s %21$s"); alter table hotwave_log_data add columns(qn1 string,ts string); 輸出 hive> select * from hotwave_log_data limit 1; OK 127.0.0.1 - - 02/Apr/2015:00:00:00 +0800 GET //touch/styles/common.js HTTP/1.0 200 2738 - Mozilla/5.0 (Linux; Android 4.4.2; SM-G9008V Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36 - 113.69.127.64 touch.hotwave.hotwave.com 0 - - - - NULL NULL 2015-04-02 l-xx.cx6
關于“hive如何正則建表”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。