ClickHouse/dbms/src/Storages/StorageMySQL.cpp

38 lines
1.1 KiB
C++
Raw Normal View History

#include <Storages/StorageMySQL.h>
2017-12-26 21:34:06 +00:00
#include <Storages/transformQueryForExternalDatabase.h>
#include <Dictionaries/MySQLBlockInputStream.h>
namespace DB
{
2017-12-26 21:34:06 +00:00
StorageMySQL::StorageMySQL(
const std::string & name,
2017-12-28 04:28:05 +00:00
mysqlxx::Pool && pool,
2017-12-26 21:34:06 +00:00
const std::string & remote_database_name,
const std::string & remote_table_name,
const NamesAndTypesList & columns)
: name(name)
, remote_database_name(remote_database_name)
, remote_table_name(remote_table_name)
2017-12-27 21:45:05 +00:00
, columns(columns)
2017-12-28 04:28:05 +00:00
, pool(std::move(pool))
{
}
BlockInputStreams StorageMySQL::read(const Names & column_names,
const SelectQueryInfo & query_info,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,
2017-12-26 21:34:06 +00:00
unsigned)
{
2017-12-13 16:46:57 +00:00
check(column_names);
processed_stage = QueryProcessingStage::FetchColumns;
2017-12-26 21:34:06 +00:00
String query = transformQueryForExternalDatabase(*query_info.query, columns, remote_database_name, remote_table_name, context);
return { std::make_shared<MySQLBlockInputStream>(pool.Get(), query, getSampleBlock(), max_block_size) };
}
2017-12-26 21:34:06 +00:00
}