Cat with --multiquery 在创建数据并将数据插入临时 table clickhouse 时不起作用
Cat with --multiquery is not working when creating and inserting data into Temporary table clickhouse
我运行使用一个会话进行多个查询。我必须创建一个 Temporary table 然后我必须将数据从 CSV 插入到该文件,然后我必须将数据插入到 Permanent table。我必须在一个会话中 运行 所有这些查询。但我收到一个错误。这是我的查询:
cat ./files/File.txt | clickhouse-client --multiquery --format_csv_delimiter="," --query="CREATE TEMPORARY TABLE IF NOT EXISTS temp_table(col0 String,col1 String,col2 String,col3 String) ; INSERT INTO temp_table FORMAT CSV ; INSERT INTO prmanent_table(person_1,person_2,timestamp_,duration) select col0 as person_1,col1 as person_2,col2 as timestamp_,col3 as duration from temp_table ; "
错误
Code: 117. DB::Exception: Expected end of line: (at row 1)
Row 1:
Column 0, name: col0, type: String, parsed text: "; INSERT INTO prmanent_table(person_1"
Column 1, name: col1, type: String, parsed text: "person_2"
Column 2, name: col2, type: String, parsed text: "timestamp_"
Column 3, name: col3, type: String, parsed text: "duration) select col0 as person_1"
ERROR: There is no line feed. "c" found instead.
It's like your file has more columns than expected.
And if your file have right number of columns, maybe it have unquoted string value with comma.```
使用FROM INFILE
INSERT INTO TABLE temp_table FROM INFILE './files/File.txt' format CSV;
我运行使用一个会话进行多个查询。我必须创建一个 Temporary table 然后我必须将数据从 CSV 插入到该文件,然后我必须将数据插入到 Permanent table。我必须在一个会话中 运行 所有这些查询。但我收到一个错误。这是我的查询:
cat ./files/File.txt | clickhouse-client --multiquery --format_csv_delimiter="," --query="CREATE TEMPORARY TABLE IF NOT EXISTS temp_table(col0 String,col1 String,col2 String,col3 String) ; INSERT INTO temp_table FORMAT CSV ; INSERT INTO prmanent_table(person_1,person_2,timestamp_,duration) select col0 as person_1,col1 as person_2,col2 as timestamp_,col3 as duration from temp_table ; "
错误
Code: 117. DB::Exception: Expected end of line: (at row 1)
Row 1:
Column 0, name: col0, type: String, parsed text: "; INSERT INTO prmanent_table(person_1"
Column 1, name: col1, type: String, parsed text: "person_2"
Column 2, name: col2, type: String, parsed text: "timestamp_"
Column 3, name: col3, type: String, parsed text: "duration) select col0 as person_1"
ERROR: There is no line feed. "c" found instead.
It's like your file has more columns than expected.
And if your file have right number of columns, maybe it have unquoted string value with comma.```
使用FROM INFILE
INSERT INTO TABLE temp_table FROM INFILE './files/File.txt' format CSV;