Files
zeekay ef352c1051 debrand: rename the wire client name, prose and linter config
proto.Name is sent in ClientHello and lands in the server's system.query_log,
so it is wire visible; it now reads datastore/native and is covered by a test.
Verified against the live server: the handshake succeeds and the new name
appears in query_log.

goimports' local-prefixes still named the upstream module, so it was not
grouping this module's own imports.

Doc comments, the deprecated-error markers in proto/error_codes.go and the
package prose are swept. Dead references are removed rather than repointed:
go-faster.org/docs/clickhouse and the mangled Datastore/clickhouse-cpp link
both 404, and the list of other vendors' clients does not belong here.

Four things deliberately keep the vendor name, and CI records why:
LICENSE and AUTHORS are the copyright notices Apache-2.0 requires; db.system in
query.go is an OpenTelemetry enum whose registered value for this DBMS is fixed
by the specification, so emitting anything else would be non-conformant; and
README names clickhouse-local, which is genuinely the binary our own server
image ships.

Numeric error codes and protocol revision constants are untouched.
2026-07-26 11:50:36 -07:00

63 lines
1.4 KiB
Go

package proto
import (
"time"
)
// Precision of DateTime64 and Time64.
//
// Tick size (precision): 10^(-precision) seconds.
// Valid range: [0:9].
type Precision byte
// Duration returns duration of single tick for precision.
func (p Precision) Duration() time.Duration {
return time.Nanosecond * time.Duration(p.Scale())
}
// Valid reports whether precision is valid.
func (p Precision) Valid() bool {
return p <= PrecisionMax
}
func (p Precision) Scale() int64 {
d := int64(1)
for i := PrecisionNano; i > p; i-- {
d *= 10
}
return d
}
const (
// PrecisionSecond is one second precision.
PrecisionSecond Precision = 0
// PrecisionMilli is millisecond precision.
PrecisionMilli Precision = 3
// PrecisionMicro is microsecond precision.
PrecisionMicro Precision = 6
// PrecisionNano is nanosecond precision.
PrecisionNano Precision = 9
// PrecisionMax is maximum precision (nanosecond).
PrecisionMax = PrecisionNano
)
// DateTime64 represents DateTime64 type.
//
// See https://docs.hanzo.ai/datastore
type DateTime64 int64
// ToDateTime64 converts time.Time to DateTime64.
func ToDateTime64(t time.Time, p Precision) DateTime64 {
if t.IsZero() {
return 0
}
return DateTime64(t.UnixNano() / p.Scale())
}
// Time returns DateTime64 as time.Time.
func (d DateTime64) Time(p Precision) time.Time {
nsec := int64(d) * p.Scale()
return time.Unix(nsec/1e9, nsec%1e9)
}