mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Always modify subqueries if modifying inplace
to support push-down while analyzing.
This commit is contained in:
parent
fa273bb73b
commit
c8eefb3927
@ -51,10 +51,6 @@ set(SRCS
|
|||||||
${RDKAFKA_SOURCE_DIR}/snappy.c
|
${RDKAFKA_SOURCE_DIR}/snappy.c
|
||||||
${RDKAFKA_SOURCE_DIR}/tinycthread.c
|
${RDKAFKA_SOURCE_DIR}/tinycthread.c
|
||||||
${RDKAFKA_SOURCE_DIR}/tinycthread_extra.c
|
${RDKAFKA_SOURCE_DIR}/tinycthread_extra.c
|
||||||
#${RDKAFKA_SOURCE_DIR}/xxhash.c
|
|
||||||
#${RDKAFKA_SOURCE_DIR}/lz4.c
|
|
||||||
#${RDKAFKA_SOURCE_DIR}/lz4frame.c
|
|
||||||
#${RDKAFKA_SOURCE_DIR}/lz4hc.c
|
|
||||||
${RDKAFKA_SOURCE_DIR}/rdgz.c
|
${RDKAFKA_SOURCE_DIR}/rdgz.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -223,16 +223,23 @@ InterpreterSelectQuery::InterpreterSelectQuery(
|
|||||||
for (const auto & it : query_analyzer->getExternalTables())
|
for (const auto & it : query_analyzer->getExternalTables())
|
||||||
if (!context.tryGetExternalTable(it.first))
|
if (!context.tryGetExternalTable(it.first))
|
||||||
context.addExternalTable(it.first, it.second);
|
context.addExternalTable(it.first, it.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!only_analyze || modify_inplace)
|
||||||
|
{
|
||||||
if (query_analyzer->isRewriteSubqueriesPredicate())
|
if (query_analyzer->isRewriteSubqueriesPredicate())
|
||||||
{
|
{
|
||||||
/// remake interpreter_subquery when PredicateOptimizer is rewrite subqueries and main table is subquery
|
/// remake interpreter_subquery when PredicateOptimizer is rewrite subqueries and main table is subquery
|
||||||
if (is_subquery)
|
if (is_subquery)
|
||||||
interpreter_subquery = std::make_unique<InterpreterSelectWithUnionQuery>(
|
interpreter_subquery = std::make_unique<InterpreterSelectWithUnionQuery>(
|
||||||
table_expression, getSubqueryContext(context), required_columns, QueryProcessingStage::Complete, subquery_depth + 1,
|
table_expression,
|
||||||
only_analyze);
|
getSubqueryContext(context),
|
||||||
|
required_columns,
|
||||||
|
QueryProcessingStage::Complete,
|
||||||
|
subquery_depth + 1,
|
||||||
|
only_analyze,
|
||||||
|
modify_inplace);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interpreter_subquery)
|
if (interpreter_subquery)
|
||||||
|
@ -277,10 +277,10 @@ def main(args):
|
|||||||
report_testcase.append(skipped)
|
report_testcase.append(skipped)
|
||||||
print("{0} - no reference file".format(MSG_UNKNOWN))
|
print("{0} - no reference file".format(MSG_UNKNOWN))
|
||||||
else:
|
else:
|
||||||
result_is_different = subprocess.call(['diff', '-q', '-bEZ', reference_file, stdout_file], stdout = PIPE)
|
result_is_different = subprocess.call(['diff', '-q', reference_file, stdout_file], stdout = PIPE)
|
||||||
|
|
||||||
if result_is_different:
|
if result_is_different:
|
||||||
diff = Popen(['diff', '--unified', '-bEZ', reference_file, stdout_file], stdout = PIPE).communicate()[0]
|
diff = Popen(['diff', '--unified', reference_file, stdout_file], stdout = PIPE).communicate()[0]
|
||||||
diff = unicode(diff, errors='replace', encoding='utf-8')
|
diff = unicode(diff, errors='replace', encoding='utf-8')
|
||||||
cat = Popen(['cat', '-A'], stdin=PIPE, stdout=PIPE).communicate(input=diff)[0]
|
cat = Popen(['cat', '-A'], stdin=PIPE, stdout=PIPE).communicate(input=diff)[0]
|
||||||
|
|
||||||
|
@ -24,17 +24,17 @@ SELECT \n a, \n b\nFROM \n(\n SELECT \n toUInt64(sum(id) AS b) A
|
|||||||
3 3
|
3 3
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n ) \n WHERE id = 1\n) \nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n ) \n WHERE id = 1\n) \nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n ) AS b \n WHERE id = 1\n) \nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n ) AS b \n WHERE id = 1\n) \nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n ) \n WHERE id = 1\n) \nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n ) \n WHERE id = 1\n) \nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) AS b \nWHERE b.id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) AS b \nWHERE b.id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n ) AS a \n WHERE id = 1\n) AS b \nWHERE b.id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n ) AS a \n WHERE id = 1\n) AS b \nWHERE b.id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n id, \n date, \n value\nFROM \n(\n SELECT \n id, \n date, \n min(value) AS value\n FROM test.test \n WHERE id = 1\n GROUP BY \n id, \n date\n) \nWHERE id = 1
|
SELECT \n id, \n date, \n value\nFROM \n(\n SELECT \n id, \n date, \n min(value) AS value\n FROM test.test \n WHERE id = 1\n GROUP BY \n id, \n date\n) \nWHERE id = 1
|
||||||
1 2000-01-01 1
|
1 2000-01-01 1
|
||||||
@ -43,7 +43,7 @@ SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n
|
|||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE id = 1\n) USING (id)\nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE id = 1\n) USING (id)\nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
|
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n ) \n ANY LEFT JOIN \n (\n SELECT *\n FROM test.test \n ) USING (id)\n WHERE id = 1\n) \nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n ) \n ANY LEFT JOIN \n (\n SELECT *\n FROM test.test \n WHERE id = 1\n ) USING (id)\n WHERE id = 1\n) \nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value, \n `b.date`, \n `b.name`, \n `b.value`\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE id = 1\n) AS b USING (id)\nWHERE b.id = 1
|
SELECT \n date, \n id, \n name, \n value, \n `b.date`, \n `b.name`, \n `b.value`\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE id = 1\n) AS b USING (id)\nWHERE b.id = 1
|
||||||
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
|
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
|
||||||
|
@ -54,12 +54,10 @@ ANALYZE SELECT * FROM (SELECT * FROM test.test) WHERE id = 1;
|
|||||||
SELECT * FROM (SELECT * FROM test.test) WHERE id = 1;
|
SELECT * FROM (SELECT * FROM test.test) WHERE id = 1;
|
||||||
|
|
||||||
-- Optimize predicate expression with asterisk and nested subquery
|
-- Optimize predicate expression with asterisk and nested subquery
|
||||||
-- FIXME: should be pushed down to the innermost subquery
|
|
||||||
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test)) WHERE id = 1;
|
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test)) WHERE id = 1;
|
||||||
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test)) WHERE id = 1;
|
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test)) WHERE id = 1;
|
||||||
|
|
||||||
-- Optimize predicate expression with qualified asterisk
|
-- Optimize predicate expression with qualified asterisk
|
||||||
-- FIXME: should be pushed down to the innermost subquery
|
|
||||||
ANALYZE SELECT * FROM (SELECT b.* FROM (SELECT * FROM test.test) AS b) WHERE id = 1;
|
ANALYZE SELECT * FROM (SELECT b.* FROM (SELECT * FROM test.test) AS b) WHERE id = 1;
|
||||||
SELECT * FROM (SELECT b.* FROM (SELECT * FROM test.test) AS b) WHERE id = 1;
|
SELECT * FROM (SELECT b.* FROM (SELECT * FROM test.test) AS b) WHERE id = 1;
|
||||||
|
|
||||||
@ -68,7 +66,6 @@ ANALYZE SELECT * FROM (SELECT date, id, name, value FROM test.test) WHERE id = 1
|
|||||||
SELECT * FROM (SELECT date, id, name, value FROM test.test) WHERE id = 1;
|
SELECT * FROM (SELECT date, id, name, value FROM test.test) WHERE id = 1;
|
||||||
|
|
||||||
-- Optimize predicate expression without asterisk and contains nested subquery
|
-- Optimize predicate expression without asterisk and contains nested subquery
|
||||||
-- FIXME: should be pushed down to the innermost subquery
|
|
||||||
ANALYZE SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test.test)) WHERE id = 1;
|
ANALYZE SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test.test)) WHERE id = 1;
|
||||||
SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test.test)) WHERE id = 1;
|
SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test.test)) WHERE id = 1;
|
||||||
|
|
||||||
@ -77,7 +74,6 @@ ANALYZE SELECT * FROM (SELECT * FROM test.test) AS b WHERE b.id = 1;
|
|||||||
SELECT * FROM (SELECT * FROM test.test) AS b WHERE b.id = 1;
|
SELECT * FROM (SELECT * FROM test.test) AS b WHERE b.id = 1;
|
||||||
|
|
||||||
-- Optimize predicate expression with qualified and nested subquery
|
-- Optimize predicate expression with qualified and nested subquery
|
||||||
-- FIXME: should be pushed down to the innermost subquery
|
|
||||||
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test) AS a) AS b WHERE b.id = 1;
|
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test) AS a) AS b WHERE b.id = 1;
|
||||||
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test) AS a) AS b WHERE b.id = 1;
|
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test) AS a) AS b WHERE b.id = 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user