Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal部分保留位数值会丢失经度 #19

Closed
justmd5 opened this issue Sep 7, 2024 · 1 comment
Closed

Decimal部分保留位数值会丢失经度 #19

justmd5 opened this issue Sep 7, 2024 · 1 comment

Comments

@justmd5
Copy link

justmd5 commented Sep 7, 2024

Decimal(10,2),Decimal(10,5) 部分数值会丢失经度
示例代码如下:

<?php
require __DIR__ . '/api/vendor/autoload.php';


$t1 = microtime(true);
$ck = new \OneCk\Client('tcp://127.0.0.1:19000', 'clickhouse', 'passwod', 'default');


$data['server info'] = $ck->getServerInfo();
$data['drop table']  = $ck->query('DROP TABLE IF EXISTS t6');

$res = $ck->query("SELECT sipHash64(toString('1ace54')) AS result");
if($res[0]['result'] !== '9525649478782099197'){
    throw new \Exception('test uint64 fail:' . __LINE__);
}
$table                = [
    'CREATE TABLE t6 (',
    '`id` UInt32,',
    '`f1` Decimal(10,2),',
    '`f2` Decimal64(5),',
    '`f3` Decimal128(7),',
    ') ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity = 8192'
];
$data['create table'] = $ck->query(implode("\n", $table));

$data['insert data'] = $ck->insert('t6', [
    [
        'id'  => 1,
        'f1'  => 16.90,
        'f2'  => 36.48,
//        'f1'  => 8.20,
        'f3' => '170141183460469231168730371588.4105721',
        ],
]);


$data = $ck->query('select * from t6');

echo json_encode($data);

结果

[{"id":1,"f1":16.89,"f2":36.47999,"f3":"170141183460469231168730371588.4105721"}]
@justmd5
Copy link
Author

justmd5 commented Sep 7, 2024

#20 已经修复了,可以测试看看,合并进来

lizhichao added a commit that referenced this issue Sep 9, 2024
fix #19 Decimal相关类型偶发丢失精度问题修复
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant