MCPcopy Create free account
hub / github.com/PostHog/duckgres / String

Method String

duckdbservice/arrowmap/arrowmap.go:343–363  ·  view source on GitHub ↗

String renders the decimal in plain numeric form, e.g. {314159, 5} → "3.14159" and {-5, 2} → "-0.05". Required so the PG text-protocol formatter (server.formatValue) and any other fmt.Sprint-based callers produce a number string instead of falling back to the Go default "{value scale}" struct render

()

Source from the content-addressed store, hash-verified

341// "{value scale}" struct rendering. Negative values keep the sign in
342// front of the integer part. Scale 0 prints as the integer.
343func (d DecimalValue) String() string {
344 if d.Value == nil {
345 return "0"
346 }
347 if d.Scale <= 0 {
348 return d.Value.String()
349 }
350 abs := new(big.Int).Abs(d.Value).String()
351 // Left-pad with zeros so the digit count is at least Scale+1, giving us
352 // room to insert the decimal point even when |Value| < 10^Scale.
353 if pad := d.Scale + 1 - len(abs); pad > 0 {
354 abs = strings.Repeat("0", pad) + abs
355 }
356 intPart := abs[:len(abs)-d.Scale]
357 fracPart := abs[len(abs)-d.Scale:]
358 sign := ""
359 if d.Value.Sign() < 0 {
360 sign = "-"
361 }
362 return sign + intPart + "." + fracPart
363}
364
365// Appender is a hook that handles append for value types arrowmap doesn't
366// know about (typically driver-specific types like duckdb.Interval). It

Callers 8

TestDecimalValueStringFunction · 0.95
sendProfilingMetadataFunction · 0.45
handleDuckDBValueFunction · 0.45
RunFunction · 0.45
parseStructFieldDefFunction · 0.45
TestDuckDBTypeToArrowFunction · 0.45

Calls

no outgoing calls

Tested by 4

TestDecimalValueStringFunction · 0.76
TestDuckDBTypeToArrowFunction · 0.36