简单的配置单元选择无法给出完整的结果

问题描述

我正在查询一个表,我们称其为“ customer_table”,该表每天都有“ yyyymmdd”格式的分区。 用'show partitions customer_table'查看分区时,可以看到昨天和前一天的数据。 但是,当我运行类似:

查询
'select customer,customer_joined_date,name,address,city
from customer_table ct
left join addresses addr on ct.cust_id=addr.cust_id
where ct.customer_joined_date >= date_format(date_sub(current_date,7),'yyyyMMdd')

查询包括昨天或前一天的数据。 我的直觉是前两天分区具有某种锁,可以防止在数据仍在流进其中时进行查询

您能建议发生什么事吗?是否可以设置环境参数,以便查询忽略“锁”?

解决方法

您能否在下面进行查询只是为了检查联接中没有时髦的东西?

  select max(customer_joined_date)
  from customer_table ct
  Where ct.customer_joined_date >= date_format(date_sub(current_date,7),'yyyyMMdd');

如果仍然看不到最新分区中的数据,则可以尝试对最新分区进行一次收集统计,看看是否有机会。以下是语法示例。

 ANALYZE TABLE Table1 PARTITION(ds='2008-04-09') COMPUTE STATISTICS;