我一直在努力解决Hive SQL中的问题,并且发现了问题所在:
select distinct 'A', NULL;
Run Code Online (Sandbox Code Playgroud)
返回'A',NULL
select count(distinct 'A', NULL);
Run Code Online (Sandbox Code Playgroud)
返回0
select count(distinct 'A', coalesce(NULL,''));
Run Code Online (Sandbox Code Playgroud)
返回1.
我正在使用较大查询中的选择行并对结果进行过滤(= 1).结果为0,我丢失了很多行.
为什么带有NULL列的行不会对计数(不同)查询的结果产生影响?
在我的代码中,我实现了一个循环,其中下限和上限是可变的,并且可能发生下限和上限相同.在这种情况下,Python会跳过循环.
for i in range(low_, high_):
print(i)
Run Code Online (Sandbox Code Playgroud)
有没有办法在循环的定义中解决这个问题?