Skip to content

Commit 20ce0b1

Browse files
authored
Fix Int64&UInt64 in clickhouse output (#750)
1 parent 882281a commit 20ce0b1

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

plugin/output/clickhouse/colgenerator/colgenerator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func clickhouseTypes() []Type {
103103
types = append(types, Type{
104104
ChTypeName: protoName,
105105
GoName: goName,
106-
Convertable: true,
106+
Convertable: bits != 64,
107107
Nullable: true,
108108
})
109109
}

plugin/output/clickhouse/colgenerator/type.go

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func (t Type) InsaneConvertFunc() string {
4848
return "AsFloat32"
4949
case "float64":
5050
return "AsFloat64"
51+
case "int64":
52+
return "AsInt64"
53+
case "uint64":
54+
return "AsUint64"
5155
default:
5256
return "AsInt"
5357
}

plugin/output/clickhouse/column_gen.go

+2-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/output/clickhouse/insanenode.go

+18-9
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ var (
1717

1818
type InsaneNode interface {
1919
AsInt() (int, error)
20+
AsInt64() (int64, error)
21+
AsUint64() (uint64, error)
2022
AsFloat32() (float32, error)
2123
AsFloat64() (float64, error)
2224
AsString() (string, error)
2325
AsBool() (bool, error)
24-
AsInt64() (int64, error)
2526
AsStringArray() ([]string, error)
2627
AsUUID() (uuid.UUID, error)
2728
AsIPv4() (proto.IPv4, error)
@@ -139,6 +140,14 @@ func (n NonStrictNode) AsInt() (int, error) {
139140
return n.Node.AsInt(), nil
140141
}
141142

143+
func (n NonStrictNode) AsInt64() (int64, error) {
144+
return n.Node.AsInt64(), nil
145+
}
146+
147+
func (n NonStrictNode) AsUint64() (uint64, error) {
148+
return n.Node.AsUint64(), nil
149+
}
150+
142151
func (n NonStrictNode) AsFloat32() (float32, error) {
143152
return float32(n.AsFloat()), nil
144153
}
@@ -158,10 +167,6 @@ func (n NonStrictNode) AsBool() (bool, error) {
158167
return n.Node.AsBool(), nil
159168
}
160169

161-
func (n NonStrictNode) AsInt64() (int64, error) {
162-
return n.Node.AsInt64(), nil
163-
}
164-
165170
func (n NonStrictNode) AsUUID() (uuid.UUID, error) {
166171
uuidRaw, err := n.AsString()
167172
if err != nil {
@@ -219,6 +224,14 @@ func (z ZeroValueNode) AsInt() (int, error) {
219224
return 0, nil
220225
}
221226

227+
func (z ZeroValueNode) AsInt64() (int64, error) {
228+
return 0, nil
229+
}
230+
231+
func (z ZeroValueNode) AsUint64() (uint64, error) {
232+
return 0, nil
233+
}
234+
222235
func (z ZeroValueNode) AsFloat32() (float32, error) {
223236
return 0, nil
224237
}
@@ -235,10 +248,6 @@ func (z ZeroValueNode) AsBool() (bool, error) {
235248
return false, nil
236249
}
237250

238-
func (z ZeroValueNode) AsInt64() (int64, error) {
239-
return 0, nil
240-
}
241-
242251
func (z ZeroValueNode) AsStringArray() ([]string, error) {
243252
return nil, nil
244253
}

plugin/output/clickhouse/insanenode_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ func TestZeroValueNode(t *testing.T) {
4242
NewColUInt16(nullable),
4343
NewColInt32(nullable),
4444
NewColUInt32(nullable),
45+
NewColInt64(nullable),
46+
NewColUInt64(nullable),
4547
NewColInt128(nullable),
4648
NewColUInt128(nullable),
4749
NewColIPv4(nullable),

0 commit comments

Comments
 (0)