rowbinary: readGeometry and writeGeometry throw for a Geometry that holds a MultiPoint (discriminant 6), and MultiPoint has no reader
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- backend
Research direction
Start with src/readers/geo.ts and src/writers/geo.ts, then inspect the NULLARY mapping in src/readers/compile.ts; the issue also identifies src/readers/reader.md and the rowbinary allowlist. Run the provided reproduction against ClickHouse 26.8 or later, and confirm that MultiPoint columns and Geometry discriminant 6 can be read and written, with the relevant rowbinary tests updated.
Written by the indexing model from the issue text.
Description
Describe the bug
@clickhouse/rowbinary cannot read a Geometry value that holds a MultiPoint. Since ClickHouse 26.8, MultiPoint is a geo type and an alternative of Geometry. One MultiPoint row in a Geometry column makes the whole result fail:
compileRowBinaryWithNamesAndTypesandreadGeometrythrowRangeError: RowBinary: unknown Geometry discriminant 6, also when theGeometryis insideArray,MaporTuple.writeGeometrythrows the same error for the discriminant 6, so aMultiPointcannot be written to aGeometrycolumn.- A
MultiPointcolumn (alsoArray(MultiPoint)) on the header path throwsRowBinaryTypeError: unsupported RowBinary type: MultiPoint.
Geometry values of the other six geo types decode correctly.
Steps to reproduce
- Start ClickHouse 26.8 or later.
- Run the program below (
CLICKHOUSE_URL, defaulthttp://localhost:8123). It makes a table with aGeometrycolumn that has aPointrow and aMultiPointrow.
Expected behaviour
The readers return the rows that the server returns in JSONEachRow (the first line of the output). In RowBinary, the server sends the MultiPoint row as the discriminant 06, then an Array(Point) value (06 02 and four Float64). The RowBinary docs list the Geometry discriminants 0 to 6, with 6 = MultiPoint. The Native format docs say that the Geometry discriminants are fixed and that new geo types are only added at the end, so 0 to 5 keep their meaning.
Code example
Reproduction program (JavaScript, 53 lines)
import { createClient, ClickHouseLogLevel } from '@clickhouse/client'
import { Cursor, compileRowBinaryWithNamesAndTypes, readGeometry } from '@clickhouse/rowbinary'
import { Sink, writeGeometry } from '@clickhouse/rowbinary/writer'
const client = createClient({
url: process.env.CLICKHOUSE_URL ?? 'http://localhost:8123',
log: { level: ClickHouseLogLevel.OFF },
})
async function bytes(query) {
const { stream } = await client.exec({ query })
const chunks = []
for await (const chunk of stream) chunks.push(chunk)
return Buffer.concat(chunks)
}
async function run(label, fn) {
try {
console.log(`${label}: ${JSON.stringify(await fn())}`)
} catch (e) {
console.log(`${label}: ${e.name}: ${e.message}`)
}
}
async function header(query) {
const cursor = new Cursor(await bytes(`${query} FORMAT RowBinaryWithNamesAndTypes`))
const { readRows } = compileRowBinaryWithNamesAndTypes(cursor)
return readRows(cursor)
}
await client.command({ query: 'DROP TABLE IF EXISTS geo_repro' })
await client.command({ query: 'CREATE TABLE geo_repro (id UInt8, g Geometry) ENGINE = MergeTree ORDER BY id' })
await client.command({
query: `INSERT INTO geo_repro SELECT 1, CAST(CAST((1, 2) AS Point) AS Geometry)
UNION ALL SELECT 2, CAST(CAST([(3, 4), (5, 6)] AS MultiPoint) AS Geometry)`,
})
const server = (await client.query({ query: 'SELECT id, g FROM geo_repro ORDER BY id', format: 'JSONEachRow' }))
await run('server, JSONEachRow', () => server.json())
await run('Geometry column, header path', () => header('SELECT id, g FROM geo_repro ORDER BY id'))
await run('contrast, without the MultiPoint row', () => header('SELECT id, g FROM geo_repro WHERE id = 1'))
await run('MultiPoint column, header path', () => header('SELECT CAST([(3, 4), (5, 6)] AS MultiPoint) AS m'))
await run('readGeometry, FORMAT RowBinary', async () =>
readGeometry(new Cursor(await bytes('SELECT g FROM geo_repro WHERE id = 2 FORMAT RowBinary'))),
)
await run('writeGeometry, discriminant 6', () => {
const sink = new Sink(Buffer.alloc(64))
writeGeometry(sink, [6, [[3, 4], [5, 6]]])
return Buffer.from(sink.bytes()).toString('hex')
})
await client.command({ query: 'DROP TABLE geo_repro' })
await client.close()
Error log
server, JSONEachRow: [{"id":1,"g":[1,2]},{"id":2,"g":[[3,4],[5,6]]}]
Geometry column, header path: RangeError: RowBinary: unknown Geometry discriminant 6
contrast, without the MultiPoint row: [{"id":1,"g":[1,2]}]
MultiPoint column, header path: RowBinaryTypeError: unsupported RowBinary type: MultiPoint
readGeometry, FORMAT RowBinary: RangeError: RowBinary: unknown Geometry discriminant 6
writeGeometry, discriminant 6: RangeError: RowBinary: unknown Geometry discriminant 6
Root cause
readGeometry(skills/clickhouse-js-node-rowbinary/src/readers/geo.ts:85) andwriteGeometry(src/writers/geo.ts:90) know only the discriminants 0 to 5 and0xFF. Every other value goes to thedefaultbranch, which throws (geo.ts:104,writers/geo.ts:119).- The package has no
MultiPointreader or writer, and theNULLARYtable ofastToReader(src/readers/compile.ts:271) has noMultiPointentry, so the header path throws atcompile.ts:204.
The JSDoc of readGeometry and GeometryValue, and the type table of reader.md, name only the six older geo types. The fix is small: a MultiPoint reader and writer (the wire is Array(Point), as for Ring), a NULLARY entry, and the case 6 in both Geometry switches.
Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Related: the upstream SQL test harness records these failures with "Issue: not filed yet" in tests/clickhouse-test-runner/rowbinary-allowlist.txt: group [rowbinary-geometry-discriminant] (2 tests) and 04509_multipoint_type in group [rowbinary-unsupported-types].
Configuration
Environment
- Client version:
mainat 0873ef2 (@clickhouse/rowbinary0.2.0,@clickhouse/client1.25.0) - Language version: Node.js 22.23.5
- OS: Linux (container)
ClickHouse server
- ClickHouse Server version: 26.11.7.10. 26.8.49.6 also sends the discriminant 6; 26.7.38.18 has no
MultiPointtype. - ClickHouse Server non-default settings, if any: none
Classification: impact: none · area: Data types & formats (Geometry, MultiPoint)
Found by automated analysis (Polyglot AI) while working on #216. Verified against a live server.
- Dominant language
- TypeScript
- Stars
- 332
- Forks
- 94
- Avg merge
- 19h 15m
- Merged PRs (30d)
- 43
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/clickhouse-js
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1292 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1290 ·
Maintainers usually reply within 1 day
-
Core SQL test harness: the shim takes the next setting as the value of --allow_repeated_settingsPossibly taken @polyglotAI-bot claimed this 3 days ago. Opentests
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1266 · 1 assignee ·
Maintainers usually reply within 1 day
-
Node.js 24/26: an insert from a raw-format stream of non-ASCII strings stops and times outPossibly taken @gedaliakliger claimed this 5 days ago. Openbug node queries
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-js#1246 ·
Maintainers usually reply within 1 day
All issues in ClickHouse/clickhouse-js
Similar issues
-
area: middleware enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
agent/quality testing
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
juspay/agent-distro#203 ·
Maintainers usually reply within 1 day
-
area/docs framework/jekyll language/markdown
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
meshery/schemas#1456 · 1 comment ·
Maintainers usually reply within 1 day