Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File data insert using CSVWithNames is failing since v0.3.2-patch10 #1072

Closed
rsim opened this issue Sep 8, 2022 · 6 comments · Fixed by #1073
Closed

File data insert using CSVWithNames is failing since v0.3.2-patch10 #1072

rsim opened this issue Sep 8, 2022 · 6 comments · Fixed by #1073
Labels
Milestone

Comments

@rsim
Copy link

rsim commented Sep 8, 2022

We are using ClickHouse JDBC driver to import CSV files that include a header line with column names. Here is the JRuby code that we use https:/rsim/mondrian-olap/blob/master/spec/rake_tasks.rb#L377-L380

conn.jdbc_connection.createStatement.write.
  query("INSERT INTO #{table_name}(#{columns_string})").
  format(Java::com.clickhouse.client.ClickHouseFormat::CSVWithNames).
  data(file_path).send

It was working until the version v0.3.2-patch9 but since the version v0.3.2-patch10 it is failing with:

Java::JavaUtilConcurrent::CompletionException: com.clickhouse.client.ClickHouseException: Code: 27. DB::ParsingException: Cannot parse input: expected ',' before: 'id,the_date,the_day,the_month,the_year,day_of_month,week_of_year,month_of_year,quarter\n1,2010-01-01 02:00:00,Friday,January,2010,1,0,1,Q1\n2,2010-01-02 02:00:00,':
Row 1:
Column 0,   name: id,            type: Int32,    ERROR: text "id,the_dat" is not like Int32

: While executing ParallelParsingBlockInputFormat: (at row 1)
. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 22.1.4.1)
, server ClickHouseNode [uri=http://localhost:8123/mondrian_test]com.clickhouse.client.ClickHouseClientBuilder$Agent.handle(com/clickhouse/client/ClickHouseClientBuilder.java:181)
com.clickhouse.client.ClickHouseClientBuilder$Agent.send(com/clickhouse/client/ClickHouseClientBuilder.java:204)
com.clickhouse.client.ClickHouseClientBuilder$Agent.execute(com/clickhouse/client/ClickHouseClientBuilder.java:234)
com.clickhouse.client.ClickHouseRequest$Mutation.execute(com/clickhouse/client/ClickHouseRequest.java:241)
com.clickhouse.client.ClickHouseRequest$Mutation.send(com/clickhouse/client/ClickHouseRequest.java:292)
java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)

It seems that now the CSV format (without the header line) is used instead of CSVWithNames and it complains about the first file line with column headers.

I was browsing the changes between patch9 and patch10 but couldn't identify so far which change could be causing this.

@rsim
Copy link
Author

rsim commented Sep 8, 2022

I found with git bisect that this commit 75ddd37 (with many different changes, the corresponding pull request #956) broke this.
/cc @zhicwu

@zhicwu
Copy link
Contributor

zhicwu commented Sep 8, 2022

Hi @rsim, thanks for the report and sorry for the inconvenience. There's a bad assumption forcing insert to use headless data format, which works for some formats like RowBinary but apparently not others. Will try to fix it today.

@zhicwu zhicwu added the bug label Sep 8, 2022
@zhicwu zhicwu linked a pull request Sep 9, 2022 that will close this issue
@rsim
Copy link
Author

rsim commented Sep 12, 2022

@zhicwu I built the JDBC driver from the latest develop branch and tested it. I still get the same error with it:

Java::JavaUtilConcurrent::CompletionException: com.clickhouse.client.ClickHouseException: Code: 27. DB::ParsingException: Cannot parse input: expected ',' before: 'id,the_date,the_day,the_month,the_year,day_of_month,week_of_year,month_of_year,quarter\n1,2010-01-01 02:00:00,Friday,January,2010,1,0,1,Q1\n2,2010-01-02 02:00:00,':
Row 1:
Column 0,   name: id,            type: Int32,    ERROR: text "id,the_dat" is not like Int32

: While executing ParallelParsingBlockInputFormat: (at row 1)
. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 22.1.4.1)
, server ClickHouseNode [uri=http://localhost:8123/mondrian_test]@-1740047039com.clickhouse.client.ClickHouseClientBuilder$Agent.handle(com/clickhouse/client/ClickHouseClientBuilder.java:274)
com.clickhouse.client.ClickHouseClientBuilder$Agent.send(com/clickhouse/client/ClickHouseClientBuilder.java:298)
com.clickhouse.client.ClickHouseClientBuilder$Agent.execute(com/clickhouse/client/ClickHouseClientBuilder.java:351)
com.clickhouse.client.ClickHouseRequest$Mutation.execute(com/clickhouse/client/ClickHouseRequest.java:272)
com.clickhouse.client.ClickHouseRequest$Mutation.send(com/clickhouse/client/ClickHouseRequest.java:326)

@zhicwu
Copy link
Contributor

zhicwu commented Sep 12, 2022

@rsim
Copy link
Author

rsim commented Sep 12, 2022

@zhicwu I just built the driver with this fix from the develop branch and tested that now this bug is fixed.
Thank you.

@zhicwu
Copy link
Contributor

zhicwu commented Sep 12, 2022

Thanks for confirming. You can download nightly build here after 4pm UTC today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants