Commit Graph

65 Commits

Author SHA1 Message Date
zhongyuankai
5ccc5b4fd8 batter 2023-12-16 18:49:25 +08:00
zhongyuankai
01f5b20517 Support ORDER BY ALL 2023-12-16 18:48:23 +08:00
Robert Schulze
8ad124ef64
Fix #56258, attempt II 2023-11-10 14:03:13 +00:00
Dmitry Novik
3488a4d84b Improve file includes 2023-03-24 03:44:52 +01:00
Robert Schulze
c668ddd506
Make ASTSelectQuery::formatImpl() more robust
Fixes #45204

The problem is that ASTSelectQuery::group_by_with_grouping_sets == true
implies ASTSelectQuery::groupBy() but sometimes this wasn't the case. I
added a sanity check a few months ago but had no idea how the AST became
corrupt.

All crashes/exceptions were during AST fuzzing. Looking at
Client/QueryFuzzer.cpp, there is a very small chance to run into the
issue. In detail:

1. In QueryFuzzer::fuzz(), we find that the AST is a ASTSelectQuery and
   groupBy() returns true.

2. With small probability, we do
     select->group_by_with_grouping_sets = !select->group_by_with_grouping_sets;
   where the (default false) group_by_with_grouping_sets flips true.

3. With small probability, we change the expression type in the
   following WHERE or PREWHERE if-branches.

