Small fixes to empty lines and style.

This commit is contained in:
Vitaliy Zakaznikov 2019-12-05 06:53:36 -05:00
parent 7f92e6a21f
commit 1e0e00b7e4
6 changed files with 19 additions and 80 deletions

View File

@ -9,13 +9,13 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <optional>
#include <Parsers/ASTAlterQuery.h>
#include <Storages/LiveView/StorageLiveView.h>
namespace DB
{

View File

@ -9,7 +9,6 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <Poco/Condition.h>

View File

@ -1,66 +0,0 @@
#pragma once
#include <Storages/IStorage.h>
namespace DB
{
class ProxyStorage : public IStorage
{
public:
ProxyStorage(StoragePtr storage_, BlockInputStreams streams_, QueryProcessingStage::Enum to_stage_)
: storage(std::move(storage_)), streams(std::move(streams_)), to_stage(to_stage_) {}
public:
std::string getName() const override { return "ProxyStorage(" + storage->getName() + ")"; }
std::string getTableName() const override { return storage->getTableName(); }
bool isRemote() const override { return storage->isRemote(); }
bool supportsSampling() const override { return storage->supportsSampling(); }
bool supportsFinal() const override { return storage->supportsFinal(); }
bool supportsPrewhere() const override { return storage->supportsPrewhere(); }
bool supportsReplication() const override { return storage->supportsReplication(); }
bool supportsDeduplication() const override { return storage->supportsDeduplication(); }
QueryProcessingStage::Enum getQueryProcessingStage(const Context & /*context*/) const override { return to_stage; }
BlockInputStreams read(
const Names & /*column_names*/,
const SelectQueryInfo & /*query_info*/,
const Context & /*context*/,
QueryProcessingStage::Enum /*processed_stage*/,
size_t /*max_block_size*/,
unsigned /*num_streams*/) override
{
return streams;
}
bool supportsIndexForIn() const override { return storage->supportsIndexForIn(); }
bool mayBenefitFromIndexForIn(const ASTPtr & left_in_operand, const Context & query_context) const override { return storage->mayBenefitFromIndexForIn(left_in_operand, query_context); }
ASTPtr getPartitionKeyAST() const override { return storage->getPartitionKeyAST(); }
ASTPtr getSortingKeyAST() const override { return storage->getSortingKeyAST(); }
ASTPtr getPrimaryKeyAST() const override { return storage->getPrimaryKeyAST(); }
ASTPtr getSamplingKeyAST() const override { return storage->getSamplingKeyAST(); }
Names getColumnsRequiredForPartitionKey() const override { return storage->getColumnsRequiredForPartitionKey(); }
Names getColumnsRequiredForSortingKey() const override { return storage->getColumnsRequiredForSortingKey(); }
Names getColumnsRequiredForPrimaryKey() const override { return storage->getColumnsRequiredForPrimaryKey(); }
Names getColumnsRequiredForSampling() const override { return storage->getColumnsRequiredForSampling(); }
Names getColumnsRequiredForFinal() const override { return storage->getColumnsRequiredForFinal(); }
const ColumnsDescription & getColumns() const override { return storage->getColumns(); }
void setColumns(ColumnsDescription columns_) override { return storage->setColumns(columns_); }
NameAndTypePair getColumn(const String & column_name) const override { return storage->getColumn(column_name); }
bool hasColumn(const String & column_name) const override { return storage->hasColumn(column_name); }
static StoragePtr createProxyStorage(StoragePtr storage, BlockInputStreams streams, QueryProcessingStage::Enum to_stage)
{
return std::make_shared<ProxyStorage>(std::move(storage), std::move(streams), to_stage);
}
private:
StoragePtr storage;
BlockInputStreams streams;
QueryProcessingStage::Enum to_stage;
};
}

View File

@ -2,20 +2,25 @@
#include <Storages/IStorage.h>
namespace DB
{
class StorageBlocks : public IStorage
{
/* Storage based on the prepared streams that already contain data blocks.
* Used by Live Views to complete stored query based on the mergeable blocks.
*/
public:
StorageBlocks(const std::string & database_name_, const std::string & table_name_,
const ColumnsDescription & columns_, BlockInputStreams streams_,
QueryProcessingStage::Enum to_stage_)
: database_name(database_name_), table_name(table_name_), streams(streams_), to_stage(to_stage_)
const ColumnsDescription & columns_, BlockInputStreams streams_,
QueryProcessingStage::Enum to_stage_)
: database_name(database_name_), table_name(table_name_), streams(streams_), to_stage(to_stage_)
{
setColumns(columns_);
}
static StoragePtr createStorage(std::string database_name, std::string table_name, const ColumnsDescription columns, BlockInputStreams streams, QueryProcessingStage::Enum to_stage)
static StoragePtr createStorage(std::string database_name, std::string table_name,
const ColumnsDescription columns, BlockInputStreams streams, QueryProcessingStage::Enum to_stage)
{
return std::make_shared<StorageBlocks>(std::move(database_name), std::move(table_name), std::move(columns), std::move(streams), to_stage);
}
@ -30,7 +35,7 @@ public:
const Context & /*context*/,
QueryProcessingStage::Enum /*processed_stage*/,
size_t /*max_block_size*/,
unsigned /*num_streams*/)
unsigned /*num_streams*/)
{
return streams;
}

