Skip to content

Commit 304f043

Browse files
committed
chore(client): revert negative exponent double serialization
1 parent 822b1b9 commit 304f043

File tree

4 files changed

+87
-59
lines changed

4 files changed

+87
-59
lines changed

sender.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -737,15 +737,6 @@ func (b *buffer) WriteFloat(f float64) {
737737
}
738738
// We need up to 24 bytes to fit a float64, including a sign.
739739
var a [24]byte
740-
s := strconv.AppendFloat(a[0:0], f, 'g', -1, 64)
741-
var prev byte
742-
for i := 0; i < len(s); i++ {
743-
// Server doesn't support 4.2e+100 notation and expects
744-
// 4.2e100 instead. So, we make sure to erase '+'.
745-
if prev == 'e' && s[i] == '+' {
746-
continue
747-
}
748-
b.WriteByte(s[i])
749-
prev = s[i]
750-
}
740+
s := strconv.AppendFloat(a[0:0], f, 'G', -1, 64)
741+
b.Write(s)
751742
}

sender_integration_test.go

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func TestE2EValidWrites(t *testing.T) {
331331
},
332332
},
333333
{
334-
"small double value with exponent",
334+
"double value with exponent",
335335
testTable,
336336
func(s *qdb.LineSender) error {
337337
return s.
@@ -350,46 +350,6 @@ func TestE2EValidWrites(t *testing.T) {
350350
Count: 1,
351351
},
352352
},
353-
{
354-
"large double value with exponent",
355-
testTable,
356-
func(s *qdb.LineSender) error {
357-
return s.
358-
Table(testTable).
359-
Float64Column("foobar", 4.2e100).
360-
At(ctx, 1000)
361-
},
362-
tableData{
363-
Columns: []column{
364-
{"foobar", "DOUBLE"},
365-
{"timestamp", "TIMESTAMP"},
366-
},
367-
Dataset: [][]interface{}{
368-
{4.2e100, "1970-01-01T00:00:00.000001Z"},
369-
},
370-
Count: 1,
371-
},
372-
},
373-
{
374-
"negative double value with exponent",
375-
testTable,
376-
func(s *qdb.LineSender) error {
377-
return s.
378-
Table(testTable).
379-
Float64Column("foobar", -4.2e100).
380-
At(ctx, 1000)
381-
},
382-
tableData{
383-
Columns: []column{
384-
{"foobar", "DOUBLE"},
385-
{"timestamp", "TIMESTAMP"},
386-
},
387-
Dataset: [][]interface{}{
388-
{-4.2e100, "1970-01-01T00:00:00.000001Z"},
389-
},
390-
Count: 1,
391-
},
392-
},
393353
}
394354

395355
for _, tc := range testCases {

sender_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestValidWrites(t *testing.T) {
110110
}
111111
}
112112

113-
func TestIntSerialization(t *testing.T) {
113+
func TestInt64Serialization(t *testing.T) {
114114
ctx := context.Background()
115115

116116
testCases := []struct {
@@ -148,7 +148,7 @@ func TestIntSerialization(t *testing.T) {
148148
}
149149
}
150150

151-
func TestFloatSerialization(t *testing.T) {
151+
func TestFloat64Serialization(t *testing.T) {
152152
ctx := context.Background()
153153

154154
testCases := []struct {
@@ -162,11 +162,11 @@ func TestFloatSerialization(t *testing.T) {
162162
{"negative infinity", math.Inf(-1), "-Infinity"},
163163
{"positive number", 42.3, "42.3"},
164164
{"negative number", -42.3, "-42.3"},
165-
{"smallest value", math.SmallestNonzeroFloat64, "5e-324"},
166-
{"max value", math.MaxFloat64, "1.7976931348623157e308"},
167-
{"negative with exponent", -4.2e-99, "-4.2e-99"},
168-
{"small with exponent", 4.2e-99, "4.2e-99"},
169-
{"large with exponent", 4.2e99, "4.2e99"},
165+
{"smallest value", math.SmallestNonzeroFloat64, "5E-324"},
166+
{"max value", math.MaxFloat64, "1.7976931348623157E+308"},
167+
{"negative with exponent", -4.2e-99, "-4.2E-99"},
168+
{"small with exponent", 4.2e-99, "4.2E-99"},
169+
{"large with exponent", 4.2e99, "4.2E+99"},
170170
}
171171

172172
for _, tc := range testCases {

test/ilp-client-interop-test.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,81 @@
11
[
2+
{
3+
"testName": "all column types",
4+
"table": "test_table",
5+
"symbols": [
6+
{
7+
"name": "sym_col",
8+
"value": "sym_val"
9+
}
10+
],
11+
"columns": [
12+
{
13+
"type": "STRING",
14+
"name": "str_col",
15+
"value": "foo bar baz"
16+
},
17+
{
18+
"type": "LONG",
19+
"name": "long_col",
20+
"value": 42
21+
},
22+
{
23+
"type": "DOUBLE",
24+
"name": "double_col",
25+
"value": 42.5
26+
},
27+
{
28+
"type": "BOOLEAN",
29+
"name": "bool_col",
30+
"value": true
31+
}
32+
],
33+
"result": {
34+
"status": "SUCCESS",
35+
"line": "test_table,sym_col=sym_val str_col=\"foo bar baz\",long_col=42i,double_col=42.5,bool_col=t"
36+
}
37+
},
38+
{
39+
"testName": "double serialization",
40+
"table": "doubles",
41+
"symbols": [],
42+
"columns": [
43+
{
44+
"type": "DOUBLE",
45+
"name": "d0",
46+
"value": 0.0
47+
},
48+
{
49+
"type": "DOUBLE",
50+
"name": "dm0",
51+
"value": -0.0
52+
},
53+
{
54+
"type": "DOUBLE",
55+
"name": "d1",
56+
"value": 1.0
57+
},
58+
{
59+
"type": "DOUBLE",
60+
"name": "dE100",
61+
"value": 1E100
62+
},
63+
{
64+
"type": "DOUBLE",
65+
"name": "d0000001",
66+
"value": 0.000001
67+
},
68+
{
69+
"type": "DOUBLE",
70+
"name": "dN0000001",
71+
"value": -0.000001
72+
}
73+
],
74+
"result": {
75+
"status": "SUCCESS",
76+
"line": "doubles d0=0,dm0=-0,d1=1,dE100=1E+100,d0000001=1E-06,dN0000001=-1E-06"
77+
}
78+
},
279
{
380
"testName": "escaped chars in table name",
481
"table": "test 1=2",

0 commit comments

Comments
 (0)