Skip to content

Conversation

@jtmolon
Copy link

@jtmolon jtmolon commented Nov 24, 2025

Summary

AppendRow fails with conversion error if the value of the tuple field is a nil pointer. This is a problem when inserting from protobuf using optional nested messages, when these are not given a value.

Example error:

clickhouse [AppendRow]: updated_ts clickhouse [AppendRow]: converting *timestamppb.Timestamp to Tuple(seconds Int64, nanos Int32) is unsupported

This change allows for graceful handling of empty structs.
Full example here: https://gist.github.com/jtmolon/569f5a37bed17620c4c976baee0eb7ab

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@CLAassistant
Copy link

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.

if value.IsNil() {
// Instead of returning an error, create a zero value
// for the underlying type
value = reflect.New(value.Type().Elem()).Elem()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we should allow this behavior by default.

In your example,

var ts *timestamp.Timestamp

r.Append(ts)

It makes sense to panic here instead of silently inserting zero value IMHO. Because the later is hard to debug (make it worse in bigger systems).

In your use-case, I see two posibilities.

  1. Easier option is to use non-pointer for timestamp with protbuf tag, so if it's omitempty it automatically creates zero value.
  2. If you want to stick with pointer type, then doing nil check before calling append should solve the problem. No?

I would prefer to keep it more explicit and fail early instead of silent insertion of zero values.

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.

4 participants