FieldToDataType.h 913 字节
Newer Older
1 2
#pragma once

3
#include <Common/FieldVisitors.h>
4

5 6 7 8

namespace DB
{

9
class IDataType;
10
using DataTypePtr = std::shared_ptr<const IDataType>;
11 12


A
Alexey Milovidov 已提交
13 14 15
/** For a given Field returns the minimum data type that allows this value to be stored.
  * Note that you still have to convert Field to corresponding data type before inserting to columns
  *  (for example, this is necessary to convert elements of Array to common type).
16
  */
17
class FieldToDataType : public StaticVisitor<DataTypePtr>
18 19
{
public:
A
Alexey Milovidov 已提交
20 21
    DataTypePtr operator() (const Null & x) const;
    DataTypePtr operator() (const UInt64 & x) const;
22
    DataTypePtr operator() (const UInt128 & x) const;
A
Alexey Milovidov 已提交
23 24 25 26 27
    DataTypePtr operator() (const Int64 & x) const;
    DataTypePtr operator() (const Float64 & x) const;
    DataTypePtr operator() (const String & x) const;
    DataTypePtr operator() (const Array & x) const;
    DataTypePtr operator() (const Tuple & x) const;
28 29 30 31
};

}