Skip to content

Conversation

@RaphDal
Copy link
Contributor

@RaphDal RaphDal commented Oct 22, 2025

This PR adds decimal support.

This is a tandem pr for:

Usage

Textual representation

import { Sender } from "@questdb/nodejs-client";

async function runDecimals() {
  const sender = await Sender.fromConfig(
    "tcp::addr=127.0.0.1:9009;protocol_version=3",
  );

  await sender
    .table("fx")
    // textual ILP form keeps the literal and its exact scale
    .decimalColumnText("mid", "1.234500")
    .atNow();

  await sender.flush();
  await sender.close();
}

runDecimals().catch(console.error);
// Resulting ILP line: fx mid=1.234500d

Binary representation

It is recommended to use the binary representation for better ingestion performance and reduced payload size (for bigger decimals).

import { Sender } from "@questdb/nodejs-client";

async function runDecimals() {
  const sender = await Sender.fromConfig(
    "tcp::addr=127.0.0.1:9009;protocol_version=3",
  );

  await sender
    .table("fx")
    // textual ILP form keeps the literal and its exact scale
    .decimalColumnUnscaled("mid", 123456n, 3) // 123456 * 10^-3 = 123.456
    .atNow();

  await sender.flush();
  await sender.close();
}

runDecimals().catch(console.error);

Progress

  • support binary and text formats
  • release decimal on QuestDB OSS

@RaphDal
Copy link
Contributor Author

RaphDal commented Oct 24, 2025

@CodeRabbit review

@glasstiger
Copy link
Collaborator

questdb-client-test submodule should be updated to the latest

@glasstiger glasstiger changed the title feat: support decimal feat: support for decimal type Nov 12, 2025
@glasstiger glasstiger changed the title feat: support for decimal type feat: support for DECIMAL type Nov 12, 2025
@glasstiger glasstiger changed the title feat: support for DECIMAL type feat: support for DECIMAL type Nov 12, 2025
@glasstiger
Copy link
Collaborator

this one is a server side issue, so just a note that error message is a bit cryptic when using higher scale than the type allows.
for example, if server has the type DECIMAL(18, 3) then decimalColumnUnscaled('data3', BigInt(147), 4) returns this error:

error in line 1: table: prices, column: data3; line protocol value: 0.010 is out bounds of column type: DECIMAL(18,3)"

no mentions of incorrect scale.

@RaphDal
Copy link
Contributor Author

RaphDal commented Nov 12, 2025

questdb-client-test submodule should be updated to the latest

Fixed in 0445cdb

this one is a server side issue, so just a note that error message is a bit cryptic when using higher scale than the type allows. for example, if server has the type DECIMAL(18, 3) then decimalColumnUnscaled('data3', BigInt(147), 4) returns this error:

error in line 1: table: prices, column: data3; line protocol value: 0.010 is out bounds of column type: DECIMAL(18,3)"

no mentions of incorrect scale.

Good point, questdb/questdb#6387 should fix this

@glasstiger glasstiger merged commit 91e9f0b into main Nov 12, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants