1 | #include <iostream> |
2 | |
3 | #include <Parsers/ParserQueryWithOutput.h> |
4 | #include <Parsers/parseQuery.h> |
5 | #include <Parsers/formatAST.h> |
6 | |
7 | |
8 | int main(int, char **) |
9 | try |
10 | { |
11 | using namespace DB; |
12 | |
13 | std::string input = |
14 | " SELECT 18446744073709551615, f(1), '\\\\', [a, b, c], (a, b, c), 1 + 2 * -3, a = b OR c > d.1 + 2 * -g[0] AND NOT e < f * (x + y)" |
15 | " FROM default.hits" |
16 | " WHERE CounterID = 101500 AND UniqID % 3 = 0" |
17 | " GROUP BY UniqID" |
18 | " HAVING SUM(Refresh) > 100" |
19 | " ORDER BY Visits, PageViews" |
20 | " LIMIT LENGTH('STRING OF 20 SYMBOLS') - 20 + 1000, 10.05 / 5.025 * 5" |
21 | " INTO OUTFILE 'test.out'" |
22 | " FORMAT TabSeparated" ; |
23 | |
24 | ParserQueryWithOutput parser; |
25 | ASTPtr ast = parseQuery(parser, input.data(), input.data() + input.size(), "" , 0); |
26 | |
27 | std::cout << "Success." << std::endl; |
28 | formatAST(*ast, std::cerr); |
29 | std::cout << std::endl; |
30 | |
31 | return 0; |
32 | } |
33 | catch (...) |
34 | { |
35 | std::cerr << DB::getCurrentExceptionMessage(true) << "\n" ; |
36 | return 1; |
37 | } |
38 | |