Skip to content

Commit 0f8349b

Browse files
committed
refactor: cleanup decimal method names
1 parent 8405773 commit 0f8349b

File tree

11 files changed

+50
-50
lines changed

11 files changed

+50
-50
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ ingestion workload.
193193
QuestDB server version 9.2.0 and newer supports decimal columns with arbitrary precision and scale.
194194
The Go client converts supported decimal values to QuestDB's text/binary wire format automatically:
195195

196-
- `DecimalColumnScaled`: `questdb.ScaledDecimal`, including helpers like `questdb.NewDecimalFromInt64` and `questdb.NewDecimal`.
196+
- `DecimalColumn`: `questdb.ScaledDecimal`, including helpers like `questdb.NewDecimalFromInt64` and `questdb.NewDecimal`.
197197
- `DecimalColumnShopspring`: `github.com/shopspring/decimal.Decimal` values or pointers.
198-
- `DecimalColumnString`: `string` literals representing decimal values (validated at runtime).
198+
- `DecimalColumnFromString`: `string` literals representing decimal values (validated at runtime).
199199

200200
```go
201201
price := qdb.NewDecimalFromInt64(12345, 2) // 123.45 with scale 2
@@ -204,8 +204,8 @@ commission := qdb.NewDecimal(big.NewInt(-750), 4) // -0.0750 with scale 4
204204
err = sender.
205205
Table("trades").
206206
Symbol("symbol", "ETH-USD").
207-
DecimalColumnScaled("price", price).
208-
DecimalColumnScaled("commission", commission).
207+
DecimalColumn("price", price).
208+
DecimalColumn("commission", commission).
209209
AtNow(ctx)
210210
```
211211

@@ -214,7 +214,7 @@ To emit textual decimals, pass a validated string literal:
214214
```go
215215
err = sender.
216216
Table("quotes").
217-
DecimalColumnString("mid", "1.23456").
217+
DecimalColumnFromString("mid", "1.23456").
218218
AtNow(ctx)
219219
```
220220

buffer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,18 +573,18 @@ func (b *buffer) Float64Column(name string, val float64) *buffer {
573573
return b
574574
}
575575

