Creating hive table with characters in the name

2019-07-23 13:45发布

问题:

I am trying to create a table in hive with the following name "$example$table". It is not allowing me to create and is giving the following error:

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org.apache.hadoop.hive.ql.metadata.HiveException: [$ndo$dbproperty]: is not a valid table name

Could anyone please help me out here? The requirement is to create tables name with characters like $,%,',' in the table name.

回答1:

Currently, special characters are supported only for columns, not tables.
https://issues.apache.org/jira/browse/HIVE-6013
https://issues.apache.org/jira/browse/HIVE-11699

P.s. 1
If you are brave enough you can rename the table within the metastore.

select * from metastore.TBLS where TBL_NAME = '$example$table';

+--------+-------------+-------+------------------+----------+-----------+-------+----------------+---------------+--------------------+--------------------+
| TBL_ID | CREATE_TIME | DB_ID | LAST_ACCESS_TIME |  OWNER   | RETENTION | SD_ID |    TBL_NAME    |   TBL_TYPE    | VIEW_EXPANDED_TEXT | VIEW_ORIGINAL_TEXT |
+--------+-------------+-------+------------------+----------+-----------+-------+----------------+---------------+--------------------+--------------------+
|    176 |  1494511100 |     2 |                0 | cloudera |         0 |   181 | $example$table | MANAGED_TABLE | (null)             | (null)             |
+--------+-------------+-------+------------------+----------+-----------+-------+----------------+---------------+--------------------+--------------------+

hive> select * from `$example$table`;
OK
1
2
3
Time taken: 0.58 seconds, Fetched: 3 row(s)
hive> 

P.s. 2
You might want to watch "Yes (prime) minister" for a better understanding of the term brave



标签: hive ddl