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?

有帮助吗?

解决方案

@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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top