1
votes

I am trying create a table named errtable from another table errcode with an extra column. The errcode table has the following schema :

id STRING,
msg STRING

The errtable has an extra column which is app_name

appname STRING,
id STRING,
msg STRING

The query I am trying to run is the following :

INSRT overwrite table ERRTABLE
SELECT ${APPLICATION_NAME} as appname, err.id, err.msg
FROM (
  SELECT * from ERRCODE
)ERR;

APPLICATION_NAME is a constant variable is being passed to my hive script with -d option (-d APPLICATION_NAME=myapp). I am getting the following error message : FAILED: SemanticException [Error 10004]: Line 4:7 Invalid table alias or column reference 'myapp': (possible column names are: id, msg). Can anyone please help me figure out what I am doing wrong?

1

1 Answers

2
votes

@Santanu: Try this it should work

INSERT overwrite table ERRTABLE  
SELECT '${APPLICATION_NAME}' as appname, err.id as id, err.msg as msg FROM ERRCODE err;