{"id":1430,"date":"2016-08-11T10:11:02","date_gmt":"2016-08-11T10:11:02","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=1430"},"modified":"2016-08-12T13:34:20","modified_gmt":"2016-08-12T13:34:20","slug":"1430","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/1430\/","title":{"rendered":"Hive Queries"},"content":{"rendered":"<p><strong>Table Creation<\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nCREATE TABLE HomeNeeds(Type STRING, Product STRING, No INT)\r\nROW FORMAT DELIMITED\r\nFIELDS TERMINATED BY ','\r\nSTORED AS TextFile;\r\n<\/pre>\n<p><strong>Insertion<\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nLOAD DATA LOCAL INPATH '\/home\/turbo\/workspace\/Sample Datas\/Test.csv'\r\nOVERWRITE INTO TABLE HomeNeeds;\r\n<\/pre>\n<p><strong>Create Table with Partition<\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nCREATE TABLE HomeNeeds(Type String, Product String, No Int)\r\nPARTITIONED BY (Date String, Country String)  \r\nROW FORMAT DELIMITED\r\nFIELDS TERMINATED BY ','; \r\n<\/pre>\n<p><em>The Partitioned columns and Table columns have no Relations with one another<\/em><\/p>\n<p><strong>Inserting into Partitioned Table<\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nLOAD DATA LOCAL INPATH '\/home\/turbo\/workspace\/Sample Datas\/Test.csv' \r\nINTO TABLE HomeNeeds\r\nPARTITION (Date='2001-01-25', Country='India');\r\n<\/pre>\n<p><strong>Partition and Bucketing<\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nCREATE TABLE HomeNeeds(Type String, Item String, No Int)\r\nPARTITIONED BY (Area String)\r\nCLUSTERED BY (Type) INTO 4 BUCKETS\r\nROW FORMAT DELIMITED\r\nFIELDS TERMINATED BY ',';\r\n\r\n<\/pre>\n<p><strong><\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n<\/pre>\n<p><strong><\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n<\/pre>\n<p><strong><\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n<\/pre>\n<p><strong><\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Table Creation CREATE TABLE HomeNeeds(Type STRING, Product STRING, No INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY &#8216;,&#8217; STORED AS TextFile; Insertion LOAD DATA LOCAL INPATH &#8216;\/home\/turbo\/workspace\/Sample Datas\/Test.csv&#8217; OVERWRITE INTO TABLE HomeNeeds; Create Table with Partition CREATE TABLE HomeNeeds(Type String, Product String, No Int) PARTITIONED BY (Date String, Country String) ROW FORMAT DELIMITED FIELDS TERMINATED BY&hellip; <a href=\"https:\/\/codethataint.com\/blog\/1430\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[186],"tags":[],"class_list":["post-1430","post","type-post","status-publish","format-standard","hentry","category-hive"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=1430"}],"version-history":[{"count":3,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1430\/revisions"}],"predecessor-version":[{"id":1433,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1430\/revisions\/1433"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=1430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=1430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=1430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}