mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
add scalars in time
This commit is contained in:
parent
7011401cd4
commit
d524301038
@ -309,6 +309,11 @@ InterpreterSelectQuery::InterpreterSelectQuery(
|
|||||||
query_ptr, SyntaxAnalyzerResult(source_header.getNamesAndTypesList(), storage),
|
query_ptr, SyntaxAnalyzerResult(source_header.getNamesAndTypesList(), storage),
|
||||||
options, joined_tables.tablesWithColumns(), required_result_column_names, table_join);
|
options, joined_tables.tablesWithColumns(), required_result_column_names, table_join);
|
||||||
|
|
||||||
|
/// Save scalar sub queries's results in the query context
|
||||||
|
if (!options.only_analyze && context->hasQueryContext())
|
||||||
|
for (const auto & it : syntax_analyzer_result->getScalars())
|
||||||
|
context->getQueryContext().addScalar(it.first, it.second);
|
||||||
|
|
||||||
if (view)
|
if (view)
|
||||||
{
|
{
|
||||||
/// Restore original view name. Save rewritten subquery for future usage in StorageView.
|
/// Restore original view name. Save rewritten subquery for future usage in StorageView.
|
||||||
@ -329,11 +334,6 @@ InterpreterSelectQuery::InterpreterSelectQuery(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save scalar sub queries's results in the query context
|
|
||||||
if (!options.only_analyze && context->hasQueryContext())
|
|
||||||
for (const auto & it : syntax_analyzer_result->getScalars())
|
|
||||||
context->getQueryContext().addScalar(it.first, it.second);
|
|
||||||
|
|
||||||
query_analyzer = std::make_unique<SelectQueryExpressionAnalyzer>(
|
query_analyzer = std::make_unique<SelectQueryExpressionAnalyzer>(
|
||||||
query_ptr, syntax_analyzer_result, *context,
|
query_ptr, syntax_analyzer_result, *context,
|
||||||
NameSet(required_result_column_names.begin(), required_result_column_names.end()),
|
NameSet(required_result_column_names.begin(), required_result_column_names.end()),
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
[0,3,2] id2
|
||||||
|
[3,1,2] id1
|
19
tests/queries/0_stateless/01323_add_scalars_in_time.sql
Normal file
19
tests/queries/0_stateless/01323_add_scalars_in_time.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
DROP TABLE IF EXISTS tags;
|
||||||
|
|
||||||
|
CREATE TABLE tags (
|
||||||
|
id String,
|
||||||
|
seqs Array(UInt8),
|
||||||
|
create_time DateTime DEFAULT now()
|
||||||
|
) engine=ReplacingMergeTree()
|
||||||
|
ORDER BY (id);
|
||||||
|
|
||||||
|
INSERT INTO tags(id, seqs) VALUES ('id1', [1,2,3]), ('id2', [0,2,3]), ('id1', [1,3]);
|
||||||
|
|
||||||
|
WITH
|
||||||
|
(SELECT [0, 1, 2, 3]) AS arr1
|
||||||
|
SELECT arrayIntersect(argMax(seqs, create_time), arr1) AS common, id
|
||||||
|
FROM tags
|
||||||
|
WHERE id LIKE 'id%'
|
||||||
|
GROUP BY id;
|
||||||
|
|
||||||
|
DROP TABLE tags;
|
Loading…
Reference in New Issue
Block a user