proto: ColTime32 has the type name "Time32", which the server does not know, so a Time column cannot be written or read
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
Research direction
Start with the exported constant ColumnTypeTime32 in proto/column.go (around line 236), which holds the wrong name "Time32". Then check its use in proto/col_time.go (the Type() method, around line 36) and in the ColAuto inference in proto/col_auto_gen.go (around line 19). Run the reproduction program against a ClickHouse 25.6+ server to confirm the INSERT and SELECT failures. Done means ColTime32 reports the server's Time name, the INSERT and SELECT succeed, and ColAuto infers the column. Check whether changing an exported constant needs a maintainer decision.
Written by the indexing model from the issue text.
Description
Describe the bug
proto.ColTime32 (and its alias proto.ColTime) reports the type Time32. No ClickHouse server has a Time32 type: the type is Time. So ColTime32 cannot exchange data with a server:
- an INSERT with a
ColTime32input fails withUNKNOWN_TYPE, and the client is then closed; - a SELECT of a
Timecolumn into aColTime32result fails with a type mismatch; - a SELECT of a
Timecolumn intoproto.ColAuto(alsoproto.Results.Auto) fails, because inference knows onlyTime32.
The wrappers report Nullable(Time32) and Array(Time32). ColTime64 (Time64(p)) works. clickhouse-go is not affected: it sends its own type name Time.
Steps to reproduce
- Start a ClickHouse server (
Timeneeds 25.6 or later). - Run the program below with
CLICKHOUSE_ADDR=<host>:9000 go run ..
Expected behaviour
The three calls succeed, as the Time64(3) contrast case does. The server knows only Time and Time64, on 25.6.13.41 (the first release with Time), 25.8.33.6 and 26.10.4.207:
SELECT toTypeName(CAST(0 AS Time32))
Code: 50. DB::Exception: Unknown data type family: Time32. Maybe you meant: ['Time64','Time'] ... (UNKNOWN_TYPE)
Only the name is wrong: a wrapper of ColTime32 whose Type() returns Time inserts and reads 01:02:03 and -01:02:03 correctly.
Code example
Reproduction program (Go, 56 lines)
package main
import (
"context"
"fmt"
"os"
"github.com/ClickHouse/ch-go"
"github.com/ClickHouse/ch-go/proto"
)
func main() {
addr := os.Getenv("CLICKHOUSE_ADDR")
if addr == "" {
addr = "localhost:9000"
}
ctx := context.Background()
dial := func() *ch.Client {
c, err := ch.Dial(ctx, ch.Options{Address: addr,
Settings: []ch.Setting{{Key: "enable_time_time64_type", Value: "1"}}})
if err != nil {
panic(err)
}
return c
}
c := dial()
for _, q := range []string{
"DROP TABLE IF EXISTS repro_time",
"CREATE TABLE repro_time (t Time, t64 Time64(3)) ENGINE = MergeTree ORDER BY tuple()",
"INSERT INTO repro_time VALUES ('01:02:03', '01:02:03.000')",
} {
if err := c.Do(ctx, ch.Query{Body: q}); err != nil {
panic(err)
}
}
in := new(proto.ColTime32)
in.Append(proto.IntoTime32(3723e9))
err := c.Do(ctx, ch.Query{Body: "INSERT INTO repro_time (t) VALUES", Input: proto.Input{{Name: "t", Data: in}}})
fmt.Println("INSERT ColTime32:", err)
c = dial() // the client is closed after the failed INSERT
var t proto.ColTime32
err = c.Do(ctx, ch.Query{Body: "SELECT t FROM repro_time", Result: proto.Results{{Name: "t", Data: &t}}})
fmt.Println("SELECT into ColTime32:", err)
c = dial()
var auto proto.ColAuto
err = c.Do(ctx, ch.Query{Body: "SELECT t FROM repro_time", Result: proto.Results{{Name: "t", Data: &auto}}})
fmt.Println("SELECT into ColAuto:", err)
c = dial()
var t64 proto.ColTime64
err = c.Do(ctx, ch.Query{Body: "SELECT t64 FROM repro_time", Result: proto.Results{{Name: "t64", Data: &t64}}})
fmt.Println("SELECT Time64(3) into ColTime64:", err, t64.Rows())
}
Error log
INSERT ColTime32: handle packet: UNKNOWN_TYPE (50): DB::Exception: Unknown data type family: Time32. Maybe you meant: ['Time64','Time']
SELECT into ColTime32: decode block: decode block: raw block: target: [0]: t: unexpected type "Time" (got) instead of "Time32" (has)
SELECT into ColAuto: decode block: decode block: raw block: target: infer: automatic column inference not supported for "Time"
SELECT Time64(3) into ColTime64: <nil> 1
Root cause
The constant ColumnTypeTime32 has the value "Time32" (proto/column.go:236); ColTime32.Type() returns it (proto/col_time.go:36), and ColAuto infers ColTime32 only for it (proto/col_auto_gen.go:19).
The fix changes the value of this exported constant, or adds a ColumnTypeTime constant; clickhouse-go uses neither.
Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Configuration
Environment
- Client version:
main(44a3358);v0.67.0tov0.76.0have the same code - Language version: Go 1.26.11
- OS: Linux
ClickHouse server
- ClickHouse Server version: 26.10.4.207
- ClickHouse Server non-default settings, if any: none (the program sets
enable_time_time64_type = 1, which 25.6 and 25.8 need) CREATE TABLEstatements for tables involved: in the program
Classification: impact: none · area: Data types & formats (Time) · native: format
Found by automated analysis (Polyglot AI) while working on ClickHouse/ch-go#1249. Verified against a live server.
- Dominant language
- Go
- Stars
- 435
- Forks
- 101
- Avg merge
- 22h 1m
- Merged PRs (30d)
- 15
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No 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/ch-go
-
bug connectivity
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ch-go#1264 ·
Maintainers usually reply within 1 day
-
proto: Time64(4), (5), (7) and (8) values are cut to milliseconds on write and readPossibly taken @AmanBoronbaev claimed this 8 days ago. Openbug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ch-go#1248 ·
Maintainers usually reply within 1 day
-
compress: block buffers get re-zeroed on every call, and the zeroing is immediately overwrittenPossibly taken @deepanshu75 claimed this 11 days ago. Openconnectivity enhancement native-protocol performance
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ch-go#1218 · 1 comment ·
Maintainers usually reply within 1 day
-
ch.Parameters does not escape quotes/backslashes in string valuesPossibly taken @Laotree claimed this 85 days ago. Openbug native-protocol queries
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ch-go#1198 · 1 comment ·
Maintainers usually reply within 1 day
-
compress: a stream that ends right after a block header reads as io.EOF, the same as a clean endPossibly taken @AmanBoronbaev claimed this 1 day ago. Openbug connectivity native-protocol
Difficulty 3/5 1-2 days Newbie friendliness 69/100
ClickHouse/ch-go#1256 ·
Maintainers usually reply within 1 day
All issues in ClickHouse/ch-go
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
seriousm4x/UpSnap#1786 ·
-
bug feedback ui/ux
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
peasant-labs/peasant#1307 ·
Maintainers usually reply within 1 day
-
Reformat test names for single-protocol tests to start with Protocol/, i.e. gRPC/ or Websocket/Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
connectrpc/conformance#1211 ·
Maintainers usually reply within 1 day
-
bug effort:s impact:med raised-by:desk risk:low
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
medici-finance/assay#8342 · 1 comment ·
Maintainers usually reply within 1 day
-
hardening
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
inference-sim/inference-sim#2821 ·
Maintainers usually reply within 1 day