mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Convert types in Views
This commit is contained in:
parent
20dcc4decd
commit
983950d4ec
@ -12,13 +12,12 @@
|
||||
#include <Storages/StorageView.h>
|
||||
#include <Storages/StorageFactory.h>
|
||||
|
||||
#include <DataStreams/MaterializingBlockInputStream.h>
|
||||
|
||||
#include <Common/typeid_cast.h>
|
||||
|
||||
#include <Processors/Pipe.h>
|
||||
#include <Processors/Sources/SourceFromInputStream.h>
|
||||
#include <Processors/Transforms/MaterializingTransform.h>
|
||||
#include <Processors/Transforms/ConvertingTransform.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -78,8 +77,15 @@ Pipes StorageView::read(
|
||||
/// It's expected that the columns read from storage are not constant.
|
||||
/// Because method 'getSampleBlockForColumns' is used to obtain a structure of result in InterpreterSelectQuery.
|
||||
for (auto & pipe : pipes)
|
||||
{
|
||||
pipe.addSimpleTransform(std::make_shared<MaterializingTransform>(pipe.getHeader()));
|
||||
|
||||
/// And also convert to expected structure.
|
||||
pipe.addSimpleTransform(std::make_shared<ConvertingTransform>(
|
||||
pipe.getHeader(), getSampleBlockForColumns(column_names),
|
||||
ConvertingTransform::MatchColumnsMode::Name, context));
|
||||
}
|
||||
|
||||
return pipes;
|
||||
}
|
||||
|
||||
|
10
tests/queries/0_stateless/01124_view_bad_types.reference
Normal file
10
tests/queries/0_stateless/01124_view_bad_types.reference
Normal file
@ -0,0 +1,10 @@
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
@ -5,7 +5,7 @@ INSERT INTO test.table SELECT * FROM system.numbers LIMIT 10;
|
||||
DROP TABLE IF EXISTS test.view;
|
||||
CREATE VIEW test.view (x UInt64) AS SELECT * FROM test.table;
|
||||
|
||||
SELECT x, any(x) FROM test.view GROUP BY x;
|
||||
SELECT x, any(x) FROM test.view GROUP BY x ORDER BY x;
|
||||
|
||||
DROP TABLE test.view;
|
||||
DROP TABLE test.table;
|
Loading…
Reference in New Issue
Block a user