{"id":2801,"date":"2020-09-02T17:42:02","date_gmt":"2020-09-02T09:42:02","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=2801"},"modified":"2025-01-22T16:20:46","modified_gmt":"2025-01-22T08:20:46","slug":"inceptor-%e6%95%b0%e6%8d%ae%e5%af%bc%e5%85%a5%e5%af%bc%e5%87%ba%e4%b9%8binsert-overwrite","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=2801","title":{"rendered":"Inceptor \u6570\u636e\u5bfc\u5165\u5bfc\u51fa\u4e4bInsert overwrite"},"content":{"rendered":"<h3>\u6982\u8981\u8bf4\u660e<\/h3>\n<hr \/>\n<p>\u9762\u5bf9\u4e00\u4e9b\u91cd\u8981\u6570\u636e\uff0c\u5f88\u591a\u573a\u666f\u4e0b\u90fd\u9700\u8981\u5c06\u6570\u636e\u4ed3\u5e93\u8fdb\u884c\u590d\u5236\uff0c\u8fd9\u53ef\u4ee5\u662f\u6574\u4e2a\u6570\u636e\u5e93\u7684\u66f4\u5e7f\u6cdb\u7ea7\u522b\uff0c\u4e5f\u53ef\u4ee5\u662f\u8f83\u5c0f\u7684\u7ea7\u522b\uff0c\u4f8b\u5982\u8868\u6216\u5206\u533a\u3002\u672c\u6848\u4f8b\u5c06\u6f14\u793a\u4f7f\u7528Insert overwrite dirctory \u7136\u540eSQL \u5efa\u5916\u8868\u7684\u65b9\u5f0f\u5bfc\u5165\u5bfc\u51fa\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<p>Inceptor \u6570\u636e\u5bfc\u5165\u5bfc\u51fa\u65b9\u6cd5\u5927\u81f4\u5206\u4e3a\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n<ol>\n<li>Export\/Import<\/li>\n<li>Insert Overwrite Dirctory\uff0c\u7136\u540e\u5efa\u5916\u8868\u7684\u65b9\u5f0f<\/li>\n<li>HDFS \u7684 get\u3001put\uff0c\u4ee5\u53caInceptor \u7684 Load \u6216\u8005 Location<\/li>\n<\/ol>\n<p>\u672c\u6848\u4f8b\u4ecb\u7ecd\u4f7f\u7528Insert overwrite dirctory\u7684\u65b9\u5f0f\u5bfc\u5165\u5bfc\u51fa Inceptor \u6570\u636e\u5927\u81f4\u5206\u4e3a4\u6b65\uff1a<\/p>\n<ol>\n<li>insert \u5230\u6e90\u96c6\u7fa4\u7684 HDFS \uff0c\u5e76get \u5230\u672c\u5730\u6587\u4ef6\u7cfb\u7edf<\/li>\n<li>\u5c06\u6e90\u96c6\u7fa4\u7684\u6587\u4ef6 scp \u5230 \u76ee\u6807\u96c6\u7fa4\uff0c\u5e76 put \u5230\u76ee\u6807\u96c6\u7fa4\u7684HDFS<\/li>\n<li>\u5728\u76ee\u6807\u96c6\u7fa4\u521b\u5efa\u5916\u8868\u6307\u5b9alocation\uff0c\u6216\u8005load \u6570\u636e\u5230\u5916\u8868<\/li>\n<li>\u5728\u76ee\u6807\u96c6\u7fa4\u521b\u5efaORC \u975e\u5206\u533a\u666e\u901a\u8868\uff0c\u7136\u540einsert into select<\/li>\n<\/ol>\n<h4>1\u3001insert\u5230\u6e90\u96c6\u7fa4HDFS\uff0c\u5e76get \u5230\u672c\u5730\u6587\u4ef6\u7cfb\u7edf<\/h4>\n<p>a\u3001\u5199\u5165\u6e90 HDFS \u6587\u4ef6\u7cfb\u7edf\uff0c\u8bed\u6cd5\uff1a<\/p>\n<pre><code>INSERT OVERWRITE DIRECTORY '\/crmdev\/orc_unpart\/' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' SELECT * FROM crmdev.orc_unpart;<\/code><\/pre>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd9\u4e2a\u8bed\u53e5\u5c06\u67e5\u8be2\u7ed3\u679c\u5199\u5165\u4e00\u4e2a \u76ee\u5f55\uff0c\u800c\u4e0d\u662f\u6587\u4ef6\uff0c\u5199\u5165\u7684\u7ed3\u679c\u53ef\u80fd\u662f\u591a\u4e2a\u6587\u4ef6\u3002<\/li>\n<li>\u5199\u5165\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u8981\u52a0\u4e0a LOCAL \u5173\u952e\u5b57\uff1b\u5199\u5165\u7684\u662f server \u6240\u5728\u7684pod\u5185\u7684\u8def\u5f84\uff1b<\/li>\n<li>ROW FORMAT\u6307\u5b9a\u6587\u4ef6\u7684\u884c\u683c\u5f0f\uff0c\u4e0d\u6307\u5b9a\u4f7f\u7528\u9ed8\u8ba4\u503c\uff1b<\/li>\n<li>STORED AS\u6307\u5b9a\u6587\u4ef6\u683c\u5f0f\uff0c\u4e0d\u6307\u5b9a\u5219\u4f7f\u7528\u9ed8\u8ba4\u503c\uff1b<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5fc5\u987b\u662fHDFS \u6587\u4ef6\u7cfb\u7edf\uff1b<\/li>\n<li>\u5fc5\u987b\u6307\u5b9a\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u7684\u5206\u9694\u7b26\u662fSOH\uff0c\u5728\u5bfc\u5165\u7684\u65f6\u5019\u8bc6\u522b\u4e0d\u4e86\uff1b<\/li>\n<\/ul>\n<p>b\u3001get \u5230\u6e90\u96c6\u7fa4\u7684\u672c\u5730\u6587\u4ef6\u7cfb\u7edf<\/p>\n<pre><code>$ hadoop fs -get \/crmdev\/orc_unpart\/\n2020-04-07 11:01:00,360 INFO util.KerberosUtil: Using principal pattern: HTTP\/_HOST\n$ ls -l\n\u603b\u7528\u91cf 4\ndrwxr-xr-x 2 root root 4096 4\u6708   7 11:01 orc_unpart<\/code><\/pre>\n<h4>2\u3001\u5c06\u6e90\u96c6\u7fa4\u7684\u6587\u4ef6 scp \u5230 \u76ee\u6807\u96c6\u7fa4\uff0c\u5e76 put \u5230\u76ee\u6807\u96c6\u7fa4\u7684HDFS<\/h4>\n<pre><code>$ scp -r orc_unpart\/ 172.22.22.24:\/mnt\/disk1\/crmdev\/\nroot@172.22.22.24's password: \n000000_0                            100%   17MB  17.3MB\/s   00:00\n000001_0                            100%   17MB  17.2MB\/s   00:00\n000002_0                            100%   17MB  17.1MB\/s   00:00<\/code><\/pre>\n<p>\u5728\u76ee\u6807\u96c6\u7fa4\u5c06\u6570\u636e\u4e0a\u4f20\u5230\u76ee\u6807\u96c6\u7fa4\u7684HDFS\uff1a<\/p>\n<pre><code>$ hadoop fs -put orc_unpart\/ \/crmdev\/\n2020-04-07 11:34:08,536 INFO util.KerberosUtil: Using principal pattern: HTTP\/_HOST<\/code><\/pre>\n<h4>3\u3001\u5728\u76ee\u6807\u96c6\u7fa4\u521b\u5efa\u5916\u8868\u6307\u5b9alocation\uff0c\u6216\u8005load \u6570\u636e\u5230\u5916\u8868<\/h4>\n<p>\u521b\u5efa\u5916\u8868\u7684\u8bed\u53e5\u4e2dROW FORMAT DELIMITED FIELDS TERMINATED BY &#8216;,&#8217;\u9700\u8981\u4e0eINSERT OVERWRITE DIRECTORY &#8216;\/crmdev\/orc_unpart\/&#8217; ROW FORMAT DELIMITED FIELDS TERMINATED BY &#8216;,&#8217; SELECT * FROM crmdev.orc_unpart;\u4e2d\u7684\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<pre><code>CREATE EXTERNAL TABLE crmdev.csv_unpart(\n  group_id int DEFAULT NULL, \n  code string DEFAULT NULL, \n  name string DEFAULT NULL, \n  new_price decimal(8,2) DEFAULT NULL, \n  main_percent decimal(8,2) DEFAULT NULL, \n  today_ranking decimal(8,2) DEFAULT NULL, \n  rise_percent decimal(6,2) DEFAULT NULL, \n  fiveday_percent decimal(8,2) DEFAULT NULL, \n  fiveday_ranking decimal(6,2) DEFAULT NULL, \n  fiveday_rise_percent decimal(5,2) DEFAULT NULL, \n  teneday_percent decimal(8,2) DEFAULT NULL, \n  tenday_ranking decimal(6,2) DEFAULT NULL, \n  tenday_rise_percent decimal(5,2) DEFAULT NULL, \n  guild string DEFAULT NULL, \n  code_id string DEFAULT NULL, \n  data_dt date DEFAULT NULL\n)\nROW FORMAT DELIMITED FIELDS TERMINATED BY ',' \nSTORED AS CSVFILE;<\/code><\/pre>\n<p>\u7136\u540e\u5728\u5efa\u8868\u7684\u65f6\u5019\u76f4\u63a5\u6307\u5b9a location \u5230 HDFS \u6587\u4ef6\u4f4d\u7f6e\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code>CREATE EXTERNAL TABLE crmdev.csv_unpart(\n  group_id int DEFAULT NULL, \n  code string DEFAULT NULL, \n  name string DEFAULT NULL, \n  new_price decimal(8,2) DEFAULT NULL, \n  main_percent decimal(8,2) DEFAULT NULL, \n  today_ranking decimal(8,2) DEFAULT NULL, \n  rise_percent decimal(6,2) DEFAULT NULL, \n  fiveday_percent decimal(8,2) DEFAULT NULL, \n  fiveday_ranking decimal(6,2) DEFAULT NULL, \n  fiveday_rise_percent decimal(5,2) DEFAULT NULL, \n  teneday_percent decimal(8,2) DEFAULT NULL, \n  tenday_ranking decimal(6,2) DEFAULT NULL, \n  tenday_rise_percent decimal(5,2) DEFAULT NULL, \n  guild string DEFAULT NULL, \n  code_id string DEFAULT NULL, \n  data_dt date DEFAULT NULL\n)\nROW FORMAT DELIMITED FIELDS TERMINATED BY ',' \nSTORED AS CSVFILE\nLOCATION '\/crmdev\/orc_unpart\/';<\/code><\/pre>\n<p>\u4e25\u7981\u76f4\u63a5\u9488\u5bf9\u8be5HDFS \u6587\u4ef6\u521b\u5efaORC \u8868\uff0c\u540e\u8005load \u5230ORC \u8868\uff0c\u5728 load \u6216\u8005location\u5efa\u8868\u7684\u65f6\u5019\u4e0d\u4f1a\u62a5\u9519\uff0c\u4f46\u662f\u5728\u67e5\u8be2\u7684\u65f6\u5019\u4f1a\u629b\u5f02\u5e38\uff0c\u4f1a\u62a5\u9519format \u9519\u8bef\uff1a<\/p>\n<pre><code>java.io.IOException: Malformed ORC file <\/code><\/pre>\n<h4>4\u3001\u5728\u76ee\u6807\u96c6\u7fa4\u521b\u5efaORC \u975e\u5206\u533a\u666e\u901a\u8868\uff0c\u7136\u540einsert into select<\/h4>\n<p>\u5728\u76ee\u6807\u96c6\u7fa4\u521b\u5efa ORC \u76ee\u6807\u8868\uff1b<\/p>\n<pre><code>CREATE TABLE crmdev.orc_unpart(\n  group_id int DEFAULT NULL, \n  code string DEFAULT NULL, \n  name string DEFAULT NULL, \n  new_price decimal(8,2) DEFAULT NULL, \n  main_percent decimal(8,2) DEFAULT NULL, \n  today_ranking decimal(8,2) DEFAULT NULL, \n  rise_percent decimal(6,2) DEFAULT NULL, \n  fiveday_percent decimal(8,2) DEFAULT NULL, \n  fiveday_ranking decimal(6,2) DEFAULT NULL, \n  fiveday_rise_percent decimal(5,2) DEFAULT NULL, \n  teneday_percent decimal(8,2) DEFAULT NULL, \n  tenday_ranking decimal(6,2) DEFAULT NULL, \n  tenday_rise_percent decimal(5,2) DEFAULT NULL, \n  guild string DEFAULT NULL, \n  code_id string DEFAULT NULL, \n  data_dt date DEFAULT NULL\n)\nSTORED AS ORC;<\/code><\/pre>\n<p>\u7136\u540e INSERT INTO TABLE crmdev.orc_unpart SELECT * FROM crmdev.csv_unpart;\u5c06\u8fc1\u79fb\u8fc7\u6765\u7684\u5916\u8868\u7684\u6570\u636e\u5199\u5165\u5230\u5185\u8868\uff1b<\/p>\n<pre><code>INSERT INTO TABLE crmdev.orc_unpart SELECT * FROM crmdev.csv_unpart;<\/code><\/pre>\n<p>\u81f3\u6b64\uff0csql \u65b9\u5f0f\u8fc1\u79fb ORC \u975e\u5206\u533a\u8868\u5b8c\u6210\uff1b\u7406\u8bba\u4e0a\uff0c\u8fd9\u79cd\u65b9\u5f0f\u652f\u6301\u6240\u6709\u8868\u7684\u8fc1\u79fb\uff1b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u8bf4\u660e \u9762\u5bf9\u4e00\u4e9b\u91cd\u8981\u6570\u636e\uff0c\u5f88\u591a\u573a\u666f\u4e0b\u90fd\u9700\u8981\u5c06\u6570\u636e\u4ed3\u5e93\u8fdb\u884c\u590d\u5236\uff0c\u8fd9\u53ef\u4ee5\u662f\u6574\u4e2a\u6570\u636e\u5e93\u7684\u66f4\u5e7f\u6cdb\u7ea7\u522b\uff0c\u4e5f\u53ef\u4ee5\u662f\u8f83\u5c0f\u7684 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=2801\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2801","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2801"}],"version-history":[{"count":1,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2801\/revisions"}],"predecessor-version":[{"id":15696,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2801\/revisions\/15696"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}