Giter VIP home page Giter VIP logo

Comments (2)

alexey-milovidov avatar alexey-milovidov commented on June 23, 2024
Screenshot_20240524_030704

In ClickHouse, when using JSON* family formats, numbers larger than Int32 are represented as strings, as Int64+ types maximum values are larger than Number.MAX_SAFE_INTEGER. This is to avoid integer overflow as max values for these types are bigger than Number.MAX_SAFE_INTEGER. However, this behavior can be modified with output_format_json_quote_64bit_integers setting.

Here is an example of how to adjust the JSON output format for 64-bit numbers:

const resultSet = await client.query({  
 query: 'SELECT * from system.numbers LIMIT 1',  
 format: 'JSONEachRow',  
})  
  
expect(await resultSet.json()).toEqual([ { number: '0' } ])  

const resultSet = await client.query({  
 query: 'SELECT * from system.numbers LIMIT 1',  
 format: 'JSONEachRow',  
 clickhouse_settings: { output_format_json_quote_64bit_integers: 0 },  
})  
  
expect(await resultSet.json()).toEqual([ { number: 0 } ])  

In the first query, the number is returned as a string, while in the second query, with the output_format_json_quote_64bit_integers setting set to 0, the number is returned as a number.

However, it's important to note that there are some known limitations when using ClickHouse with Node.js/Web. For instance, when using JSON* family formats, numbers larger than Int32 are represented as strings, as Int64+ types maximum values are larger than Number.MAX_SAFE_INTEGER.

For more details, you can refer to the following documentation:

from clickhouse.

tylerlaws0n avatar tylerlaws0n commented on June 23, 2024

Thanks for the thorough explanation! Apologies for missing this in the docs as well.

from clickhouse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.