ClickHouse/dbms/src/Interpreters/InterpreterCheckQuery.cpp

33 lines
932 B
C++
Raw Normal View History

2014-08-05 10:52:06 +00:00
#include <DB/Interpreters/InterpreterCheckQuery.h>
#include <DB/Parsers/ASTCheckQuery.h>
#include <DB/DataStreams/OneBlockInputStream.h>
#include <DB/Columns/ColumnsNumber.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
2015-06-18 02:11:05 +00:00
namespace DB
{
2014-08-05 10:52:06 +00:00
InterpreterCheckQuery::InterpreterCheckQuery(DB::ASTPtr query_ptr_, DB::Context& context_) : query_ptr(query_ptr_), context(context_)
{
}
2015-06-18 02:11:05 +00:00
BlockIO InterpreterCheckQuery::execute()
2014-08-05 10:52:06 +00:00
{
ASTCheckQuery & alter = typeid_cast<ASTCheckQuery &>(*query_ptr);
String & table_name = alter.table;
String database_name = alter.database.empty() ? context.getCurrentDatabase() : alter.database;
StoragePtr table = context.getTable(database_name, table_name);
2015-06-18 02:11:05 +00:00
result = Block{{ new ColumnUInt8, new DataTypeUInt8, "result" }};
2014-08-05 10:52:06 +00:00
result.getByPosition(0).column->insert(Field(UInt64(table->checkData())));
2015-06-18 02:11:05 +00:00
BlockIO res;
res.in = new OneBlockInputStream(result);
res.in_sample = result;
return res;
2014-08-05 10:52:06 +00:00
}
}