2011-08-12 18:27:39 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-05-03 22:46:51 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <Core/Types.h>
|
|
|
|
#include <Core/Field.h>
|
2017-11-24 13:55:31 +00:00
|
|
|
#include <Common/FieldVisitors.h>
|
2015-10-12 07:05:54 +00:00
|
|
|
|
2011-08-12 18:27:39 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-03-12 10:13:45 +00:00
|
|
|
class IDataType;
|
2017-12-18 01:11:48 +00:00
|
|
|
using DataTypePtr = std::shared_ptr<const IDataType>;
|
2017-03-12 10:13:45 +00:00
|
|
|
|
|
|
|
|
2018-02-28 04:30:27 +00:00
|
|
|
/** 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).
|
2015-06-29 04:54:52 +00:00
|
|
|
*/
|
2013-01-05 20:03:19 +00:00
|
|
|
class FieldToDataType : public StaticVisitor<DataTypePtr>
|
2011-08-12 18:27:39 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-02-28 04:30:27 +00:00
|
|
|
DataTypePtr operator() (const Null & x) const;
|
|
|
|
DataTypePtr operator() (const UInt64 & x) const;
|
2018-07-09 21:25:56 +00:00
|
|
|
DataTypePtr operator() (const UInt128 & x) const;
|
2021-05-03 16:12:28 +00:00
|
|
|
DataTypePtr operator() (const UInt256 & x) const;
|
2018-02-28 04:30:27 +00:00
|
|
|
DataTypePtr operator() (const Int64 & x) const;
|
2020-08-19 11:52:17 +00:00
|
|
|
DataTypePtr operator() (const Int128 & x) const;
|
2021-05-03 16:12:28 +00:00
|
|
|
DataTypePtr operator() (const Int256 & x) const;
|
2021-05-03 22:46:51 +00:00
|
|
|
DataTypePtr operator() (const UUID & x) const;
|
2018-02-28 04:30:27 +00:00
|
|
|
DataTypePtr operator() (const Float64 & x) const;
|
|
|
|
DataTypePtr operator() (const String & x) const;
|
|
|
|
DataTypePtr operator() (const Array & x) const;
|
2020-03-08 22:38:12 +00:00
|
|
|
DataTypePtr operator() (const Tuple & tuple) const;
|
2020-10-10 06:49:03 +00:00
|
|
|
DataTypePtr operator() (const Map & map) const;
|
2018-08-23 19:11:31 +00:00
|
|
|
DataTypePtr operator() (const DecimalField<Decimal32> & x) const;
|
|
|
|
DataTypePtr operator() (const DecimalField<Decimal64> & x) const;
|
|
|
|
DataTypePtr operator() (const DecimalField<Decimal128> & x) const;
|
2020-08-19 11:52:17 +00:00
|
|
|
DataTypePtr operator() (const DecimalField<Decimal256> & x) const;
|
2019-02-11 13:11:52 +00:00
|
|
|
DataTypePtr operator() (const AggregateFunctionStateData & x) const;
|
2022-01-18 11:52:27 +00:00
|
|
|
DataTypePtr operator() (const bool & x) const;
|
2011-08-12 18:27:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|