This situation is illegal. One possibility is changing the fuzzing code
to not generate it. The fuzzing code is however generic, and doesn't
really care about such details. Therefore, instead add an (theoretically
unnecessary) extra check to ASTSelectQuery::formatImpl() for robustness.
2023-02-25 22:28:00 +00:00
Alexander Tokmakov
70d1adfe4b
Better formatting for exception messages (#45449)
* save format string for NetException

* format exceptions

* format exceptions 2

* format exceptions 3

* format exceptions 4

* format exceptions 5

* format exceptions 6

* fix

* format exceptions 7

* format exceptions 8

* Update MergeTreeIndexGin.cpp

* Update AggregateFunctionMap.cpp

* Update AggregateFunctionMap.cpp

* fix
2023-01-24 00:13:58 +03:00
Kseniia Sumarokova
db3e0219fc
Merge pull request #41687 from ClickHouse/40907_Parameterized_views_as_table_functions
40907 Parameterized views as table functions
2023-01-12 14:24:32 +01:00
Robert Schulze
4c03ccf99b
Sanity check that the SelectAST isn't corrupt 2023-01-02 12:06:18 +00:00
Robert Schulze
db90214c0b
Make ASTSelectQuery::formatImpl() more robust
Fixes #43049
2022-12-21 10:52:49 +00:00
Smita Kulkarni
dd8df3347b Addressed style review comments and removed bool variables assignment from Clone of ASTs - 40907 Parameterized views as table functions 2022-12-16 11:11:19 +01:00
Smita Kulkarni
953e1068b5 Merge branch 'master' into 40907_Parameterized_views_as_table_functions 2022-11-28 19:10:32 +01:00
Smita Kulkarni
3e5f1a9178 Added is_parameterized_view in ASTFunction and fixed review comments - 40907 Parameterized views as table functions 2022-11-07 15:22:45 +01:00
taofengliu
d03cf4731d parser format 2022-11-05 17:22:41 +08:00
Smita Kulkarni
1dde95b6e7 Updated hasQueryParameters using mutable optional bool and typo comment fixed - 40907 Parameterized views as table functions 2022-10-20 10:31:41 +02:00
Smita Kulkarni
e4ac3d0e18 Added FunctionParameterValuesVisitor, renamed bool to is_create_parameterized_view, added checks for parameterized view and support & test to propagate query parameters - 40907 Parameterized views as table functions 2022-10-19 18:30:03 +02:00
taofengliu
46739eeaf8 support GROUP BY ALL 2022-10-18 10:46:37 +08:00
Smita Kulkarni
614fd4cf42 Added is_parameterized_view to Context and removed flag from ASTs, updated to use tryGetTable, addressed review comments - 40907 Parameterized views as table functions 2022-10-17 18:11:22 +02:00
Smita Kulkarni
7033a56ff2 Moved QueryParameterVisitor to Parsers & EXPLAIN SYNTAX test fix - 40907 Parameterized views as table functions 2022-10-03 16:42:44 +02:00
Smita Kulkarni
e5c0c6a1b6 Addressed review comments - 40907 Parameterized views as table functions
Implementation
* Updated handling of has_query_parameters to avoid recalculation.
* Fixed style comments
* Updated formatImpl of ASTTableExpression to prioritise table_function before sub_query.
Testing:
* Added test for ATTACH, DETACH, INSERT INTO view and EXPLAIN SYNTAX to tests/queries/0_stateless/02428_parameterized_view.sql
2022-10-03 14:27:38 +02:00
Smita Kulkarni
a12d2fcf44 Updated ASTSelectQuery to fix FastTest fails for 40907 Parameterized views as table functions 2022-09-27 22:13:20 +02:00
Smita Kulkarni
bbc33a54b2 Addressed review comments - 40907 Parameterized views as table functions
Implementation
* Fix for clang-today build fails - updated to use const in Context.cpp & const function in ActionsVisitior.cpp
* Updated to use QueryParameterVisitor to check if query has query parameters
* Updated executeTableFunction to check if table/table exists instead of try-catch approach
* Fixed small review comments and style comments.
Documentation:
* Addressed review comments and added the LIVE view part which was removed by mistake in the previous commits.
2022-09-27 16:30:59 +02:00
Smita Kulkarni
4fb1dffb9e 40907 Parameterized views as table functions
Implementation
* Fix for clang-today build fails - updated to use const reference in ASTSelectQuery.cpp & ASTSelectWithUnionQuery.cpp
2022-09-26 13:08:54 +02:00
Smita Kulkarni
4d414b69b8 40907 Parameterized views as table functions
Implementation
* Fix for clang-today build fails - updated to use const reference in ASTSelectQuery.cpp
2022-09-26 10:30:28 +02:00
Smita Kulkarni
456baddbc7 40907 Parameterized views as table functions
Implementation
* Fix for Build fails - updated conversion of Field to String and includes
2022-09-24 12:01:18 +02:00
Smita Kulkarni
f801772a86 40907 Parameterized views as table functions
Implementation:
* Updated parsers by adding a bool allow_query_parameters while creating ordinary view, which is used in interpreters to allow query parameters in SELECT.
* Added a check in ActionsVisitor if multiple parameters have same names while creating parameterised view.
* Added bool in StorageView to represent parameterized view.
* Updated processing of SELECT with parameter values to check for views and added substitution of values in the query parameters.

Testing:
* Added a test tests/queries/0_stateless/02428_parameterized_view.sql

Documentation:
* Updated the english documentation for VIEW.
2022-09-23 14:04:43 +02:00
Raúl Marín
f814908364 Improvements based on comments from the PR 2022-08-22 17:39:33 +02:00
Raúl Marín
e2e4b0b925 Merge remote-tracking branch 'blessed/master' into avoid_printing_settings 2022-08-10 16:43:52 +02:00
Maksim Kita
3e6b663020 ASTSelectQuery added hasJoin method 2022-08-03 11:25:45 +02:00
Raúl Marín
dfc20266c7 Avoid printing SETTINGS twice when formatting a query 2022-07-06 14:06:04 +02:00
Dmitry Novik
5128afb0b7 Do not prepend whitespace in grouping sets 2022-05-13 16:14:41 +00:00
Dmitry Novik
fb5766287c Cleanup GROUPING SETS formating 2022-05-13 16:14:41 +00:00
Dmitry Novik
61deae7105
Merge branch 'master' into grouping-sets-fix 2022-04-21 03:34:42 +02:00
Robert Schulze
118e94523c
Activate clang-tidy warning "readability-container-contains"
This check suggests replacing <Container>.count() by
<Container>.contains() which is more speaking and in case of
multimaps/multisets also faster.
2022-04-18 23:53:11 +02:00
Dmitry Novik
a16710c750 Merge remote-tracking branch 'origin/master' into grouping-sets-fix 2022-04-14 17:29:51 +00:00
Yakov Olkhovskiy
ac441b9dcf compiler suggestions 2022-04-06 00:05:06 -04:00
Yakov Olkhovskiy
e0d6033c39 all columns can participate in interpolate expression despite if they are selected or not, some optimization on expressionless INTERPOLATE 2022-04-05 14:26:49 -04:00
Yakov Olkhovskiy
a8e1671a76 type match check for INTERPOLATE expressions added, bugfix, printout fixed 2022-03-18 16:44:27 -04:00
Dmitry Novik
67df01d025
Merge branch 'master' into grouping-sets-fix 2022-02-22 04:18:03 -08:00
Raúl Marín
045c92e2b9 Fix readability issues 2022-01-26 17:36:45 +01:00
Raúl Marín
4b5ab80e3b Better scalar cache handling
- Fixes global CTE scalar cache.
- Adds MVs back (views dependent on the source are cached locally and others globally
2022-01-26 17:36:45 +01:00
Dmitry Novik
e957054409 fix GROUPING SETS formating 2022-01-11 11:26:13 +00:00
fanzhou
6c6d3015de 1. refactor ExpressionAnalyzer
2. Update formatAST to support grouping sets query with distributed table
3. modify astExpression to support function in grouping sets
2022-01-11 11:26:12 +00:00
MaxTheHuman
a8f4f3d6b0 init commit with parsing and BAD realisation 2022-01-11 11:26:09 +00:00
alexey-milovidov
0a55fa3dc2
Revert "Grouping sets dev" 2021-12-25 20:30:31 +03:00
Dmitry Novik
f138122259 fix GROUPING SETS formating 2021-12-07 16:44:09 +03:00
fanzhou
b94f8878ff 1. refactor ExpressionAnalyzer
2. Update formatAST to support grouping sets query with distributed table
3. modify astExpression to support function in grouping sets
2021-11-30 14:58:55 +03:00
MaxTheHuman
8b95b7d271 init commit with parsing and BAD realisation 2021-11-23 17:58:16 +03:00
vdimir
e8e26463bf
Change signature of ASTSelectQuery::arrayJoinExpressionList 2021-08-31 15:27:44 +03:00
tavplubix
cd311e2e87
Update ASTSelectQuery.cpp 2021-06-30 12:41:46 +03:00
Alexander Tokmakov
fd914f3d97 fix 'Not found column' error in MaterializeMySQL 2021-06-29 20:47:41 +03:00