[英]Hive - External table creation
我正在學習 hive 並閱讀了一篇關於何時使用 HIVE 外部表的文章,並提到了下面的聲明。
查詢存儲在外部系統(例如 amazon s3)中的數據 - 避免將該數據引入 HDFS
任何人都可以詳細說明上述聲明。 “避免將該數據帶入 HDFS”? Load data local 命令將有助於將本地文件加載到 HDFS 中,HIVE 正在應用頂部的格式。
是否可以訪問 HDFS 之外的數據?
是否可以訪問 HDFS 之外的數據?
HIve 可以讀取任何 Hadoop 兼容文件系統上的數據,而不僅僅是 HDFS。
有人可以詳細說明上面的說法。 “避免將該數據帶入 HDFS”?
以 S3 為例,您可以創建一個位置為s3a://bucket/path
的外部表,除非您確實需要與 S3 相比讀取 HDFS 的速度,否則無需將其帶到 HDFS。 但是,要將數據集持久保存在臨時雲集群中,結果應該寫回到任何提供的長期存儲中。
有可能的。 你可以自己試試這個。 在 CDH 上,我有一個文件extn\\t.txt
[cloudera@quickstart ~]$ pwd
/home/cloudera
[cloudera@quickstart ~]$ cat extn/t.txt
something
[cloudera@quickstart ~]$
我現在可以創建一個外部表來訪問這個文件,如下所示
create external table tbl(line string)
location 'file:///home/cloudera/extn'
描述表
INFO : OK
+-----------+------------+----------+--+
| col_name | data_type | comment |
+-----------+------------+----------+--+
| line | string | |
+-----------+------------+----------+--+
1 row selected (0.152 seconds)
0: jdbc:hive2://localhost:10000>
選擇
INFO : OK
+------------+--+
| tbl.line |
+------------+--+
| something |
+------------+--+
1 row selected (0.134 seconds)
0: jdbc:hive2://localhost:10000>
描述格式化
+-------------------------------+----------------------------------------------------+-----------------------+--+
| col_name | data_type | comment |
+-------------------------------+----------------------------------------------------+-----------------------+--+
| # col_name | data_type | comment |
| | NULL | NULL |
| line | string | |
| | NULL | NULL |
| # Detailed Table Information | NULL | NULL |
| Database: | default | NULL |
| Owner: | cloudera | NULL |
| CreateTime: | Tue Feb 20 12:49:25 PST 2018 | NULL |
| LastAccessTime: | UNKNOWN | NULL |
| Protect Mode: | None | NULL |
| Retention: | 0 | NULL |
| Location: | file:/home/cloudera/extn | NULL |
| Table Type: | EXTERNAL_TABLE | NULL |
| Table Parameters: | NULL | NULL |
| | COLUMN_STATS_ACCURATE | false |
| | EXTERNAL | TRUE |
| | numFiles | 0 |
| | numRows | -1 |
| | rawDataSize | -1 |
| | totalSize | 0 |
| | transient_lastDdlTime | 1519159765 |
| | NULL | NULL |
| # Storage Information | NULL | NULL |
| SerDe Library: | org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | NULL |
| InputFormat: | org.apache.hadoop.mapred.TextInputFormat | NULL |
| OutputFormat: | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | NULL |
| Compressed: | No | NULL |
| Num Buckets: | -1 | NULL |
| Bucket Columns: | [] | NULL |
| Sort Columns: | [] | NULL |
| Storage Desc Params: | NULL | NULL |
| | serialization.format | 1 |
+-------------------------------+----------------------------------------------------+-----------------------+
負載數據不同。 請檢查此外部表與負載數據
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.