Clickhouse:2个版本之间的行结果差异

发布于 2025-01-31 19:10:53 字数 384 浏览 2 评论 0原文

在版本中19.13.3.26 以下查询返回1行:

select   -1 as brandidTotal, toDecimal64(Sum(CostpriceSEK),2) as costprice
  from mytable
  where Stylenumber = 'a row which does not exist'  
  group by brandidTotal

但是在版本 22.2.2.1 中,它返回一个空的结果(我可以理解,因为在哪里找不到任何行)

似乎汇总函数总和改变了行为。 (如果删除了第二列,则两者都返回一个空集)

是否可以像19x一样使版本22X的处理方式?

In version 19.13.3.26 the following query returns 1 row:

select   -1 as brandidTotal, toDecimal64(Sum(CostpriceSEK),2) as costprice
  from mytable
  where Stylenumber = 'a row which does not exist'  
  group by brandidTotal

But in version 22.2.2.1 it returns an empty result (which i can understand, since where does not find any rows)

It seems like the aggregate function SUM has changed behaviour. (if second column is removed, both returns an empty set)

Is it possible to make version 22X handle it like 19x does?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倒数 2025-02-07 19:10:53
  --empty_result_for_aggregation_by_constant_keys_on_empty_set 
            Return empty result when aggregating by constant keys on empty set.


select -1 x, count() from (select 1 yyy where 0) group by x;

0 rows in set. Elapsed: 0.002 sec.


set empty_result_for_aggregation_by_constant_keys_on_empty_set=0;

select -1 x, count() from (select 1 yyy where 0) group by x;

┌──x─┬─count()─┐
│ -1 │       0 │
└────┴─────────┘

默认为所有人启用它

cat /etc/clickhouse-server/users.d/const_aggr_emp.xml
<?xml version="1.0" ?>
<yandex>
    <profiles>
        <default>
            <empty_result_for_aggregation_by_constant_keys_on_empty_set>0</empty_result_for_aggregation_by_constant_keys_on_empty_set>
        </default>
    </profiles>
</yandex>
  --empty_result_for_aggregation_by_constant_keys_on_empty_set 
            Return empty result when aggregating by constant keys on empty set.


select -1 x, count() from (select 1 yyy where 0) group by x;

0 rows in set. Elapsed: 0.002 sec.


set empty_result_for_aggregation_by_constant_keys_on_empty_set=0;

select -1 x, count() from (select 1 yyy where 0) group by x;

┌──x─┬─count()─┐
│ -1 │       0 │
└────┴─────────┘

to enable it by default for all

cat /etc/clickhouse-server/users.d/const_aggr_emp.xml
<?xml version="1.0" ?>
<yandex>
    <profiles>
        <default>
            <empty_result_for_aggregation_by_constant_keys_on_empty_set>0</empty_result_for_aggregation_by_constant_keys_on_empty_set>
        </default>
    </profiles>
</yandex>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文