Title
u

Utkarsh Chourasia

12/03/2022, 11:38 AM
Hey, I want to contribute to https://github.com/questdb/go-questdb-client project. I see there is an issue open. This would be my first contribution so need a little guidances. Until now, I have forked -> make a new branch -> started questDB server in Docker -> ??? After this I am not sure what to do next. I ran the
main.go
files in examples.
a

Andrey Pechkurov

12/05/2022, 10:35 AM
Hi Utkarsh, Server expects the following format for long256 values: https://questdb.io/docs/reference/api/ilp/columnset-types/#long256 Client API wise I see two options: accepts a long256 value as 4 `uint64`s
sender.
		Table("trades").
		Long256Column("value", 1, 2, 3, 4).
		AtNow(ctx)
or accept a math/big Int: https://pkg.go.dev/math/big#Int
var v Int
v.SetUint64(42)
sender.
		Table("trades").
		Long256Column("value", v).
		AtNow(ctx)
In the latter case we have to return an error on an attempt to insert a negative value (that's because long256 is an unsigned type) and also have a boundary check
math/big Int is probably more user-friendly. It will also simplify serialization code as you could use https://pkg.go.dev/math/big#Int.Append
Please let me know if you have further questions.
u

Utkarsh Chourasia

12/11/2022, 10:40 AM
Hi, I have implemented the
Long256Column()
. Currently the tests are not passing for some reason, Can you guide me on this a little? https://github.com/JammUtkarsh/go-questdb-client/blob/add-long256/sender_test.go#L188
a

Andrey Pechkurov

12/12/2022, 7:37 AM
Hi Utkarsh, Let me take a look.
The test fails since the expected value doesn't match the actual one.
Also,
123i
is the format of 64-bit integer columns (
long
type). Long256 columns use a different format: https://questdb.io/docs/reference/api/ilp/columnset-types/#long256
One more thing to mention: the test you've added uses a mocked server. Would be great if you could also add a test with a real server to make sure that the data is in a proper format. Such tests are in the
sender_integration_test.go
file.
u

Utkarsh Chourasia

12/12/2022, 9:28 AM
Okay, I’ll fix the formatting and add integration tests as well soon. Also, if you could tell me, are there any other changes you would recommend especially in test?
a

Andrey Pechkurov

12/12/2022, 10:04 AM
We need some validation for the
<http://big.Int|big.Int>
sign (positive numbers only) and boundaries (a long256 is 256 bits). Tests should cover those. As for
<http://big.Int|big.Int>
values vs pointers, I'd better accept a pointer, not a struct in the
Long256Column
method. That's because the docs mention that shallow copies of `big.Int`s are not supported and may lead to errors. Finally, a nit: I'd better rename
buffer.WriteLong
into
buffer.WriteBitInt
and also accept a pointer there.