mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Fixed tests #1665
This commit is contained in:
parent
610b64679f
commit
ce5de79263
2
contrib/librdkafka
vendored
2
contrib/librdkafka
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 3401fa1e45605b5ae806f94905c92f5f546a607b
|
Subproject commit c3d50eb613704fb9c8ab3bce95a88275cb5875b7
|
2
contrib/poco
vendored
2
contrib/poco
vendored
@ -1 +1 @@
|
|||||||
Subproject commit bcf9ebad48b2162d25f5fc432b176d74a09f498d
|
Subproject commit 81d4fdfcb887f89b0f7b1e9b503cbe63e6d8366b
|
@ -16,6 +16,7 @@ namespace ErrorCodes
|
|||||||
{
|
{
|
||||||
extern const int CANNOT_PARSE_INPUT_ASSERTION_FAILED;
|
extern const int CANNOT_PARSE_INPUT_ASSERTION_FAILED;
|
||||||
extern const int CANNOT_PARSE_QUOTED_STRING;
|
extern const int CANNOT_PARSE_QUOTED_STRING;
|
||||||
|
extern const int CANNOT_PARSE_NUMBER;
|
||||||
extern const int CANNOT_PARSE_DATE;
|
extern const int CANNOT_PARSE_DATE;
|
||||||
extern const int CANNOT_PARSE_DATETIME;
|
extern const int CANNOT_PARSE_DATETIME;
|
||||||
extern const int CANNOT_READ_ARRAY_FROM_TEXT;
|
extern const int CANNOT_READ_ARRAY_FROM_TEXT;
|
||||||
@ -80,6 +81,7 @@ bool ValuesRowInputStream::read(MutableColumns & columns)
|
|||||||
*/
|
*/
|
||||||
if (e.code() == ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED
|
if (e.code() == ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED
|
||||||
|| e.code() == ErrorCodes::CANNOT_PARSE_QUOTED_STRING
|
|| e.code() == ErrorCodes::CANNOT_PARSE_QUOTED_STRING
|
||||||
|
|| e.code() == ErrorCodes::CANNOT_PARSE_NUMBER
|
||||||
|| e.code() == ErrorCodes::CANNOT_PARSE_DATE
|
|| e.code() == ErrorCodes::CANNOT_PARSE_DATE
|
||||||
|| e.code() == ErrorCodes::CANNOT_PARSE_DATETIME
|
|| e.code() == ErrorCodes::CANNOT_PARSE_DATETIME
|
||||||
|| e.code() == ErrorCodes::CANNOT_READ_ARRAY_FROM_TEXT)
|
|| e.code() == ErrorCodes::CANNOT_READ_ARRAY_FROM_TEXT)
|
||||||
|
@ -19,6 +19,7 @@ void registerFunctionsReinterpret(FunctionFactory & factory)
|
|||||||
factory.registerFunction<FunctionReinterpretAsDate>();
|
factory.registerFunction<FunctionReinterpretAsDate>();
|
||||||
factory.registerFunction<FunctionReinterpretAsDateTime>();
|
factory.registerFunction<FunctionReinterpretAsDateTime>();
|
||||||
factory.registerFunction<FunctionReinterpretAsString>();
|
factory.registerFunction<FunctionReinterpretAsString>();
|
||||||
|
factory.registerFunction<FunctionReinterpretAsFixedString>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,76 @@ public:
|
|||||||
{
|
{
|
||||||
const IDataType & type = *arguments[0];
|
const IDataType & type = *arguments[0];
|
||||||
|
|
||||||
if (type.isValueUnambiguouslyRepresentedInFixedSizeContiguousMemoryRegion())
|
|
||||||
return std::make_shared<DataTypeFixedString>(type.getSizeOfValueInMemory());
|
|
||||||
if (type.isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
|
if (type.isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
|
||||||
return std::make_shared<DataTypeString>();
|
return std::make_shared<DataTypeString>();
|
||||||
throw Exception("Cannot reinterpret " + type.getName() + " as String because it is not contiguous in memory", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
throw Exception("Cannot reinterpret " + type.getName() + " as String because it is not contiguous in memory", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void executeToString(const IColumn & src, ColumnString & dst)
|
||||||
|
{
|
||||||
|
size_t rows = src.size();
|
||||||
|
ColumnString::Chars_t & data_to = dst.getChars();
|
||||||
|
ColumnString::Offsets & offsets_to = dst.getOffsets();
|
||||||
|
offsets_to.resize(rows);
|
||||||
|
|
||||||
|
ColumnString::Offset offset = 0;
|
||||||
|
for (size_t i = 0; i < rows; ++i)
|
||||||
|
{
|
||||||
|
StringRef data = src.getDataAt(i);
|
||||||
|
|
||||||
|
/// Cut trailing zero bytes.
|
||||||
|
while (data.size && data.data[data.size - 1] == 0)
|
||||||
|
--data.size;
|
||||||
|
|
||||||
|
data_to.resize(offset + data.size + 1);
|
||||||
|
memcpySmallAllowReadWriteOverflow15(&data_to[offset], data.data, data.size);
|
||||||
|
offset += data.size;
|
||||||
|
data_to[offset] = 0;
|
||||||
|
++offset;
|
||||||
|
offsets_to[i] = offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool useDefaultImplementationForConstants() const override { return true; }
|
||||||
|
|
||||||
|
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override
|
||||||
|
{
|
||||||
|
const IColumn & src = *block.getByPosition(arguments[0]).column;
|
||||||
|
MutableColumnPtr dst = block.getByPosition(result).type->createColumn();
|
||||||
|
|
||||||
|
if (ColumnString * dst_concrete = typeid_cast<ColumnString *>(dst.get()))
|
||||||
|
executeToString(src, *dst_concrete);
|
||||||
|
else
|
||||||
|
throw Exception("Illegal column " + src.getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN);
|
||||||
|
|
||||||
|
block.getByPosition(result).column = std::move(dst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename Name>
|
||||||
|
class FunctionReinterpretAsFixedStringImpl : public IFunction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr auto name = Name::name;
|
||||||
|
static FunctionPtr create(const Context &) { return std::make_shared<FunctionReinterpretAsFixedStringImpl>(); };
|
||||||
|
|
||||||
|
String getName() const override
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getNumberOfArguments() const override { return 1; }
|
||||||
|
|
||||||
|
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||||
|
{
|
||||||
|
const IDataType & type = *arguments[0];
|
||||||
|
|
||||||
|
if (type.isValueUnambiguouslyRepresentedInFixedSizeContiguousMemoryRegion())
|
||||||
|
return std::make_shared<DataTypeFixedString>(type.getSizeOfValueInMemory());
|
||||||
|
throw Exception("Cannot reinterpret " + type.getName() + " as FixedString because it is not fixed size and contiguous in memory", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||||
|
}
|
||||||
|
|
||||||
void executeToFixedString(const IColumn & src, ColumnFixedString & dst, size_t n)
|
void executeToFixedString(const IColumn & src, ColumnFixedString & dst, size_t n)
|
||||||
{
|
{
|
||||||
size_t rows = src.size();
|
size_t rows = src.size();
|
||||||
@ -68,26 +131,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void executeToString(const IColumn & src, ColumnString & dst)
|
|
||||||
{
|
|
||||||
size_t rows = src.size();
|
|
||||||
ColumnString::Chars_t & data_to = dst.getChars();
|
|
||||||
ColumnString::Offsets & offsets_to = dst.getOffsets();
|
|
||||||
offsets_to.resize(rows);
|
|
||||||
|
|
||||||
ColumnString::Offset offset = 0;
|
|
||||||
for (size_t i = 0; i < rows; ++i)
|
|
||||||
{
|
|
||||||
StringRef data = src.getDataAt(i);
|
|
||||||
data_to.resize(offset + data.size + 1);
|
|
||||||
memcpySmallAllowReadWriteOverflow15(&data_to[offset], data.data, data.size);
|
|
||||||
offset += data.size;
|
|
||||||
data_to[offset] = 0;
|
|
||||||
++offset;
|
|
||||||
offsets_to[i] = offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool useDefaultImplementationForConstants() const override { return true; }
|
bool useDefaultImplementationForConstants() const override { return true; }
|
||||||
|
|
||||||
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override
|
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override
|
||||||
@ -97,8 +140,6 @@ public:
|
|||||||
|
|
||||||
if (ColumnFixedString * dst_concrete = typeid_cast<ColumnFixedString *>(dst.get()))
|
if (ColumnFixedString * dst_concrete = typeid_cast<ColumnFixedString *>(dst.get()))
|
||||||
executeToFixedString(src, *dst_concrete, dst_concrete->getN());
|
executeToFixedString(src, *dst_concrete, dst_concrete->getN());
|
||||||
else if (ColumnString * dst_concrete = typeid_cast<ColumnString *>(dst.get()))
|
|
||||||
executeToString(src, *dst_concrete);
|
|
||||||
else
|
else
|
||||||
throw Exception("Illegal column " + src.getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN);
|
throw Exception("Illegal column " + src.getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN);
|
||||||
|
|
||||||
@ -202,6 +243,7 @@ struct NameReinterpretAsFloat64 { static constexpr auto name = "reinterpretA
|
|||||||
struct NameReinterpretAsDate { static constexpr auto name = "reinterpretAsDate"; };
|
struct NameReinterpretAsDate { static constexpr auto name = "reinterpretAsDate"; };
|
||||||
struct NameReinterpretAsDateTime { static constexpr auto name = "reinterpretAsDateTime"; };
|
struct NameReinterpretAsDateTime { static constexpr auto name = "reinterpretAsDateTime"; };
|
||||||
struct NameReinterpretAsString { static constexpr auto name = "reinterpretAsString"; };
|
struct NameReinterpretAsString { static constexpr auto name = "reinterpretAsString"; };
|
||||||
|
struct NameReinterpretAsFixedString { static constexpr auto name = "reinterpretAsFixedString"; };
|
||||||
|
|
||||||
using FunctionReinterpretAsUInt8 = FunctionReinterpretStringAs<DataTypeUInt8, NameReinterpretAsUInt8>;
|
using FunctionReinterpretAsUInt8 = FunctionReinterpretStringAs<DataTypeUInt8, NameReinterpretAsUInt8>;
|
||||||
using FunctionReinterpretAsUInt16 = FunctionReinterpretStringAs<DataTypeUInt16, NameReinterpretAsUInt16>;
|
using FunctionReinterpretAsUInt16 = FunctionReinterpretStringAs<DataTypeUInt16, NameReinterpretAsUInt16>;
|
||||||
@ -217,6 +259,7 @@ using FunctionReinterpretAsDate = FunctionReinterpretStringAs<DataTypeDate,
|
|||||||
using FunctionReinterpretAsDateTime = FunctionReinterpretStringAs<DataTypeDateTime, NameReinterpretAsDateTime>;
|
using FunctionReinterpretAsDateTime = FunctionReinterpretStringAs<DataTypeDateTime, NameReinterpretAsDateTime>;
|
||||||
|
|
||||||
using FunctionReinterpretAsString = FunctionReinterpretAsStringImpl<NameReinterpretAsString>;
|
using FunctionReinterpretAsString = FunctionReinterpretAsStringImpl<NameReinterpretAsString>;
|
||||||
|
using FunctionReinterpretAsFixedString = FunctionReinterpretAsStringImpl<NameReinterpretAsFixedString>;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -718,8 +718,11 @@ void skipJSONFieldPlain(ReadBuffer & buf, const StringRef & name_of_filed)
|
|||||||
NullSink sink;
|
NullSink sink;
|
||||||
readJSONStringInto(sink, buf);
|
readJSONStringInto(sink, buf);
|
||||||
}
|
}
|
||||||
else if (isNumericASCII(*buf.position()) || *buf.position() == '-' || *buf.position() == '+') /// skip number
|
else if (isNumericASCII(*buf.position()) || *buf.position() == '-' || *buf.position() == '+' || *buf.position() == '.') /// skip number
|
||||||
{
|
{
|
||||||
|
if (*buf.position() == '+')
|
||||||
|
++buf.position();
|
||||||
|
|
||||||
double v;
|
double v;
|
||||||
if (!tryReadFloatText(v, buf))
|
if (!tryReadFloatText(v, buf))
|
||||||
throw Exception("Expected a number field for key '" + name_of_filed.toString() + "'", ErrorCodes::INCORRECT_DATA);
|
throw Exception("Expected a number field for key '" + name_of_filed.toString() + "'", ErrorCodes::INCORRECT_DATA);
|
||||||
|
Loading…
Reference in New Issue
Block a user