Skip to content

Document UUID → UInt128 insert patterns with round-trip assertion#780

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-uuid-parsing-issue
Open

Document UUID → UInt128 insert patterns with round-trip assertion#780
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-uuid-parsing-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

Inserting a UUID string into a UInt128 column via JSONEachRow fails with CANNOT_PARSE_INPUT_ASSERTION_FAILED because ClickHouse only converts UUID → UInt128 implicitly for the VALUES clause. The client correctly forwards the JSON unchanged; users need guidance on the supported patterns.

Summary

Adds a new example (Node + Web) demonstrating two working approaches, with a round-trip assertion proving the server stores the value byte-for-byte.

  • examples/{node,web}/coding/insert_uuid_into_uint128.ts — two patterns:
    • Client-side conversion (recommended): BigInt('0x' + uuid.replace(/-/g, '')).toString() passed as the UInt128 column value.
    • EPHEMERAL UUID column: UInt128 DEFAULT id_uuid + UUID EPHEMERAL paired with insert({ columns: ['id_uuid', ...] }).
  • Round-trip assertion after each SELECT (node:assert/strict in Node; tiny inline assertEqual in Web, since node:assert isn't browser-compatible). Both patterns produce the same UInt128 decimal 2126302229887840375125392584261985180.
  • examples/README.md — new row in the coding/ table.
function uuidToUInt128(uuid: string): string {
  return BigInt('0x' + uuid.replace(/-/g, '')).toString()
}

await client.insert({
  table,
  values: [{ id: uuidToUInt128(uuid), description: '...' }],
  format: 'JSONEachRow',
})

Checklist

  • A human-readable description of the changes was provided to include in CHANGELOG

Release note

Added examples/{node,web}/coding/insert_uuid_into_uint128.ts showing how to insert a UUID into a UInt128 column with JSONEachRow, either via client-side BigInt conversion or via an EPHEMERAL UUID column with a UInt128 DEFAULT expression, with a round-trip assertion verifying the stored value.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix UUID parsing/conversion into uint128 during insertion Document UUID → UInt128 insert patterns for JSONEachRow May 29, 2026
Copilot AI requested a review from peter-leonov-ch May 29, 2026 23:30
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI changed the title Document UUID → UInt128 insert patterns for JSONEachRow Document UUID → UInt128 insert patterns with round-trip assertion May 30, 2026
@peter-leonov-ch peter-leonov-ch marked this pull request as ready for review May 31, 2026 18:05
@peter-leonov-ch peter-leonov-ch requested a review from mshustov as a code owner May 31, 2026 18:05
Copilot AI review requested due to automatic review settings May 31, 2026 18:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Node and Web examples documenting how to insert UUID-derived values into UInt128 columns through JSON formats, including assertions that both supported patterns round-trip to the same stored value.

Changes:

  • Adds client-side UUID-to-UInt128 conversion examples for Node and Web.
  • Adds EPHEMERAL UUID column + UInt128 DEFAULT examples for Node and Web.
  • Adds the new example pair to the examples README coding table.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
examples/node/coding/insert_uuid_into_uint128.ts Adds the Node example with node:assert round-trip checks.
examples/web/coding/insert_uuid_into_uint128.ts Adds the Web example with an inline assertion helper.
examples/README.md Links the new Node and Web examples in the coding section.

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.

UUID parsing/conversion into uint128 during insertion seems broken in node client

4 participants