fix(querier): decode JSON columns for scalar and time-series results - #12555
Open
tushar-signoz wants to merge 1 commit into
Open
fix(querier): decode JSON columns for scalar and time-series results#12555tushar-signoz wants to merge 1 commit into
tushar-signoz wants to merge 1 commit into
Conversation
Share the raw reader's JSON scan target across all three readers, and unwrap Dynamic columns from their chcol.Variant envelope.
tushar-signoz
requested review from
srikanthccv and
therealpandey
as code owners
August 13, 2026 23:58
| return &v | ||
| } | ||
| return reflect.New(colType.ScanType()).Interface() | ||
| } |
Member
There was a problem hiding this comment.
Wondering if this this is the best possible fix for the highlighted problem, can there other possible places where we might miss reading this []byte like in waterfall / flamegraph apis once we move attributes to json?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
POST /api/v5/query_rangereturned HTTP 500 (JSON Scan value must be clickhouse.JSON or map[string]any) for anyscalarortime_seriesClickHouse query whose result contained a JSON column — on abody_v2stack,select * from signoz_logs.logs_v2is enough. OnlyreadAsRawrouted JSON columns to a[]bytescan target;readAsScalarandreadAsTimeSeriesscanned intochcol.JSON, whoseScanrejects the string ClickHouse sends us.readAsRawintoscanTarget/decodeColumnValue, shared by all three readers.Dynamiccolumns (a JSON path such asbody_v2.level) from theirchcol.Variantenvelope, so consumers get7/"x"instead of an opaque struct.Issues closed by this PR
Fixes https://github.com/SigNoz/engineering-pod/issues/5911
Additional Information
The issue suggested treating
DynamiclikeJSONon the bytes path. Probing the driver against ClickHouse 25.12 shows that would break it —Dynamicscans natively, and only its string-backed values survive a*[]bytetarget:reflect.New(ScanType()))*[]byteJSONJSON Scan value must be…Dynamic(String)Variant{"str", "String"}Dynamic(Int64)Variant{1, "Int64"}converting Int64 to *[]uint8So
Dynamickeeps its native scan target and is unwrapped after the scan instead. The wire format is unchanged (Variantalready marshalled to its underlying value), only the Go type improves.Verified end to end against the devenv ClickHouse, same request on both binaries:
requestTypescalarbody_v2decoded as an objecttime_seriesrawOut of scope, but found while probing: a
Map(String, JSON)column panics inside the driver (reflect.Value.SetMapIndex: value of type []uint8 is not assignable to type chcol.JSON), andconsumeruns in an errgroup goroutine, so the HTTP recovery middleware would not catch it. Nested-JSON containers can't be byte-scanned either, so that needs its own fix.