Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

HIve Error: parser exception cannot recognize input

avatar
Contributor
select cast(10000 as int),
           case data_type
            when 'TIMESTAMP' then
    		  concat('     ,cast((cast(sys_extract_utc(update_time) AS DATE) - TO_DATE('01-01-1970 00:00:00', 'DD-MM-YYYY HH24:MI:SS')) * 86400 AS INT) last_date_time_ts')
            else
              concat('     ,#unknown data_type : ', data_type)
           end
      from (select row_number() over() ln, table_name, column_name, data_type, column_id 
              from test.all_tab_columns
             where date_key in (select max(date_key) from test.all_tab_columns)
               and table_name = 'test_table'
                      ) data
Tried to extract the the last updated time using below query.  hive is throwing exception

Error: Error while compiling statement: FAILED: ParseException line 4:7 cannot recognize input near ''cast((cast(sys_extract_utc(update_time) AS DATE) - TO_DATE('' '01' '-' in expression specification (state=42000,code=40000)

1 ACCEPTED SOLUTION

avatar
@Adithya Sajjanam

sys_extract_utc is not a valid Hive function. You are translating your Oracle query as is and that's why getting this error. You can refer to the Hive documentation for reference to Date functions in hive and translate your query from Oracle syntax to Hive QL accordingly.

View solution in original post

1 REPLY 1

avatar
@Adithya Sajjanam

sys_extract_utc is not a valid Hive function. You are translating your Oracle query as is and that's why getting this error. You can refer to the Hive documentation for reference to Date functions in hive and translate your query from Oracle syntax to Hive QL accordingly.