1#pragma once
2
3#include <Common/FieldVisitors.h>
4
5
6namespace DB
7{
8
9class IDataType;
10using DataTypePtr = std::shared_ptr<const IDataType>;
11
12
13/** For a given Field returns the minimum data type that allows this value to be stored.
14 * Note that you still have to convert Field to corresponding data type before inserting to columns
15 * (for example, this is necessary to convert elements of Array to common type).
16 */
17class FieldToDataType : public StaticVisitor<DataTypePtr>
18{
19public:
20 DataTypePtr operator() (const Null & x) const;
21 DataTypePtr operator() (const UInt64 & x) const;
22 DataTypePtr operator() (const UInt128 & x) const;
23 DataTypePtr operator() (const Int64 & x) const;
24 DataTypePtr operator() (const Float64 & x) const;
25 DataTypePtr operator() (const String & x) const;
26 DataTypePtr operator() (const Array & x) const;
27 DataTypePtr operator() (const Tuple & x) const;
28 DataTypePtr operator() (const DecimalField<Decimal32> & x) const;
29 DataTypePtr operator() (const DecimalField<Decimal64> & x) const;
30 DataTypePtr operator() (const DecimalField<Decimal128> & x) const;
31 DataTypePtr operator() (const AggregateFunctionStateData & x) const;
32};
33
34}
35
36