hiveql

Dynamic partitioning in Hive through the exact inserted timestamp

大兔子大兔子 提交于 2021-02-04 21:05:39
问题 I need to insert data to a given external table which should be partitioned by the inserted date. My question is how is Hive handling the timestamp generation? When I select a timestamp for all inserted records like this: WITH delta_insert AS ( SELECT trg.*, from_unixtime(unix_timestamp()) AS generic_timestamp FROM target_table trg ) SELECT * FROM delta_insert; Will the timestamp always be identical for all records, even if the query takes a lot of time to un? Or should I alternatively only

Dynamic partitioning in Hive through the exact inserted timestamp

╄→尐↘猪︶ㄣ 提交于 2021-02-04 21:05:33
问题 I need to insert data to a given external table which should be partitioned by the inserted date. My question is how is Hive handling the timestamp generation? When I select a timestamp for all inserted records like this: WITH delta_insert AS ( SELECT trg.*, from_unixtime(unix_timestamp()) AS generic_timestamp FROM target_table trg ) SELECT * FROM delta_insert; Will the timestamp always be identical for all records, even if the query takes a lot of time to un? Or should I alternatively only

Left Outer Join with subqueries IN/EXIST at Hive

一个人想着一个人 提交于 2021-01-29 15:08:56
问题 All, so I am trying to run the query. The query consist of 7 tables and I want to all table get left joined based on A.conn_keyy and the others with clause 'ON' My confusion comes when I want to join CPLCUR based on A , not works. (CPLCUR.conn_keyy in ( a.conn_keyy = b.conn_keyy ) It appears error : both left and right aliases encountered in join 'conn_key' set hive.support.quoted.identifiers=none; select coalesce(a.conn_keyy, b.conn_keyy,CPLCUR.conn_keyy) as rrconn_keyy, b.rfbbn, b.LINES_ID

why boolean field is not working in Hive?

不想你离开。 提交于 2021-01-29 02:21:19
问题 I have a column in my hive table which datatype is boolean. when I tried to import data from csv, it stored as NULL. This is my sample table : CREATE tABLE if not exists Engineanalysis( EngineModel String, EnginePartNo String , Location String, Position String, InspectionReq boolean) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; My sample data : AB01,AS01-IT01,AIRFRAME,,0 AB02,AS01-IT02,AIRFRAME,,1 AB03,AS01-IT03,AIRFRAME,,1 AB04,AS01-IT04,AIRFRAME,,1 AB05,AS01-IT05

why boolean field is not working in Hive?

亡梦爱人 提交于 2021-01-29 02:14:05
问题 I have a column in my hive table which datatype is boolean. when I tried to import data from csv, it stored as NULL. This is my sample table : CREATE tABLE if not exists Engineanalysis( EngineModel String, EnginePartNo String , Location String, Position String, InspectionReq boolean) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; My sample data : AB01,AS01-IT01,AIRFRAME,,0 AB02,AS01-IT02,AIRFRAME,,1 AB03,AS01-IT03,AIRFRAME,,1 AB04,AS01-IT04,AIRFRAME,,1 AB05,AS01-IT05

How to declare and use variable in Hive SQL?

瘦欲@ 提交于 2021-01-28 19:55:29
问题 I am using below syntax to declare and use variable in hive sql query. But it gives me an error as below SET aa='10'; SELECT col1 as data, ${aa} as myVar from myTable; ERROR: org.apache.hive.service.cli.HiveSQLException: Error while processing statement: Cannot modify aa at runtime. It is not in list of params that are allowed to be modified at runtime I have also tried using hiveconf SELECT ${hiveconf:aa} from myTable; 回答1: You can not pass variable like that. You need to use --hivevar . You

Merging multiple arrays into a map

谁说我不能喝 提交于 2021-01-28 14:08:30
问题 I have some data (sample from full table) that looks like this: | prov_id | hotel_id | m_id | apis_xml | company_id | yyyy_mm_dd | |---------|----------|------|----------|------------|------------| | 945 | 78888 | 3910 | [5] | 998 | 2020-05-20 | | 1475 | 78888 | 6676 | [1,2,4] | 37 | 2020-05-20 | | 1475 | 78888 | 6670 | [1,2,4] | 37 | 2020-05-20 | | 945 | 78888 | 2617 | [5] | 998 | 2020-05-20 | I want to find the lowest apis_xml value per hotel and have the associated prov_id set as the

In Hive, how to read through NULL / empty tags present within an XML using explode(XPATH(..)) function?

杀马特。学长 韩版系。学妹 提交于 2021-01-28 11:51:40
问题 In below Hive-query, I need to read the null / empty "string" tags as well, from the XML content. Only the non-null "string" tags are getting considered within the XPATH() list now. with your_data as ( select '<ParentArray> <ParentFieldArray> <Name>ABCD</Name> <Value> <string>111</string> <string></string> <string>222</string> </Value> </ParentFieldArray> <ParentFieldArray> <Name>EFGH</Name> <Value> <string/> <string>444</string> <string></string> <string>555</string> </Value> <

Issue in Hive Query due to memory

主宰稳场 提交于 2021-01-28 07:01:38
问题 We have insert query in which we are trying to insert data to partitioned table by reading data from non partitioned table. Query - insert into db1.fact_table PARTITION(part_col1, part_col2) ( col1, col2, col3, col4, col5, col6, . . . . . . . col32 LOAD_DT, part_col1, Part_col2 ) select col1, col2, col3, col4, col5, col6, . . . . . . . col32, part_col1, Part_col2 from db1.main_table WHERE col1=0; Table has 34 columns, number of records in main table depends on size of input file which we

Using like operator to check for pattern in hive

↘锁芯ラ 提交于 2021-01-22 10:15:06
问题 I need to retrieve the columns from a hive table that must begin with uppercase letter and end with digit. I used this query select * from tab1 where col1 like '[A-Z]%[0-9]'; But not able to retrieve the records ,getting only empty result. 回答1: rlike / regexp select * from tab1 where col1 rlike '^[A-Z].*[0-9]$'; 来源: https://stackoverflow.com/questions/42809183/using-like-operator-to-check-for-pattern-in-hive