mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #55871 from Algunenano/predicate_pushdown
Disable predicate pushdown if the CTE contains stateful functions
This commit is contained in:
commit
3d0631a37d
@ -166,7 +166,7 @@ static void getConjunctionHashesFrom(const ASTPtr & ast, std::set<IAST::Hash> &
|
||||
bool PredicateRewriteVisitorData::rewriteSubquery(ASTSelectQuery & subquery, const Names & inner_columns)
|
||||
{
|
||||
if ((!optimize_final && subquery.final())
|
||||
|| (!optimize_with && subquery.with())
|
||||
|| (subquery.with() && (!optimize_with || hasNonRewritableFunction(subquery.with(), getContext())))
|
||||
|| subquery.withFill()
|
||||
|| subquery.limitBy() || subquery.limitLength() || subquery.limitByLength() || subquery.limitByOffset()
|
||||
|| hasNonRewritableFunction(subquery.select(), getContext())
|
||||
|
@ -0,0 +1 @@
|
||||
558
|
@ -0,0 +1,20 @@
|
||||
CREATE TABLE t
|
||||
(
|
||||
`rDate` String,
|
||||
`cpu_total` Int64
|
||||
)
|
||||
ENGINE = Log;
|
||||
|
||||
insert into t values ('2022-03-06', 22442 ), ('2022-03-05', 22382 ), ('2022-03-04', 22395 ), ('2022-03-03', 22306 ), ('2022-03-02', 22095 ), ('2022-03-01', 22065 ), ('2022-02-28', 21949 ), ('2022-02-27', 21884 ), ('2022-02-26', 21875 ), ('2022-02-25', 21858 ), ('2022-02-24', 21775 ), ('2022-02-23', 21639 ), ('2022-02-22', 21557 ), ('2022-02-21', 21381 ), ('2022-02-20', 21794 ), ('2022-02-19', 21808 ), ('2022-02-18', 21695 ), ('2022-02-17', 20874 ), ('2022-02-16', 20911 ), ('2022-02-15', 20898 ), ('2022-02-14', 20768 ), ('2022-02-13', 20588 ), ('2022-02-12', 20516 ), ('2022-02-11', 20501 ), ('2022-02-10', 20429 ), ('2022-02-09', 20208 ), ('2022-02-08', 20186 ), ('2022-02-07', 20192 ), ('2022-02-06', 20192 ), ('2022-02-05', 20175 ), ('2022-02-04', 20191 ), ('2022-02-03', 20214 ), ('2022-02-02', 20215 ), ('2022-02-01', 20220 ), ('2022-01-31', 20146 ), ('2022-01-30', 20137 ), ('2022-01-29', 20162 ), ('2022-01-28', 20164 ), ('2022-01-27', 20128 ), ('2022-01-26', 20139 ), ('2022-01-25', 20000 ), ('2022-01-24', 19778 ), ('2022-01-23', 19789 ), ('2022-01-22', 19628 ), ('2022-01-21', 19631 ), ('2022-01-20', 19386 ), ('2022-01-19', 19439 ), ('2022-01-18', 19477 ), ('2022-01-17', 19386 ), ('2022-01-16', 20013 ), ('2022-01-15', 19359 ), ('2022-01-14', 19356 ), ('2022-01-13', 19300 ), ('2022-01-12', 19237 ), ('2022-01-11', 19159 ), ('2022-01-10', 18970 ), ('2022-01-09', 18804 ), ('2022-01-08', 18816 ), ('2022-01-07', 18808 ), ('2022-01-06', 18693 ), ('2022-01-05', 18639 ), ('2022-01-04', 18579 ), ('2022-01-03', 18450 ), ('2022-01-02', 18458 ), ('2022-01-01', 18445 ), ('2021-12-31', 18443 ), ('2021-12-30', 18388 ), ('2021-12-29', 18348 ), ('2021-12-28', 18042 ), ('2021-12-26', 18049 ), ('2021-12-22', 17962 );
|
||||
|
||||
SELECT cpu_total_week
|
||||
FROM
|
||||
(
|
||||
WITH neighbor(cpu_total, 7) AS cpu_total_7
|
||||
SELECT
|
||||
rDate,
|
||||
floor(multiIf(cpu_total_7 = 0, 0, cpu_total - cpu_total_7), 2) AS cpu_total_week
|
||||
FROM t
|
||||
) AS t_table_471873
|
||||
WHERE (rDate >= '2022-03-06') AND (rDate <= '2022-03-06')
|
||||
SETTINGS enable_optimize_predicate_expression = 1;
|
Loading…
Reference in New Issue
Block a user