Hiveql - How to Find The Column Value Is Numeric or Not Using Any Udf

HiveQL - How to find the column value is numeric or not using any UDF?

I believe Hive supports rlike (regular expressions). So, you can do:

where col rlike '[^0-9]'

This looks for any non-digit character. You can expand this, if your numeric values might have decimal points or commas.

How to use a UDF value or column value in hive insert partition statement, rather than constant value

This can be achieved by setting hive.exec.dynamic.partition.mode=nonstrict; and giving partition value as part-of the select statement.

Note the last column in select clause is date_of_data and by specifying partition(date_of_data) this columns is used as partition value.

warning if there is multiple values in the partition the records will be sent to corresponding partition. Use with caution.

set hive.exec.dynamic.partition.mode=nonstrict;
INSERT INTO TABLE DailyData partition(date_of_data)
SELECT id as entity_id, simpledata as payload, from_unixtime(unix_timestamp(),'yyyyMMdd') as date_of_data from log_data;

Reference: https://cwiki.apache.org/confluence/display/hive/languagemanual+dml#LanguageManualDML-DynamicPartitionInserts

How to assign value in query which running a Hive query

In Hive you do need to the "concat(day(datetimeVal), ': ', hour(datetimeVal)" twice unless you made a secondary table such that

Select day_hour from(Select concat(day(datetimeVal),':',hour(datetimeVal) as day_hour, 
* from table) GROUP BY day_hour;

Otherwise Hive will get confused and not even run unfortunately.

Hive: Convert String to Integer

cast(str_column as int)

From: Language manual UDFs - type conversion functions



Related Topics



Leave a reply



Submit