十四、getjson、split、substring等函數使用

1、substring

hive (default)> select substring('abcde',1);
OK
_c0
abcde
Time taken: 1.661 seconds, Fetched: 1 row(s)

hive (default)> select substring('abcde',1,5);
OK
_c0
abcde
Time taken: 0.101 seconds, Fetched: 1 row(s)

hive (default)> select substring('abcde',1,3);
OK
_c0
abc

2、split函數

hive (default)> select split("a,b,c",',')[0],split("a,b,c",',')[2];
OK
_c0     _c1
a       c

3、get_json_object函數

hive (default)> select get_json_object('{"name":"zhangsan"}','$.name');
zhangsan

hive (default)> select get_json_object('{"name":"zhangsan","py":["xm","xh","xq"]}','$.py[1]');
xh

hive (default)> select get_json_object('{"name":"zhangsan","py":["xm","xh","xq"],"scores":[{"yw":"98"},{"yy":"89"}]}','$.scores[1].yy');
89

4、查看hive中所有函數

hive (default)> show functions;
OK
tab_name
!
!=
%
&
*
+
-
/
<
<=
<=>
<>
=
==
>
>=
^
abs
acos
add_months
and
array
array_contains
ascii
asin
assert_true
atan
avg
base64
between
bin
case
cbrt
ceil
ceiling
coalesce
collect_list
collect_set
compute_stats
concat
concat_ws
context_ngrams
conv
corr
cos
count
covar_pop
covar_samp
create_union
cume_dist
current_database
current_date
current_timestamp
current_user
date_add
date_format
date_sub
datediff
day
dayofmonth
decode
degrees
dense_rank
div
e
elt
encode
ewah_bitmap
ewah_bitmap_and
ewah_bitmap_empty
ewah_bitmap_or
exp
explode
factorial
field
find_in_set
first_value
floor
format_number
from_unixtime
from_utc_timestamp
get_json_object
greatest
hash
hex
histogram_numeric
hour
if
in
in_file
index
initcap
inline
instr
isnotnull
isnull
java_method
json_tuple
lag
last_day
last_value
lcase
lead
least
length
levenshtein
like
ln
locate
log
log10
log2
lower
lpad
ltrim
map
map_keys
map_values
matchpath
max
min
minute
month
months_between
named_struct
negative
next_day
ngrams
noop
noopstreaming
noopwithmap
noopwithmapstreaming
not
ntile
nvl
or
parse_url
parse_url_tuple
percent_rank
percentile
percentile_approx
pi
pmod
posexplode
positive
pow
power
printf
radians
rand
rank
reflect
reflect2
regexp
regexp_extract
regexp_replace
repeat
reverse
rlike
round
row_number
rpad
rtrim
second
sentences
shiftleft
shiftright
shiftrightunsigned
sign
sin
size
sort_array
soundex
space
split
sqrt
stack
std
stddev
stddev_pop
stddev_samp
str_to_map
struct
substr
substring
sum
tan
to_date
to_unix_timestamp
to_utc_timestamp
translate
trim
trunc
ucase
unbase64
unhex
unix_timestamp
upper
var_pop
var_samp
variance
weekofyear
when
windowingtablefunction
xpath
xpath_boolean
xpath_double
xpath_float
xpath_int
xpath_long
xpath_number
xpath_short
xpath_string
year
|
~
Time taken: 0.048 seconds, Fetched: 216 row(s)
hive (default)> 

5、查看hive中函數使用說明 show functions xxx

hive (default)> show functions upper;
SHOW FUNCTIONS is deprecated, please use SHOW FUNCTIONS LIKE instead.
OK
tab_name
upper
Time taken: 0.358 seconds, Fetched: 1 row(s)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章