576-
func (b *buffer) DecimalColumnScaled(name string, val ScaledDecimal) *buffer {
576+
func (b *buffer) DecimalColumn(name string, val ScaledDecimal) *buffer {
577577
if val.isNull() {
578578
// Don't write null decimals
579579
return b
580580
}
581581
if !b.prepareForField() {
582582
return b
583583
}
584-
return b.decimalColumnScaled(name, val)
584+
return b.decimalColumn(name, val)
585585
}
586586

587-
func (b *buffer) decimalColumnScaled(name string, val ScaledDecimal) *buffer {
587+
func (b *buffer) decimalColumn(name string, val ScaledDecimal) *buffer {
588588
if err := val.ensureValidScale(); err != nil {
589589
b.lastErr = err
590590
return b
@@ -603,7 +603,7 @@ func (b *buffer) decimalColumnScaled(name string, val ScaledDecimal) *buffer {
603603
return b
604604
}
605605

606-
func (b *buffer) DecimalColumnString(name string, val string) *buffer {
606+
func (b *buffer) DecimalColumnFromString(name string, val string) *buffer {
607607
if !b.prepareForField() {
608608
return b
609609
}
@@ -641,7 +641,7 @@ func (b *buffer) DecimalColumnShopspring(name string, val ShopspringDecimal) *bu
641641
if !b.prepareForField() {
642642
return b
643643
}
644-
return b.decimalColumnScaled(name, dec)
644+
return b.decimalColumn(name, dec)
645645
}
646646

647647
func (b *buffer) Float64ColumnBinary(name string, val float64) *buffer {

buffer_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ func TestFloat64ColumnBinary(t *testing.T) {
494494
}
495495
}
496496

497-
func TestDecimalColumnScaled(t *testing.T) {
497+
func TestDecimalColumn(t *testing.T) {
498498
negative, err := qdb.NewDecimal(big.NewInt(-12345), 3)
499499
assert.NoError(t, err)
500500

@@ -524,14 +524,14 @@ func TestDecimalColumnScaled(t *testing.T) {
524524
for _, tc := range testCases {
525525
t.Run(tc.name, func(t *testing.T) {
526526
buf := newTestBuffer()
527-
err := buf.Table(testTable).DecimalColumnScaled("price", tc.value).At(time.Time{}, false)
527+
err := buf.Table(testTable).DecimalColumn("price", tc.value).At(time.Time{}, false)
528528
assert.NoError(t, err)
529529
assert.Equal(t, tc.expected, buf.Messages())
530530
})
531531
}
532532
}
533533

534-
func TestDecimalColumnScaledTrimmingAndPadding(t *testing.T) {
534+
func TestDecimalColumnTrimmingAndPadding(t *testing.T) {
535535
prefix := []byte(testTable + " price==")
536536

537537
testCases := []struct {
@@ -595,7 +595,7 @@ func TestDecimalColumnScaledTrimmingAndPadding(t *testing.T) {
595595
t.Run(tc.name, func(t *testing.T) {
596596
buf := newTestBuffer()
597597

598-
err := buf.Table(testTable).DecimalColumnScaled("price", tc.value).At(time.Time{}, false)
598+
err := buf.Table(testTable).DecimalColumn("price", tc.value).At(time.Time{}, false)
599599
assert.NoError(t, err)
600600

601601
expected := append(append([]byte{}, prefix...), tc.expectedBytes...)
@@ -654,7 +654,7 @@ func TestDecimalColumnShopspring(t *testing.T) {
654654
}
655655
}
656656

657-
func TestDecimalColumnStringValidation(t *testing.T) {
657+
func TestDecimalColumnFromStringValidation(t *testing.T) {
658658
t.Run("valid strings", func(t *testing.T) {
659659
testCases := []struct {
660660
name string
@@ -672,7 +672,7 @@ func TestDecimalColumnStringValidation(t *testing.T) {
672672
for _, tc := range testCases {
673673
t.Run(tc.name, func(t *testing.T) {
674674
buf := newTestBuffer()
675-
err := buf.Table(testTable).DecimalColumnString("price", tc.value).At(time.Time{}, false)
675+
err := buf.Table(testTable).DecimalColumnFromString("price", tc.value).At(time.Time{}, false)
676676
assert.NoError(t, err)
677677
expected := []byte(testTable + " price=" + tc.expected + "\n")
678678
assert.Equal(t, expected, buf.Messages())
@@ -696,7 +696,7 @@ func TestDecimalColumnStringValidation(t *testing.T) {
696696
for _, tc := range testCases {
697697
t.Run(tc.name, func(t *testing.T) {
698698
buf := newTestBuffer()
699-
err := buf.Table(testTable).DecimalColumnString("price", tc.value).At(time.Time{}, false)
699+
err := buf.Table(testTable).DecimalColumnFromString("price", tc.value).At(time.Time{}, false)
700700
assert.Error(t, err)
701701
assert.Contains(t, err.Error(), "decimal")
702702
assert.Empty(t, buf.Messages())
@@ -709,7 +709,7 @@ func TestDecimalColumnErrors(t *testing.T) {
709709
t.Run("invalid scale", func(t *testing.T) {
710710
buf := newTestBuffer()
711711
dec := qdb.NewDecimalFromInt64(1, 100)
712-
err := buf.Table(testTable).DecimalColumnScaled("price", dec).At(time.Time{}, false)
712+
err := buf.Table(testTable).DecimalColumn("price", dec).At(time.Time{}, false)
713713
assert.ErrorContains(t, err, "decimal scale")
714714
assert.Empty(t, buf.Messages())
715715
})

http_sender.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func (s *httpLineSender) Float64Column(name string, val float64) LineSender {
305305
return s
306306
}
307307

308-
func (s *httpLineSender) DecimalColumnString(name string, val string) LineSender {
308+
func (s *httpLineSender) DecimalColumnFromString(name string, val string) LineSender {
309309
s.buf.SetLastErr(errDecimalNotSupported)
310310
return s
311311
}
@@ -315,7 +315,7 @@ func (s *httpLineSender) DecimalColumnShopspring(name string, val ShopspringDeci
315315
return s
316316
}
317317

318-
func (s *httpLineSender) DecimalColumnScaled(name string, val ScaledDecimal) LineSender {
318+
func (s *httpLineSender) DecimalColumn(name string, val ScaledDecimal) LineSender {
319319
s.buf.SetLastErr(errDecimalNotSupported)
320320
return s
321321
}
@@ -652,7 +652,7 @@ func (s *httpLineSenderV2) Float64ArrayNDColumn(name string, values *NdArray[flo
652652
return s
653653
}
654654

655-
func (s *httpLineSenderV2) DecimalColumnString(name string, val string) LineSender {
655+
func (s *httpLineSenderV2) DecimalColumnFromString(name string, val string) LineSender {
656656
s.buf.SetLastErr(errDecimalNotSupported)
657657
return s
658658
}
@@ -662,7 +662,7 @@ func (s *httpLineSenderV2) DecimalColumnShopspring(name string, val ShopspringDe
662662
return s
663663
}
664664

665-
func (s *httpLineSenderV2) DecimalColumnScaled(name string, val ScaledDecimal) LineSender {
665+
func (s *httpLineSenderV2) DecimalColumn(name string, val ScaledDecimal) LineSender {
666666
s.buf.SetLastErr(errDecimalNotSupported)
667667
return s
668668
}
@@ -727,13 +727,13 @@ func (s *httpLineSenderV3) Float64ArrayNDColumn(name string, values *NdArray[flo
727727
return s
728728
}
729729

730-
func (s *httpLineSenderV3) DecimalColumnScaled(name string, val ScaledDecimal) LineSender {
731-
s.buf.DecimalColumnScaled(name, val)
730+
func (s *httpLineSenderV3) DecimalColumn(name string, val ScaledDecimal) LineSender {
731+
s.buf.DecimalColumn(name, val)
732732
return s
733733
}
734734

735-
func (s *httpLineSenderV3) DecimalColumnString(name string, val string) LineSender {
736-
s.buf.DecimalColumnString(name, val)
735+
func (s *httpLineSenderV3) DecimalColumnFromString(name string, val string) LineSender {
736+
s.buf.DecimalColumnFromString(name, val)
737737
return s
738738
}
739739

http_sender_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ func TestDecimalColumnUnsupportedInHttpProtocolV2(t *testing.T) {
937937

938938
err = sender.
939939
Table(testTable).
940-
DecimalColumnString("price", "12.99").
940+
DecimalColumnFromString("price", "12.99").
941941
At(ctx, time.UnixMicro(1))
942942
assert.Error(t, err)
943943
assert.Contains(t, err.Error(), "current protocol version does not support decimal")

integration_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ func (suite *integrationTestSuite) TestE2EValidWrites() {
499499
func(s qdb.LineSender) error {
500500
err := s.
501501
Table(testTable).
502-
DecimalColumnString("text_col", "123.45").
503-
DecimalColumnScaled("binary_col", qdb.NewDecimalFromInt64(12345, 2)).
504-
DecimalColumnScaled("binary_neg_col", qdb.NewDecimalFromInt64(-12345, 2)).
502+
DecimalColumnFromString("text_col", "123.45").
503+
DecimalColumn("binary_col", qdb.NewDecimalFromInt64(12345, 2)).
504+
DecimalColumn("binary_neg_col", qdb.NewDecimalFromInt64(-12345, 2)).
505505
DecimalColumnShopspring("binary_null_col", nil).
506506
At(ctx, time.UnixMicro(1))
507507
if err != nil {
@@ -510,9 +510,9 @@ func (suite *integrationTestSuite) TestE2EValidWrites() {
510510

511511
return s.
512512
Table(testTable).
513-
DecimalColumnString("text_col", "123.46").
514-
DecimalColumnScaled("binary_col", qdb.NewDecimalFromInt64(12346, 2)).
515-
DecimalColumnScaled("binary_neg_col", qdb.NewDecimalFromInt64(-12346, 2)).
513+
DecimalColumnFromString("text_col", "123.46").
514+
DecimalColumn("binary_col", qdb.NewDecimalFromInt64(12346, 2)).
515+
DecimalColumn("binary_neg_col", qdb.NewDecimalFromInt64(-12346, 2)).
516516
DecimalColumnShopspring("binary_null_col", nil).
517517
At(ctx, time.UnixMicro(2))
518518
},

interop_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func execute(t *testing.T, ctx context.Context, sender qdb.LineSender, backCh ch
124124
case "DECIMAL":
125125
dec, err := parseDecimal64(s.Value.(string))
126126
assert.NoError(t, err)
127-
sender.DecimalColumnScaled(s.Name, dec)
127+
sender.DecimalColumn(s.Name, dec)
128128
default:
129129
assert.Fail(t, "unexpected column type: "+s.Type)
130130
}

sender.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ type LineSender interface {
114114
// Column name cannot contain any of the following characters:
115115
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
116116
// '-', '*' '%%', '~', or a non-printable char.
117-
DecimalColumnString(name string, val string) LineSender
117+
DecimalColumnFromString(name string, val string) LineSender
118118

119-
// DecimalColumnScaled adds a decimal column value to the ILP message.
119+
// DecimalColumn adds a decimal column value to the ILP message.
120120
//
121121
// Serializes the decimal value using the binary representation.
122122
//
123123
// Column name cannot contain any of the following characters:
124124
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
125125
// '-', '*' '%%', '~', or a non-printable char.
126-
DecimalColumnScaled(name string, val ScaledDecimal) LineSender
126+
DecimalColumn(name string, val ScaledDecimal) LineSender
127127

128128
// DecimalColumnShopspring adds a decimal column value to the ILP message.
129129
//

sender_pool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ func (ps *pooledSender) Float64Column(name string, val float64) LineSender {
314314
return ps
315315
}
316316

317-
func (ps *pooledSender) DecimalColumnString(name string, val string) LineSender {
318-
ps.wrapped.DecimalColumnString(name, val)
317+
func (ps *pooledSender) DecimalColumnFromString(name string, val string) LineSender {
318+
ps.wrapped.DecimalColumnFromString(name, val)
319319
return ps
320320
}
321321

@@ -324,8 +324,8 @@ func (ps *pooledSender) DecimalColumnShopspring(name string, val ShopspringDecim
324324
return ps
325325
}
326326

327-
func (ps *pooledSender) DecimalColumnScaled(name string, val ScaledDecimal) LineSender {
328-
ps.wrapped.DecimalColumnScaled(name, val)
327+
func (ps *pooledSender) DecimalColumn(name string, val ScaledDecimal) LineSender {
328+
ps.wrapped.DecimalColumn(name, val)
329329
return ps
330330
}
331331

tcp_sender.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (s *tcpLineSender) Float64Column(name string, val float64) LineSender {
203203
return s
204204
}
205205

206-
func (s *tcpLineSender) DecimalColumnString(name string, val string) LineSender {
206+
func (s *tcpLineSender) DecimalColumnFromString(name string, val string) LineSender {
207207
s.buf.SetLastErr(errDecimalNotSupported)
208208
return s
209209
}
@@ -213,7 +213,7 @@ func (s *tcpLineSender) DecimalColumnShopspring(name string, val ShopspringDecim
213213
return s
214214
}
215215

216-
func (s *tcpLineSender) DecimalColumnScaled(name string, val ScaledDecimal) LineSender {
216+
func (s *tcpLineSender) DecimalColumn(name string, val ScaledDecimal) LineSender {
217217
s.buf.SetLastErr(errDecimalNotSupported)
218218
return s
219219
}
@@ -381,7 +381,7 @@ func (s *tcpLineSenderV2) Float64ArrayNDColumn(name string, values *NdArray[floa
381381
return s
382382
}
383383

384-
func (s *tcpLineSenderV2) DecimalColumnString(name string, val string) LineSender {
384+
func (s *tcpLineSenderV2) DecimalColumnFromString(name string, val string) LineSender {
385385
s.buf.SetLastErr(errDecimalNotSupported)
386386
return s
387387
}
@@ -391,7 +391,7 @@ func (s *tcpLineSenderV2) DecimalColumnShopspring(name string, val ShopspringDec
391391
return s
392392
}
393393

394-
func (s *tcpLineSenderV2) DecimalColumnScaled(name string, val ScaledDecimal) LineSender {
394+
func (s *tcpLineSenderV2) DecimalColumn(name string, val ScaledDecimal) LineSender {
395395
s.buf.SetLastErr(errDecimalNotSupported)
396396
return s
397397
}
@@ -456,13 +456,13 @@ func (s *tcpLineSenderV3) Float64ArrayNDColumn(name string, values *NdArray[floa
456456
return s
457457
}
458458

459-
func (s *tcpLineSenderV3) DecimalColumnString(name string, val string) LineSender {
460-
s.buf.DecimalColumnString(name, val)
459+
func (s *tcpLineSenderV3) DecimalColumnFromString(name string, val string) LineSender {
460+
s.buf.DecimalColumnFromString(name, val)
461461
return s
462462
}
463463

464-
func (s *tcpLineSenderV3) DecimalColumnScaled(name string, val ScaledDecimal) LineSender {
465-
s.buf.DecimalColumnScaled(name, val)
464+
func (s *tcpLineSenderV3) DecimalColumn(name string, val ScaledDecimal) LineSender {
465+
s.buf.DecimalColumn(name, val)
466466
return s
467467
}
468468

0 commit comments

Comments
 (0)