View File

@ -41,6 +41,7 @@ limitations under the License. */
#include <Interpreters/DatabaseAndTableWithAlias.h>
#include <Interpreters/AddDefaultDatabaseVisitor.h>
namespace DB
{
@ -73,7 +74,7 @@ static ASTTableExpression * getTableExpression(ASTSelectQuery & select, size_t t
static void extractDependentTable(ASTPtr & query, String & select_database_name, String & select_table_name, const String & database_name, const String & table_name, ASTPtr & inner_outer_query, ASTPtr & inner_subquery)
{
ASTSelectQuery & select_query = typeid_cast<ASTSelectQuery &>(*query);
ASTSelectQuery & select_query = typeid_cast<ASTSelectQuery &>(*query);
auto db_and_table = getDatabaseAndTable(select_query, 0);
ASTPtr subquery = extractTableExpression(select_query, 0);
@ -332,7 +333,7 @@ bool StorageLiveView::getNewBlocks()
InterpreterSelectQuery interpreter(mergeable_query->clone(), *live_view_context, SelectQueryOptions(QueryProcessingStage::WithMergeableState), Names());
auto mergeable_stream = std::make_shared<MaterializingBlockInputStream>(interpreter.execute().in);
while (Block block = mergeable_stream->read())
new_mergeable_blocks->push_back(block);
@ -342,14 +343,14 @@ bool StorageLiveView::getNewBlocks()
auto blocks_storage = StorageBlocks::createStorage(database_name, table_name, global_context.getTable(select_database_name, select_table_name)->getColumns(), {from}, QueryProcessingStage::WithMergeableState);
InterpreterSelectQuery select(mergeable_query->clone(), *live_view_context, blocks_storage, SelectQueryOptions(QueryProcessingStage::Complete));
BlockInputStreamPtr data = std::make_shared<MaterializingBlockInputStream>(select.execute().in);
if (inner_subquery)
{
auto outer_blocks_storage = StorageBlocks::createStorage(database_name, table_name,ColumnsDescription(data->getHeader().getNamesAndTypesList()), {data}, QueryProcessingStage::FetchColumns);
InterpreterSelectQuery outer_select(inner_outer_query->clone(), *live_view_context, outer_blocks_storage, SelectQueryOptions(QueryProcessingStage::Complete));
data = std::make_shared<MaterializingBlockInputStream>(outer_select.execute().in);
}
/// Squashing is needed here because the view query can generate a lot of blocks
/// even when only one block is inserted into the parent table (e.g. if the query is a GROUP BY
/// and two-level aggregation is triggered).

View File

@ -159,8 +159,8 @@ private:
String table_name;
String database_name;
ASTPtr inner_query; /// stored query : SELECT * FROM ( SELECT a FROM A)
ASTPtr inner_subquery; /// stored query's subquery if any : SLECT a FROM A
ASTPtr inner_outer_query; /// the query right before innermost subquery : ... SELECT * FROM ( subquery )
ASTPtr inner_subquery; /// stored query's innermost subquery if any
ASTPtr inner_outer_query; /// query right before innermost subquery
Context & global_context;
std::unique_ptr<Context> live_view_context;