hue上的hive編輯器比較智能,可以預(yù)先提示錯誤,以及根據(jù)前綴提示表名和列名。
hive的編輯器有很多快捷鍵,熟悉快捷鍵后可以快速提高工作效率。
一、查看快捷鍵的方式
單擊下圖中問號:

查看快捷鍵的方式.png

快捷鍵和語法
二、hive的語法
2.1 注釋
A comment is text that is not executed. It can be of two types:
注釋不會被執(zhí)行。hive編輯器支持兩種注釋:
單行注釋:
-- Comment
多行注釋
/* Multi Line
Comment */
2.2 點擊
-
雙擊:雙擊編輯器左邊行數(shù)選擇所有行。
雙擊行數(shù)選擇所有行 -
拖拽
從助手拖拽表名到編輯器可以插入相應(yīng)查詢樣例到編輯器。
插入相應(yīng)查詢樣例到編輯器 -
右鍵單擊:右鍵單擊hql中的元素可以瀏覽到元素相應(yīng)的信息。元素包括函數(shù)、列名、表名等。
右鍵單擊 - 單擊:單擊左邊編輯器的行數(shù)選擇一整行。
2.3 多語句查詢
在一個編輯器里通過;分隔多個查詢語句。
執(zhí)行鼠標(biāo)位置hql。
select * from customers;
select * from web_logs;
2.4 變量
變量是為了在查詢中容易配置參數(shù)??偣灿袃煞N類型變量。
- 單值變量:
${variable_name}
select * from web_logs where country_code = "${country_code}"
變量可以設(shè)置默認(rèn)值:
select * from web_logs where country_code = "${country_code=US}"
- 多值變量:
${variable_name=variable_value1, variable_value2,...}
select * from web_logs where country_code = "${country_code=CA, FR, US}"
改變展示內(nèi)容。展示名字和變量值不一致。
select * from web_logs where country_code = "${country_code=CA(Canada), FR(France), US(United States)}"
三、快捷鍵
快捷鍵支持windows/linux系列和mac系統(tǒng)。
mac筆記本電腦沒有delete、home 、end鍵。
delete:fn + Backspace
home:fn + left
end: fn + right
3.1 行操作
| Windows/Linux | Mac | 描述 | 中文描述 |
|---|---|---|---|
| Ctrl-D | Command-D | Remove line | 刪除行 |
| Alt-Shift-Down | Command-Option-Down | Copy lines down | 向下復(fù)制一行 |
| Alt-Shift-Up | Command-Option-Up | Copy lines up | 向上復(fù)制一行 |
| Alt-Down | Option-Down | Move lines down | 下移行 |
| Alt-Up | Option-Up | Move lines up | 上移行 |
| Alt-Delete | Ctrl-K | Remove to line end | 刪除到行尾 |
| Alt-Backspace | Command-Backspace | Remove to line start | 刪除到行頭 |
| Ctrl-Backspace | Option-Backspace, Ctrl-Option-Backspace | Remove word left | 向左邊刪除一個單詞 |
| Ctrl-Delete | Option-Delete | Remove word right | 向右邊刪除一個單詞 |
| --- | Ctrl-O | Split line | 插入一行 |
3.2 選擇
| Windows/Linux | Mac | Action | 描述 |
|---|---|---|---|
| Ctrl-A | Command-A | Select all | 全選 |
| Shift-Left | Shift-Left | Select left | 往左邊選擇 |
| Shift-Right | Shift-Right | Select right | 往右邊選擇 |
| Ctrl-Shift-Left | Option-Shift-Left | Select word left | 往左邊選擇一個單詞 |
| Ctrl-Shift-Right | Option-Shift-Right | Select word right | 往右邊選擇一個單詞 |
| Shift-Home | Shift-Home | Select line start | 選擇到行首 |
| Shift-End | Shift-End | Select line end | 選擇到行尾 |
| Alt-Shift-Right | Command-Shift-Right | Select to line end | 選擇到行尾 |
| Alt-Shift-Left | Command-Shift-Left | Select to line start | 選擇到行首 |
| Shift-Up | Shift-Up | Select up | 向上選擇一行 |
| Shift-Down | Shift-Down | Select down | 向下選擇一行 |
| Shift-PageUp | Shift-PageUp | Select page up | 向上選擇一頁 |
| Shift-PageDown | Shift-PageDown | Select page down | 向下選擇一頁 |
| Ctrl-Shift-Home | Command-Shift-Up | Select to start | 選擇從當(dāng)前到開始 |
| Ctrl-Shift-End | Command-Shift-Down | Select to end | 選擇從當(dāng)前到結(jié)尾 |
| Ctrl-Shift-D | Command-Shift-D | Duplicate selection | 復(fù)制 |
| Ctrl-Shift-P | --- | Select to matching bracket |
3.3 多光標(biāo)
| Windows/Linux | Mac | Action | 描述 |
|---|---|---|---|
| Ctrl-Alt-Up | Ctrl-Option-Up | Add multi-cursor above | 向上增加光標(biāo) |
| Ctrl-Alt-Down | Ctrl-Option-Down | Add multi-cursor below | 向下增加光標(biāo) |
| Ctrl-Alt-Right | Ctrl-Option-Right | Add next occurrence to multi-selection | 向下一個發(fā)生的地方增加選擇 |
| Ctrl-Alt-Left | Ctrl-Option-Left | Add previous occurrence to multi-selection | 向上一個發(fā)生的地方增加選擇 |
| Ctrl-Alt-Shift-Up | Ctrl-Option-Shift-Up | Move multicursor from current line to the line above | 多個光標(biāo)時將當(dāng)前的光標(biāo)向上移動一行 |
| Ctrl-Alt-Shift-Down | Ctrl-Option-Shift-Down | Move multicursor from current line to the line below | 多個光標(biāo)時將當(dāng)前的光標(biāo)向下移動一行 |
| Ctrl-Alt-Shift-Right | Ctrl-Option-Shift-Right | Remove current occurrence from multi-selection and move to next | 多個光標(biāo)時將當(dāng)前的光標(biāo)移動到下一個發(fā)生的位置 |
| Ctrl-Alt-Shift-Left | Ctrl-Option-Shift-Left | Remove current occurrence from multi-selection and move to previous | 多個光標(biāo)時將當(dāng)前的光標(biāo)移動到上一個發(fā)生的位置 |
| Ctrl-Shift-L | Ctrl-Shift-L | Select all from multi-selection | 選擇光標(biāo)所有地方 |
3.4 跳轉(zhuǎn)
| Windows/Linux | Mac | Action | 描述 |
|---|---|---|---|
| Left | Left, Ctrl-B | Go to left | 向左跳轉(zhuǎn) |
| Right | Right, Ctrl-F | Go to right | 向右跳轉(zhuǎn) |
| Ctrl-Left | Option-Left | Go to word left | 跳轉(zhuǎn)到左邊單詞 |
| Ctrl-Right | Option-Right | Go to word right | 跳轉(zhuǎn)到右邊單詞 |
| Up | Up, Ctrl-P | Go line up | 跳轉(zhuǎn)到上一行 |
| Down | Down, Ctrl-N | Go line down | 跳轉(zhuǎn)到下一行 |
| Alt-Left, Home | Command-Left, Home, Ctrl-A | Go to line start | 跳轉(zhuǎn)到行首 |
| Alt-Right, End | Command-Right, End, Ctrl-E | Go to line end | 跳轉(zhuǎn)到行尾 |
| PageUp | Option-PageUp | Go to page up | 跳轉(zhuǎn)到上一頁 |
| PageDown | Option-PageDown, Ctrl-V | Go to page down | 跳轉(zhuǎn)到下一頁 |
| Ctrl-Home | Command-Home, Command-Up | Go to start | 跳轉(zhuǎn)到開始 |
| Ctrl-End | Command-End, Command-Down | Go to end | 跳轉(zhuǎn)到結(jié)尾 |
| Ctrl-L, Ctrl-J | Command-L, Command-J | Go to line | 跳轉(zhuǎn)到固定行 |
| Ctrl-Down | Command-Down | Scroll line down | 滾動軸向下移動 |
| Ctrl-Up | --- | Scroll line up | 滾動軸向上移動 |
| Ctrl-P | --- | Go to matching bracket | |
| --- | Option-PageDown | Scroll page down | 滾動軸向下移動一頁 |
| --- | Option-PageUp | Scroll page up | 滾動軸向上移動一頁 |
3.5 查找替換
| Windows/Linux | Mac | Action | 描述 |
|---|---|---|---|
| Ctrl-F | Command-F | Find | 查找 |
| Ctrl-H | Command-Option-F | Replace | 替換 |
| Ctrl-K | Command-G | Find next | 查找下一個 |
| Ctrl-Shift-K | Command-Shift-G | Find previous | 查找上一個 |
3.6 隱藏和展開
| Windows/Linux | Mac | Action | 描述 |
|---|---|---|---|
| Alt-L, Ctrl-F1 | Command-Option-L, Command-F1 | Fold selection | 隱藏已經(jīng)選擇的行 |
| Alt-Shift-L, Ctrl-Shift-F1 | Command-Option-Shift-L, Command-Shift-F1 | Unfold | 展開 |
| Alt-0 | Command-Option-0 | Fold all | 隱藏所有 |
| Alt-Shift-0 | Command-Option-Shift-0 | Unfold all | 展開所有 |
3.7 其他
| Windows/Linux | Mac | Action | 描述 |
|---|---|---|---|
| Ctrl-Space | Ctrl-Space | Autocomplete when Live Autocompletion is off | |
| Ctrl-i|Ctrl-Shift-f | Command-i|Command-Shift-f | Format selection or all | 格式化 |
| Tab | Tab | Indent | 縮進 |
| Shift-Tab | Shift-Tab | Outdent | 刪除縮進 |
| Ctrl-Z | Command-Z | Undo | 撤銷 |
| Ctrl-Shift-Z, Ctrl-Y | Command-Shift-Z, Command-Y | Redo | 恢復(fù) |
| Ctrl-/ | Command-/ | Toggle comment | 注釋 |
| Ctrl-T | Ctrl-T | Transpose letters | |
| Ctrl-Shift-U | Ctrl-Shift-U | Change to lower case | 小寫 |
| Ctrl-U | Ctrl-U | Change to upper case | 大寫 |
| Insert | Insert | Overwrite | 覆蓋 |
| Ctrl-Shift-E | Command-Shift-E | Macros replay | |
| Ctrl-Alt-E | --- | Macros recording | |
| Delete | --- | Delete | |
| --- | Ctrl-L | Center selection | 游標(biāo)居中 |
3.8 設(shè)置
| Windows/Linux | Mac | Action | 描述 |
|---|---|---|---|
| Ctrl - , | Command - , | Show the settings menu | 設(shè)置 |


