这篇文章将为大家详细讲解有关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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。