I am new to Hive and got an error when I tried to create a partitioned table.
here is my script:
CREATE TABLE partitionedemp(emp_no int, birth_date string, first_name string, last_name string) Partitioned By(gender string, hire_date string) stored as sequencefile;
I got an error below:
bash: syntax error near unexpected token `('
What's wrong with my script? Thank you very much.
Everything is fine , Just you have ^M characters between CREATE and TABLE keywords. To check, paste this command in vi editor and run command like this:-
$ cat -v file.txt
CREATEM-cM-^#M-^#TABLE partitionedemp(emp_no int, birth_date string, first_name string, last_name string) Partitioned By(gender string, hire_date string) stored as sequencefile;
Solution:- Straightforward one - type full create table statement on hive prompt instead of copy and paste.
Related
I'd like to use this query to create a partitioned table in Amazon Athena:
CREATE TABLE IF NOT EXISTS
testing.partitioned_test(order_id bigint, name string, car string, country string)
PARTITIONED BY (year int)
ROW FORMAT SERDE 'parquet.hive.serde.ParquetHiveSerDe'
STORED AS 'PARQUET'
LOCATION 's3://testing-imcm-into/partitions'
Unfortunately I don't get the error message which tells me the following:
line 3:2: mismatched input 'partitioned' expecting {, 'with'}
The quotes around 'PARQUET' seemed to be causing a problem.
Try this:
CREATE EXTERNAL TABLE IF NOT EXISTS
partitioned_test (order_id bigint, name string, car string, country string)
PARTITIONED BY (year int)
STORED AS PARQUET
LOCATION 's3://testing-imcm-into/partitions/'
I created a hive table on a hbase table
like that
CREATE EXTERNAL TABLE RGPD.TEST_TAB(
`HBASE_ID` STRING,
`INTEGRATION_ID` STRING,
`LAST_NAME` STRING,
`MAIDEN_NAME` STRING,
`FST_NAME` STRING,
`PER_TITLE` STRING,
`BIRTH_DT` STRING
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ('hbase.columns.mapping'=':key,all:integration_id,all:last_name,all:maiden_name,all:fst_name,all:per_title,all:birth_dt','serialization.encoding'='UTF-8')
TBLPROPERTIES ('hbase.table.name'='key:TEST_TAB');
when I make a select query in hive
I have a return like this:
10131472 FRAN�OIS
while the query in hbase returns:
01061948 FRAN\xC7OIS
I know this is a charset (utf-8) issue but I have not found the solution
Any help please !!
I was creating table in hive with
create table stores(
storeid integer,
area string,
city string,
state string,
country string)
Try using INT in place of Integer.
I have copied and pasted your ddl statement above into my hive cli and it worked perfectly.
You need to check your hive installation
INTEGER can be used from Hive version 2.2.0 onwards. For earlier versions, INT should be used.
Try using this DDL:
create table stores(
storeid int,
area string,
city string,
state string,
country string);
References: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-NumericTypes
https://issues.apache.org/jira/browse/HIVE-14950
I create a external table with a wrong(non-exists) path :
create external table IF NOT EXISTS ds_user_id_csv
(
type string,
imei string,
imsi string,
idfa string,
msisdn string,
mac string
)
PARTITIONED BY(prov string,day string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
stored as textfile
LOCATION 'hdfs://cdh0:8020/user/hive/warehouse/test.db/ds_user_id';
And I can not drop the table:
[cdh1:21000] > drop table ds_user_id_csv
> ;
Query: drop table ds_user_id_csv
ERROR:
ImpalaRuntimeException: Error making 'dropTable' RPC to Hive Metastore:
CAUSED BY: MetaException: java.lang.IllegalArgumentException: Wrong FS: hdfs://cdh0:8020/user/hive/warehouse/test.db/ds_user_id, expected: hdfs://nameservice1
So how to solve this? Thank you.
Use the following command to change the location
ALTER TABLE name ds_user_id_csv SET LOCATION '{new location}';
I am trying to create a table in hive using following query:
create table customers(Cust_ID INT, Cust_Name STRING, Dealer_ID INT, Country STRING, State STRING, City STRING, ZipCode INT)
row format delimited
fields terminated by ';'
stored as textfile;
but i'm getting the following error:
FAILED: Parse Error: line 0:-1 mismatched input '<EOF>' expecting StringLiteral in table row format's field separator
i have created previously transactions table with same syntax and it had worked out just fine..but somehow i think m making some syntatical error. plz help.
Try escaping ';' by adding '\' os your query will look as follow:
create table customers(Cust_ID INT, Cust_Name STRING, Dealer_ID INT, Country STRING, State STRING, City STRING, ZipCode INT)
row format delimited
fields terminated by '\;'
stored as textfile;
Try using the OCT \073 instead of ';'
Example:
row format delimited fields terminated by '\073'