sparkSQL元数据缓存不同步 beeline连接的表结构与hive不一致

之前遇到过的坑,通过beeline连接spark thirft server,当在Hive进行表结构修改,如replace/add/change columns后,表结构没有变化,还是旧的表结构,导致无法验证数据。

操作步骤如下:

-- 1.create table
-- hive/beeline execute
create table test_table(id int);

-- 2.check metadata in beeline
desc test_table;

-- 3. add columns for test_table
-- hive execute
alter table test_table add columns (name string);
alter table test_table replace columns (id int,name_new string);

-- 4. check metadata in hive
-- hive execute
desc test_table;

-- 5.check metadata in beeline
-- beeline execute
desc test_table;

-- 6. refresh metadata cache
-- beeline execute
refresh table test_table;

-- 7.check metadata in beeline
-- beeline execute
desc test_table;

经测试,在spark2.1中无此问题。

猜你喜欢

转载自www.cnblogs.com/chenzechao/p/8971698.html