Shriram Sunder

08/16/2022, 8:55 PM
Hey team, just a quick question for whoever is awake, I'm trying to push some data into a table (that's not been created yet, let's call it 'aggs' for aggregate data). As I'm inserting this data, I'm getting the following error:
panic: table name already provided: invalid message
This is the code that does the insertion... am I doing anything wrong? It works exactly as expected when I used the exact same code for another table to insert all the tickers info.
sender, _ := QDBConnectILP(ctx)
	defer sender.Close()
    // For each of these results, push!
	for _, agg := range aggBar.Results {
		err := sender.Table("aggs").
			Symbol("ticker", aggBar.Ticker).
			StringColumn("timespan", timespan).
			Int64Column("multiplier", int64(multiplier)).
			Float64Column("timestamp", agg.T).
			Float64Column("open", agg.O).
			Float64Column("high", agg.H).
			Float64Column("low", agg.L).
			Float64Column("close", agg.C).
			Float64Column("volume", agg.V).
			Float64Column("vw", agg.Vw).
			Float64Column("n", float64(agg.N)).
			At(ctx, time.Now().UnixNano())

	// Make sure that the messages are sent over the network.
	err = sender.Flush(ctx)

Bolek Ziobrowski

08/17/2022, 7:14 AM
Hi @Shriram Sunder . I think it happens when table is specified twice for a row . Please have a look at https://github.com/questdb/go-questdb-client/blob/41ae846db01e4aca1f767fffe92d690fc25bab11/sender_test.go :
func TestErrorOnMultipleTableCalls(t *testing.T) {
	ctx := context.Background()

	srv, err := newTestServer(readAndDiscard)
	assert.NoError(t, err)
	defer srv.close()

	sender, err := qdb.NewLineSender(ctx, qdb.WithAddress(srv.addr))
	assert.NoError(t, err)
	defer sender.Close()

	err = sender.Table(testTable).Table(testTable).AtNow(ctx)

	assert.ErrorContains(t, err, "table name already provided")
	assert.Empty(t, sender.Messages())

Andrey Pechkurov

08/17/2022, 8:32 AM
Hi Shriram, Your snippet looks ok to me. Are you sure that you're observing the error with this code? If so, could you create a GH issue with a minimal reproducer? https://github.com/questdb/go-questdb-client/issues/new

Shriram Sunder

08/19/2022, 2:36 AM
Hey @Andrey Pechkurov, The error magically disappeared when I explicitly closed the sender instead of
defer sender.Close()
at the beginning. I don't really see how I can minimally reproduce this error on GH, this requires connecting to an existing QuestDB instance.

Andrey Pechkurov

08/19/2022, 5:29 AM
when I explicitly closed the sender instead of defer sender.Close() at the beginning
That's weird.
defer sender.Close()
acts as if you had
at all return points of your function
And it shouldn't affect sender's behavior

Shriram Sunder

09/04/2022, 7:58 PM
I understand how
defer sender.close()
works, I'm just describing a behaviour that I encountered. I admit it's weird, but ... that's what worked. I'm developing on a Windows system, if that makes any difference.

Andrey Pechkurov

09/05/2022, 6:13 AM
No, Windows shouldn't make any difference. If you have a reproducer snippet, please open a GH issue: https://github.com/questdb/go-questdb-client/issues/new