我正在尝试使用clickhouse中的表函数文件,下面是我尝试过的。
的背景:测试sql:
create table test(a String,b Int32) ENGINE = Memory;--File(CSV)
insert into test (a,b) values ('world',22) ('quant',33);
insert into test (a,b) values ('hello',1);
select * from test;
SELECT a,b FROM test FORMAT Template SETTINGS format_template_resultset = '/home/resultset.format', format_template_row = '/home/row.format', format_template_rows_between_delimiter = 'n';
打印:
head
the first:"world",the second:22;
the first:"quant",the second:33;
the first:"hello",the second:1;
end
sql:
SELECT * FROM file("data",Template SETTINGS format_template_resultset = '/home/resultset.format', format_template_row = '/home/row.format', format_template_rows_between_delimiter = 'n', 'a String, b Int32');
打印:
Syntax error: failed at position 36 ('SETTINGS'):
SELECT * FROM file("data",Template SETTINGS format_template_resultset = '/home/resultset.format', format_template_row = '/home/row.format', format_template_rows_between_delimiter = 'n', 'a String, b Int32');
Expected one of: DoubleColon, LIKE, GLOBAL NOT IN, end of query, AS, DIV, IS, UUID, OR, QuestionMark, BETWEEN, NOT LIKE, MOD, AND, Comma, alias, IN, ILIKE, Dot, NOT ILIKE, NOT, Arrow, token, NOT IN, GLOBAL IN
我已经检查了文档,但它似乎不正确。我怎样才能做到这一点呢?
@vladimir的答案是正确的,
SELECT * FROM file("data",Template, 'a String, b Int32') SETTINGS format_template_resultset = '/home/resultset.format', format_template_row = '/home/row.format', format_template_rows_between_delimiter = 'n';
谢谢。