2014-08-22 00:57:20 +00:00
|
|
|
#include <DB/Functions/FunctionFactory.h>
|
|
|
|
#include <DB/Functions/FunctionsConversion.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-08-17 07:40:06 +00:00
|
|
|
void throwExceptionForIncompletelyParsedValue(
|
|
|
|
ReadBuffer & read_buffer, Block & block, const ColumnNumbers & arguments, size_t result)
|
|
|
|
{
|
|
|
|
std::string message;
|
|
|
|
{
|
|
|
|
const IDataType & to_type = *block.getByPosition(result).type;
|
|
|
|
|
2016-08-17 07:41:44 +00:00
|
|
|
WriteBufferFromString message_buf(message);
|
2016-08-17 07:40:06 +00:00
|
|
|
message_buf << "Cannot parse string " << quote << String(read_buffer.buffer().begin(), read_buffer.buffer().size())
|
|
|
|
<< " as " << to_type.getName()
|
|
|
|
<< ": syntax error";
|
|
|
|
|
|
|
|
if (read_buffer.offset())
|
|
|
|
message_buf << " at position " << read_buffer.offset()
|
|
|
|
<< " (parsed just " << quote << String(read_buffer.buffer().begin(), read_buffer.offset()) << ")";
|
|
|
|
else
|
|
|
|
message_buf << " at begin of string";
|
|
|
|
|
|
|
|
if (to_type.isNumeric())
|
|
|
|
message_buf << ". Note: there are to" << to_type.getName() << "OrZero function, which returns zero instead throwing exception.";
|
|
|
|
}
|
|
|
|
|
|
|
|
throw Exception(message, ErrorCodes::CANNOT_PARSE_TEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-22 00:57:20 +00:00
|
|
|
void registerFunctionsConversion(FunctionFactory & factory)
|
|
|
|
{
|
2014-11-12 17:23:26 +00:00
|
|
|
factory.registerFunction<FunctionToUInt8>();
|
|
|
|
factory.registerFunction<FunctionToUInt16>();
|
|
|
|
factory.registerFunction<FunctionToUInt32>();
|
|
|
|
factory.registerFunction<FunctionToUInt64>();
|
|
|
|
factory.registerFunction<FunctionToInt8>();
|
|
|
|
factory.registerFunction<FunctionToInt16>();
|
|
|
|
factory.registerFunction<FunctionToInt32>();
|
|
|
|
factory.registerFunction<FunctionToInt64>();
|
|
|
|
factory.registerFunction<FunctionToFloat32>();
|
|
|
|
factory.registerFunction<FunctionToFloat64>();
|
|
|
|
factory.registerFunction<FunctionToDate>();
|
|
|
|
factory.registerFunction<FunctionToDateTime>();
|
|
|
|
factory.registerFunction<FunctionToString>();
|
|
|
|
factory.registerFunction<FunctionToFixedString>();
|
2015-07-01 17:32:04 +00:00
|
|
|
factory.registerFunction<FunctionToUnixTimestamp>();
|
2015-12-23 08:11:11 +00:00
|
|
|
factory.registerFunction<FunctionCast>();
|
2016-08-02 05:32:09 +00:00
|
|
|
factory.registerFunction<FunctionToUInt8OrZero>();
|
|
|
|
factory.registerFunction<FunctionToUInt16OrZero>();
|
|
|
|
factory.registerFunction<FunctionToUInt32OrZero>();
|
|
|
|
factory.registerFunction<FunctionToUInt64OrZero>();
|
|
|
|
factory.registerFunction<FunctionToInt8OrZero>();
|
|
|
|
factory.registerFunction<FunctionToInt16OrZero>();
|
|
|
|
factory.registerFunction<FunctionToInt32OrZero>();
|
|
|
|
factory.registerFunction<FunctionToInt64OrZero>();
|
|
|
|
factory.registerFunction<FunctionToFloat32OrZero>();
|
|
|
|
factory.registerFunction<FunctionToFloat64OrZero>();
|
2014-08-22 00:57:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|