dbr icon indicating copy to clipboard operation
dbr copied to clipboard

Wrong placeholder count error on INSERT ... FORMAT CSV

Open dizzyfool opened this issue 5 years ago • 0 comments

Here's the case.

Prepare some db and test if it's working:

create table test (
     date DateTime,
     event String
) engine MergeTree() order by date;

insert into test format CSV
2021-01-01 00:00:00,click
2021-01-01 00:00:00,?

select * from test;

Run go code:

func TestIssue(t *testing.T) {
	conn, _ := dbr.Open("clickhouse", "http://user:pass@localhost:8123/db", nil)

	query := `insert into test (date, event) format CSV
2021-01-01 00:00:00,click
2021-01-01 00:00:00,?`

	_, err := conn.Exec(query)
	fmt.Println(err) //clickhouse: wrong placeholder count

	query = `insert into test (date, event) format CSV
"2021-01-01 00:00:00","click"
"2021-01-01 00:00:00","?"`

	_, err = conn.Exec(query)
	fmt.Println(err) //clickhouse: wrong placeholder count
}

I expect to get no errors here, because every query I run is perfectly valid.

dizzyfool avatar Mar 30 '21 09:03 dizzyfool