Skip to content

Minus zero values #16

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

Open
minouminou opened this issue Apr 20, 2022 · 2 comments
Open

Minus zero values #16

minouminou opened this issue Apr 20, 2022 · 2 comments
Labels
area/queryprocessor Query processor issues and requests external

Comments

@minouminou
Copy link

Signed zero values should be additionally checked:

  1. Minus zero values are not supported for float datatype
create table t1_1 (id Uint64, a Float, primary key(id));
insert into t1_2(id,a) values (1,-0.0);
Status: GENERIC_ERROR
Issues: 
<main>: Error: Type annotation, code: 1030
    <main>:1:13: Error: At function: KiWriteTable!
        <main>:1:21: Error: Failed to convert type: Struct<'a':Double,'id':Int32> to Struct<'a':Float?,'id':Uint64?>
        <main>:1:21: Error: Failed to convert input columns types to scheme types, code: 2031

create table t1(id Uint64, a Double, primary key(id));
insert into t1(id,a) values (1,0),(2,-0.0);
select * from t1;
┌────┬────┐
| a  | id |
├────┼────┤
| 0  | 1  |
├────┼────┤
| -0 | 2  |
└────┴────┘
  1. Division by zero returns error when using YDB CLI, +inf/-inf values are not supported
select 1/-0.0;
library/cpp/json/writer/json.cpp:259: JSON writer: invalid float value: -inf

select 1/0.0;
library/cpp/json/writer/json.cpp:259: JSON writer: invalid float value: inf

select 1/0;
┌─────────┐
| column0 |
├─────────┤
| null    |
└─────────┘
  1. Result of min/max functions might be inconsistent (should be +0)
create table t1(id Uint64, a Double, primary key(id));
insert into t1(id,a) values (1,0),(2,-0.0);
select min(a) from t1;
┌─────────┐
| column0 |
├─────────┤
| -0      |
└─────────┘

select max(a) from t1;
┌─────────┐
| column0 |
├─────────┤
| -0      |
└─────────┘

select min_of(0.0,-0.0);'
┌─────────┐
| column0 |
├─────────┤
| 0       |
└─────────┘

select max_of(0.0,-0.0);'
┌─────────┐
| column0 |
├─────────┤
| 0       |
└─────────┘
@spuchin
Copy link
Collaborator

spuchin commented Apr 20, 2022

  1. Minus zero values are not supported for float datatype

There is no implicit cast from double to float, even for literals. You have to use explicit cast or literal type suffix:

insert into t1_1(id,a) values (1,-0.0f);

@spuchin
Copy link
Collaborator

spuchin commented Apr 21, 2022

Result of min/max functions might be inconsistent (should be +0)

According to IEEE 754 +/-0 are equal, no specific order is guaranteed in aggregation functions.

