2014-03-09 17:36:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-06 20:18:34 +00:00
|
|
|
#include <Storages/ColumnsDescription.h>
|
2015-02-22 15:31:39 +00:00
|
|
|
|
|
|
|
|
2014-03-09 17:36:01 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Description of the table.
|
2018-03-06 20:18:34 +00:00
|
|
|
* Is not thread safe. See IStorage::lockStructure ().
|
2014-03-09 17:36:01 +00:00
|
|
|
*/
|
2014-03-19 10:45:13 +00:00
|
|
|
class ITableDeclaration
|
2014-03-09 17:36:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-03-13 14:18:11 +00:00
|
|
|
virtual const ColumnsDescription & getColumns() const { return columns; }
|
|
|
|
virtual void setColumns(ColumnsDescription columns_);
|
2014-03-09 17:36:01 +00:00
|
|
|
|
2018-03-13 14:18:11 +00:00
|
|
|
/// NOTE: These methods should include virtual columns, but should NOT include ALIAS columns
|
|
|
|
/// (they are treated separately).
|
|
|
|
virtual NameAndTypePair getColumn(const String & column_name) const;
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual bool hasColumn(const String & column_name) const;
|
2014-03-09 17:36:01 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Block getSampleBlock() const;
|
|
|
|
Block getSampleBlockNonMaterialized() const;
|
2018-01-09 01:51:08 +00:00
|
|
|
Block getSampleBlockForColumns(const Names & column_names) const;
|
2014-03-09 17:36:01 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Verify that all the requested names are in the table and are set correctly.
|
|
|
|
* (the list of names is not empty and the names do not repeat)
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
|
|
|
void check(const Names & column_names) const;
|
2014-03-09 17:36:01 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Check that all the requested names are in the table and have the correct types.
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
2017-12-25 21:57:29 +00:00
|
|
|
void check(const NamesAndTypesList & columns) const;
|
2014-07-14 14:07:47 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Check that all names from the intersection of `names` and `columns` are in the table and have the same types.
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
2017-12-25 21:57:29 +00:00
|
|
|
void check(const NamesAndTypesList & columns, const Names & column_names) const;
|
2014-07-14 14:07:47 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Check that the data block for the record contains all the columns of the table with the correct types,
|
|
|
|
* contains only the columns of the table, and all the columns are different.
|
|
|
|
* If need_all, still checks that all the columns of the table are in the block.
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
|
|
|
void check(const Block & block, bool need_all = false) const;
|
2014-10-03 15:30:10 +00:00
|
|
|
|
2014-03-09 17:36:01 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ITableDeclaration() = default;
|
2018-03-06 20:18:34 +00:00
|
|
|
explicit ITableDeclaration(ColumnsDescription columns_);
|
|
|
|
virtual ~ITableDeclaration() = default;
|
2015-02-22 15:31:39 +00:00
|
|
|
|
2018-03-13 14:18:11 +00:00
|
|
|
private:
|
2018-03-06 20:18:34 +00:00
|
|
|
ColumnsDescription columns;
|
2014-03-09 17:36:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|