解决Impala中创建表以后,查询时却提示表不存在的问题

查询时提示表不存在,而尝试创建表却提示表存在。使用HDFS中的文件导入为表也出现同样的问题,在Hue界面刷新Impala中的表可以看到表,但查询时依然提示表不存在。

[shell]
[example.com:21000] > select * from tab1;
Query: select * from tab1
ERROR: AnalysisException: Table does not exist: default.tab1
[/shell]

[shell]
[example.com:21000] > CREATE EXTERNAL TABLE tab1
> (
> id INT,
> col_1 BOOLEAN,
> col_2 DOUBLE,
> col_3 TIMESTAMP
> )
> ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’
> LOCATION ‘/user/dwheeler/sample_data/tab1’;
Query: create EXTERNAL TABLE tab1
(
id INT,
col_1 BOOLEAN,
col_2 DOUBLE,
col_3 TIMESTAMP
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’
LOCATION ‘/user/theory/sample_data/tab1’
ERROR: AlreadyExistsException: Table tab1 already exists
[/shell]

原因如下:
In Impala 1.1 and earlier you need to issue an explicit “invalidate metadata” command to make tables created on other nodes visible to the local Impala daemon.
Starting with Impala 1.2 this won’t be necessary; the new catalog service will take care of metadata distribution to all impalad’s in the cluster.

解决办法如下,在Impala中执行一下同步任务:
[shell]
invalidate metadata
[/shell]

via:http://stackoverflow.com/questions/19647467/why-dont-impala-table-definitions-replicate