@fomichev3000 fomichev3000 added the area/queryprocessor Query processor issues and requests label May 18, 2022
Sazonov99 added a commit to Sazonov99/ydb that referenced this issue May 5, 2025
/place/sandbox-data/tasks/8/8/3053489088/__FUSE/mount_path_85659d51-ce9b-4cfe-bbaa-40809fb5ff23/contrib/ydb/core/util/cpuinfo.cpp:108:32: runtime error: -nan is outside the range of representable values of type 'unsigned int'
    #0 0x35c666d6 in NKikimr::TSystemThreadsMonitor::GetThreadPools(TInstant) /-S/contrib/ydb/core/util/cpuinfo.cpp:108:32
    ydb-platform#1 0x35c0d648 in NKikimr::NNodeWhiteboard::TNodeWhiteboardService::Handle(TAutoPtr<NActors::TEventHandle<NKikimr::NNodeWhiteboard::TNodeWhiteboardService::TEvPrivate::TEvUpdateRuntimeStats>, TDelete>&, NActors::TActorContext const&) /-S/contrib/ydb/core/tablet/node_whiteboard.cpp:1152:43
    ydb-platform#2 0x35bfa08c in NKikimr::NNodeWhiteboard::TNodeWhiteboardService::StateFunc(TAutoPtr<NActors::IEventHandle, TDelete>&) /-S/contrib/ydb/core/tablet/node_whiteboard.cpp:526:5
    ydb-platform#3 0x16ebbd43 in NActors::IActor::Receive(TAutoPtr<NActors::IEventHandle, TDelete>&) /-S/contrib/ydb/library/actors/core/actor.cpp:280:13
    ydb-platform#4 0x331e74cb in NActors::TTestActorRuntimeBase::SendInternal(TAutoPtr<NActors::IEventHandle, TDelete>, unsigned int, bool) /-S/contrib/ydb/library/actors/testlib/test_runtime.cpp:1702:33
    ydb-platform#5 0x331dfe6a in NActors::TTestActorRuntimeBase::DispatchEventsInternal(NActors::TDispatchOptions const&, TInstant) /-S/contrib/ydb/library/actors/testlib/test_runtime.cpp:1295:45
    ydb-platform#6 0x331dd77e in NActors::TTestActorRuntimeBase::DispatchEvents(NActors::TDispatchOptions const&, TInstant) /-S/contrib/ydb/library/actors/testlib/test_runtime.cpp:1091:16
    ydb-platform#7 0x1203075c in NCloud::NStorage::(anonymous namespace)::BootHiveMock(NActors::TTestActorRuntime&, unsigned long, TIntrusivePtr<NCloud::NStorage::(anonymous namespace)::THiveMockState, TDefaultIntrusivePtrOps<NCloud::NStorage::(anonymous namespace)::THiveMockState>>, NCloud::NStorage::(anonymous namespace)::EExternalBootOptions) /-S/cloud/storage/core/libs/hive_proxy/hive_proxy_ut.cpp:415:17
    ydb-platform#8 0x11fe3d57 in NCloud::NStorage::(anonymous namespace)::TTestEnv::TTestEnv(NActors::TTestActorRuntime&, TBasicString<char, std::__y1::char_traits<char>>, bool, bool, bool) /-S/cloud/storage/core/libs/hive_proxy/hive_proxy_ut.cpp:447:9
    ydb-platform#9 0x11fef7e7 in NCloud::NStorage::NTestSuiteTHiveProxyTest::TTestCaseLockReconnected::Execute_(NUnitTest::TTestContext&) /-S/cloud/storage/core/libs/hive_proxy/hive_proxy_ut.cpp:909:18
    ydb-platform#10 0x1202d38f in NCloud::NStorage::NTestSuiteTHiveProxyTest::TCurrentTest::Execute()::'lambda'()::operator()() const /-S/cloud/storage/core/libs/hive_proxy/hive_proxy_ut.cpp:802:1
    ydb-platform#11 0x12545679 in NUnitTest::TTestBase::Run(std::__y1::function<void ()>, TBasicString<char, std::__y1::char_traits<char>> const&, char const*, bool) /-S/library/cpp/testing/unittest/registar.cpp:373:18
    ydb-platform#12 0x1202b74f in NCloud::NStorage::NTestSuiteTHiveProxyTest::TCurrentTest::Execute() /-S/cloud/storage/core/libs/hive_proxy/hive_proxy_ut.cpp:802:1
    ydb-platform#13 0x12547045 in NUnitTest::TTestFactory::Execute() /-S/library/cpp/testing/unittest/registar.cpp:494:19
    ydb-platform#14 0x1256700c in NUnitTest::RunMain(int, char**) /-S/library/cpp/testing/unittest/utmain.cpp:872:44
    ydb-platform#15 0x7f582a8d8082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
    ydb-platform#16 0x1001f028 in _start (/tmp/3053489088/tmpscdMvC/build_root/fxqa/007ce8/cloud/storage/core/libs/hive_proxy/ut/cloud-storage-core-libs-hive_proxy-ut+0x1001f028) (BuildId: 6ff85f4ee4c5af508adb6bac1d7e58f9d8052d10)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /place/sandbox-data/tasks/8/8/3053489088/__FUSE/mount_path_85659d51-ce9b-4cfe-bbaa-40809fb5ff23/contrib/ydb/core/util/cpuinfo.cpp:108:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/queryprocessor Query processor issues and requests external
Projects
None yet
Development

No branches or pull requests

4 participants