Vertica 与 PostgreSQL 不同的计算

Vertica different calculations than in PostgreSQL

我有一个疑问:

SELECT CAST(((stats.ts_spawn - 1427835600) / 86400) * 86400 + 
1427835600 AS INTEGER) AS anon_1 FROM stats WHERE stats.ts_spawn > 
1427835600 AND stats.ts_spawn < 1428440399 GROUP BY anon_1 order by anon_1;

我希望在一周内开始每一天。

Postgresql 中的结果:

1427835600
1427922000
1428008400
1428094800
1428181200
1428267600
1428354000

Vertica returns 一周中每一天的每个小时的开始:

1427839200
1427842800
1427846400
1427850000
... and so on, total 167 records(24 * 7 - 1)

我不知道如何修改这个查询。

第二个显然导致除法中的浮点数不是整数。在 Vertica documents 中我们可以读到:

the Vertica 6 release introduced a behavior change when dividing integers using the / operator

如果您希望查询在两个系统上的行为相同,请更改该文档中提到的配置选项,或者对除法结果使用 Floor() 函数。