《Programming Hive》讀書筆記(兩)Hive基礎知識

來源:互聯網
上載者:User

標籤:


《Programming Hive》讀書筆記(兩)Hive基礎知識

:第一遍讀是瀏覽。建立知識索引,由於有些知識不一定能用到,知道就好。感興趣的部分能夠多研究。

以後用的時候再具體看。並結合其它資料一起。



Chapter 3.Data Types and File Formats

未經處理資料類型和集合資料類型

Select出來的資料,列與列之間的分隔字元能夠指定


Chapter 4.HiveQL:Data Definition

建立資料庫,建立和修改表,分區的操作


Chapter 5.HiveQL:Data Manipulation

1 載入資料和匯出資料,應該從本地和HDFS都能夠。

2 建立表和將查詢結果插入到表中

 

 

Chapter 6.HiveQL:Queries select的各種文法,join,cluster by等

Where支援正則表達式like,rlike

 

JOIN:On條件不支援不等號,不支援OR

1 先join再where,會依據join過濾一批資料,然後依據where過濾一批

2 The partition filters are ignored for OUTER JOINTS. However, usingsuch filter predicates in ON clauses for inner joins does work! 

在outer join中。在on裡面寫分區條件是無用的。假設想通過分區條件加高速度,能夠通過子查詢再join的方法。

 

Inner join,left outer join,right outerjoin,left semi join(in的作用,但貌似高版本號碼的hive支援in子查詢)

 

hive >SELECT*FROMstocksJOINdividends

> WHEREstock.symbol=dividends.symbolandstock.symbol=‘AAPL‘;

Hive裡面,這條sql會先算笛卡爾積的再依據where過濾。

In Hive,this query computes the full Cartesianproduct before applying the WHERE

clause. Itcould take a very long time to finish. When the property hive.mapred.modeis

set to strict, Hive prevents users from inadvertentlyissuing a Cartesian product query.

 

兩個表join,假設當中一個較小。能夠通過map-side-join的方法加高速度。

只是這樣的最佳化不支援right-join和full-join。

Hive does not support theoptimization for right- and full-outer joins.

 

最佳化:滿足一定條件,設定相應的參數開啟。

 

The ORDER BY clause is familiar from other SQL dialects. It performs atotal orderingof

the query result set.This means that all the data is passed through a single reducer,

which may take an unacceptablylong time to execute for larger data sets.

Order by的排序是全域的,最後所有資料通過一個reducer來排序。

 

Because ORDER BY can result in excessively long run times, Hive willrequire a LIMIT

clause with ORDER BY if the property hive.mapred.mode is set to strict. Bydefault, it is

set to nonstrict.(注意事項)

 

sort by的排序是局部的

 

DISTRIBUTEBY controls how map output isdivided among reducers.

DISTRIBUTEBY能夠指定map輸出之後怎樣分配到各個reducer中。

一般是某個欄位同樣放在同一個reducer中,有點像groupby的思想。

常常跟sort by一起用(DISTRIBUTEBY放前面)。達到先分組再內部排序的效果。

 

Cluster by相等於distribute by加上sort by的效果。

 

額外資料:

http://www.cnblogs.com/ggjucheng/archive/2013/01/03/2843243.html

 

cast(valueAS TYPE)

強制性轉換時,得注意轉換後的值。看看是否達到你所須要的效果。

 

Queries from sample data

隨機抽取資料

 

部分未不懂。先無論。

BlockSampling

Input Pruningfor Bucket Tables

 

Union all合并兩個表



本文linger

本文連結:http://blog.csdn.net/lingerlanlan/article/details/41153799


著作權聲明:本文部落格原創文章,部落格,未經同意,不得轉載。

《Programming Hive》讀書筆記(兩)Hive基礎知識

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.