sql - Getting Exception while using Timeline column as Hive Partition Field

I am trying to load data from normal table to Hive partitioned table.

Here is my normal table syntax:

create table x(name string, date1 string);

Here is my new partitioned table syntax:

create table y (name string, date1 string) partitioned by (timestamp1 string);

Here is how I am how to load data to y:

insert into table y PARTITION(SUBSTR(date1,0,2)) select name, date1 from x;

Here is my Exception:

FAILED: ParseException line 1:39 missing ) at '(' near ',' in column name
line 1:51 cannot recognize input near '0' ',' '2' in column name

1 Answer

  1. Fred- Reply

    2019-11-14

    Use dynamic partitioning:

    set hive.exec.dynamic.partition=true; 
    set hive.exec.dynamic.partition.mode=nonstrict;
    
    insert into table y PARTITION(timestamp1) 
    select name, date1, SUBSTR(date1,0,2) as timestamp1  from x;
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>