typedb / typedb-driver

TypeDB Drivers for Rust, Python, Java, Node.js, C, C++, and C#.
https://typedb.com
Apache License 2.0
38 stars 33 forks source link

Error thrown if aggregate subquery returns NaN #606

Closed james-whiteside closed 7 months ago

james-whiteside commented 8 months ago

Description

If an aggregate subquery in a Fetch query returns a NaN, then CXN07 is thrown. For example, in the following query, none of the books in the order have a price that high. The standard deviation of zero elements is undefined and resolves to NaN.

match
$order isa order, has id "o0015";
fetch
std-price: {
    match
    $book isa book, has price $price;
    $price > 100000000000000;
    ($order, $book) isa order-line;
    get; std $price;
};

However, instead of returning JSON containing a NaN, an error is thrown.

[CXN07] Missing field in message received from server: 'readable_concept'.

Environment

  1. TypeDB distribution: Core
  2. TypeDB version: 2.25.7
  3. Environment: MacOS
  4. Studio version: 2.25.0
dmitrii-ubskii commented 7 months ago

This appears to have been fixed in #549, which was released in 2.26.3. Can you please double check with a more recent version of Studio?

james-whiteside commented 7 months ago

Confirmed working on 2.26.6. Apologies for inconvenience. I think it's a bit weird that we get null when part of a subquery and NaN otherwise but that's a seperate and minor issue. Closing.

dmitrii-ubskii commented 7 months ago

we get null when part of a subquery and NaN otherwise

JSON floats cannot be NaNs and are replaced with nulls instead.