2016-02-14 02:37:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Field.h>
|
2016-02-14 02:37:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class IDataType;
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/** Used to interpret expressions in a set in IN,
|
|
|
|
* and also in the query of the form INSERT ... VALUES ...
|
2016-02-14 02:37:42 +00:00
|
|
|
*
|
2017-06-02 21:37:28 +00:00
|
|
|
* To work correctly with expressions of the form `1.0 IN (1)` or, for example, `1 IN (1, 2.0, 2.5, -1)` work the same way as `1 IN (1, 2)`.
|
|
|
|
* Checks for the compatibility of types, checks values fall in the range of valid values of the type, makes type conversion.
|
|
|
|
* If the value does not fall into the range - returns Null.
|
2016-02-14 02:37:42 +00:00
|
|
|
*/
|
2017-02-16 22:05:48 +00:00
|
|
|
Field convertFieldToType(const Field & from_value, const IDataType & to_type, const IDataType * from_type_hint = nullptr);
|
2016-02-14 02:37:42 +00:00
|
|
|
|
2020-06-24 16:37:04 +00:00
|
|
|
/// Does the same, but throws ARGUMENT_OUT_OF_BOUND if value does not fall into the range.
|
|
|
|
Field convertFieldToTypeOrThrow(const Field & from_value, const IDataType & to_type, const IDataType * from_type_hint = nullptr);
|
|
|
|
|
2016-02-14 02:37:42 +00:00
|
|
|
}
|