Merge pull request #13073 from nikitamikhaylov/rewrite-tests

BayesAB test
This commit is contained in:
alexey-milovidov 2020-07-31 02:30:07 +03:00 committed by GitHub
commit 74edcfb87e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
135 changed files with 219 additions and 292 deletions

View File

@ -1,5 +1,3 @@
#include <iomanip>
#include <Poco/Net/NetException.h>
#include <Core/Defines.h>
#include <Compression/CompressedReadBuffer.h>

View File

@ -17,7 +17,6 @@
#endif
#include <Common/Exception.h>
#include <IO/WriteHelpers.h>
#include <Poco/String.h>
#include <algorithm>

View File

@ -1,7 +1,6 @@
#include <Columns/ColumnAggregateFunction.h>
#include <Columns/ColumnsCommon.h>
#include <Common/assert_cast.h>
#include <AggregateFunctions/AggregateFunctionState.h>
#include <DataStreams/ColumnGathererStream.h>
#include <IO/WriteBufferFromArena.h>
#include <IO/WriteBufferFromString.h>

View File

@ -2,11 +2,9 @@
#include <Columns/ColumnConst.h>
#include <Columns/ColumnsCommon.h>
#include <Common/PODArray.h>
#include <Common/typeid_cast.h>
#include <Common/WeakHash.h>
#include <Common/HashTable/Hash.h>
#include <common/defines.h>
#if defined(MEMORY_SANITIZER)
#include <sanitizer/msan_interface.h>

View File

@ -1,4 +1,3 @@
#include <Core/Defines.h>
#include <Common/Arena.h>
#include <Common/memcmpSmall.h>
#include <Common/assert_cast.h>

View File

@ -11,7 +11,6 @@
#include <Common/assert_cast.h>
#include <Common/WeakHash.h>
#include <Common/HashTable/Hash.h>
#include <IO/WriteBuffer.h>
#include <IO/WriteHelpers.h>
#include <Columns/ColumnsCommon.h>
#include <DataStreams/ColumnGathererStream.h>

View File

@ -6,7 +6,6 @@
#include <cstring>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <functional>
#include <Poco/DOM/Text.h>
#include <Poco/DOM/Attr.h>

View File

@ -1,6 +1,5 @@
#include "configReadClient.h"
#include <Poco/Util/Application.h>
#include <Poco/Util/LayeredConfiguration.h>
#include <Poco/File.h>
#include "ConfigProcessor.h"

View File

@ -1,9 +1,7 @@
#include <Core/UUID.h>
#include <IO/ReadBuffer.h>
#include <IO/WriteBuffer.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <IO/ReadBufferFromString.h>
#include <IO/WriteBufferFromString.h>
#include <IO/Operators.h>
#include <Common/FieldVisitors.h>

View File

@ -5,7 +5,6 @@
#include <Common/StackTrace.h>
#include <Common/TraceCollector.h>
#include <Common/thread_local_rng.h>
#include <common/StringRef.h>
#include <common/logger_useful.h>
#include <common/phdr_cache.h>
#include <common/errnoToString.h>

View File

@ -1,7 +1,5 @@
#include "StatusFile.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <fcntl.h>
#include <errno.h>

View File

@ -1,5 +1,4 @@
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#if defined(OS_LINUX)
# include <sys/sysinfo.h>
@ -8,9 +7,7 @@
#include <random>
#include <common/defines.h>
#include <common/sleep.h>
#include <common/getThreadId.h>
#include <IO/ReadHelpers.h>

View File

@ -13,9 +13,6 @@
#include <Common/StackTrace.h>
#include <common/logger_useful.h>
#include <unistd.h>
#include <fcntl.h>
namespace DB
{

View File

@ -1,5 +1,3 @@
#include <string.h>
#include <Common/ProfileEvents.h>
#include <Common/ZooKeeper/IKeeper.h>

View File

@ -3,7 +3,6 @@
#include "KeeperException.h"
#include "TestKeeper.h"
#include <random>
#include <functional>
#include <pcg-random/pcg_random.hpp>
@ -11,8 +10,6 @@
#include <common/find_symbols.h>
#include <Common/randomSeed.h>
#include <Common/StringUtils/StringUtils.h>
#include <Common/PODArray.h>
#include <Common/thread_local_rng.h>
#include <Common/Exception.h>
#include <Poco/Net/NetException.h>

View File

@ -8,9 +8,6 @@
#include <IO/Operators.h>
#include <IO/WriteBufferFromString.h>
#include <Poco/Exception.h>
#include <Poco/Net/NetException.h>
#if !defined(ARCADIA_BUILD)
# include <Common/config.h>
#endif

View File

@ -5,7 +5,6 @@
#include <syscall.h>
#include <unistd.h>
#include <linux/capability.h>
#include <linux/netlink.h>
#include <Common/Exception.h>

View File

@ -1,5 +1,4 @@
#include "CompressedReadBuffer.h"
#include <Compression/CompressionInfo.h>
#include <Compression/LZ4_decompress_faster.h>

View File

@ -1,14 +1,11 @@
#include "CompressedReadBufferBase.h"
#include <vector>
#include <cstring>
#include <cassert>
#include <city.h>
#include <Common/PODArray.h>
#include <Common/ProfileEvents.h>
#include <Common/Exception.h>
#include <Common/hex.h>
#include <common/unaligned.h>
#include <Compression/ICompressionCodec.h>
#include <Compression/CompressionFactory.h>
#include <IO/ReadBuffer.h>

View File

@ -2,7 +2,6 @@
#include "CompressedReadBufferFromFile.h"
#include <Compression/CompressionInfo.h>
#include <Compression/LZ4_decompress_faster.h>
#include <IO/WriteHelpers.h>
#include <IO/createReadBufferFromFileBase.h>

View File

@ -1,4 +1,3 @@
#include <memory>
#include <city.h>
#include <string.h>

View File

@ -5,7 +5,6 @@
#include <Parsers/IAST.h>
#include <Parsers/ASTLiteral.h>
#include <IO/WriteHelpers.h>
#include <cstdlib>
namespace DB

View File

@ -9,7 +9,6 @@
#include <string.h>
#include <algorithm>
#include <cstdlib>
#include <type_traits>
#include <bitset>

View File

@ -3,12 +3,10 @@
#include <Common/PODArray.h>
#include <common/unaligned.h>
#include <Compression/CompressionFactory.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <IO/WriteBufferFromString.h>
#include <IO/Operators.h>
#include <Common/hex.h>
#include <sstream>
namespace DB

View File

@ -1,9 +1,7 @@
#include <Compression/CompressionCodecZSTD.h>
#include <Compression/CompressionInfo.h>
#include <IO/ReadHelpers.h>
#include <Compression/CompressionFactory.h>
#include <zstd.h>
#include <Core/Field.h>
#include <Parsers/IAST.h>
#include <Parsers/ASTLiteral.h>
#include <Common/typeid_cast.h>

View File

@ -1,10 +1,7 @@
#include <Compression/CompressionFactory.h>
#include <Parsers/parseQuery.h>
#include <Parsers/ParserCreateQuery.h>
#include <Parsers/ASTFunction.h>
#include <Parsers/ASTIdentifier.h>
#include <Parsers/ASTLiteral.h>
#include <Common/typeid_cast.h>
#include <Poco/String.h>
#include <IO/ReadBuffer.h>
#include <Parsers/queryToString.h>

View File

@ -2,8 +2,6 @@
#include <string.h>
#include <iostream>
#include <random>
#include <algorithm>
#include <Core/Defines.h>
#include <Common/Stopwatch.h>
#include <common/types.h>

View File

@ -1,11 +1,9 @@
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <Core/Types.h>
#include <Common/Stopwatch.h>
#include <IO/WriteBufferFromFile.h>
#include <IO/ReadBufferFromFile.h>

View File

@ -11,8 +11,6 @@
#include <Parsers/IParser.h>
#include <Parsers/TokenIterator.h>
#include <fmt/format.h>
#include <random>
#include <bitset>
#include <cmath>

View File

@ -6,13 +6,11 @@
#include <IO/WriteBufferFromString.h>
#include <IO/Operators.h>
#include <Common/typeid_cast.h>
#include <Common/assert_cast.h>
#include <Columns/ColumnConst.h>
#include <iterator>
#include <memory>
namespace DB

View File

@ -1,6 +1,5 @@
#include <Core/ColumnsWithTypeAndName.h>
#include <IO/WriteBufferFromString.h>
#include <IO/WriteHelpers.h>
#include <IO/Operators.h>

View File

@ -7,7 +7,6 @@
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeEnum.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
namespace DB

View File

@ -1,12 +1,10 @@
#include <iostream>
#include <iomanip>
#include <sstream>
#include <Core/Field.h>
#include <Common/FieldVisitors.h>
#include <Common/Stopwatch.h>
#include <IO/WriteBufferFromFileDescriptor.h>
#include <IO/ReadHelpers.h>
#include <DataTypes/DataTypeString.h>

View File

@ -1,4 +1,3 @@
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnTuple.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypeCustom.h>

View File

@ -4,7 +4,6 @@
#include <DataTypes/DataTypeCustomSimpleTextSerialization.h>
#include <DataTypes/DataTypeFactory.h>
#include <DataTypes/DataTypeCustom.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionsCoding.h>
namespace DB

View File

@ -1,14 +1,9 @@
#include <Common/FieldVisitors.h>
#include <Common/typeid_cast.h>
#include <IO/ReadHelpers.h>
#include <Columns/ColumnAggregateFunction.h>
#include <DataTypes/DataTypeCustomSimpleAggregateFunction.h>
#include <DataTypes/DataTypeLowCardinality.h>
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypeFactory.h>
#include <AggregateFunctions/AggregateFunctionFactory.h>

View File

@ -1,10 +1,7 @@
#include <DataTypes/DataTypeDateTime.h>
#include <Columns/ColumnDecimal.h>
#include <Columns/ColumnVector.h>
#include <Columns/ColumnsNumber.h>
#include <Common/assert_cast.h>
#include <Common/typeid_cast.h>
#include <common/DateLUT.h>
#include <DataTypes/DataTypeFactory.h>
#include <Formats/FormatSettings.h>

View File

@ -1,8 +1,6 @@
#include <DataTypes/DataTypeDateTime64.h>
#include <Columns/ColumnDecimal.h>
#include <Columns/ColumnVector.h>
#include <Columns/ColumnsNumber.h>
#include <Common/assert_cast.h>
#include <Common/typeid_cast.h>
#include <common/DateLUT.h>

View File

@ -1,5 +1,4 @@
#include <Columns/ColumnFixedString.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnConst.h>
#include <Formats/FormatSettings.h>

View File

@ -1,7 +1,6 @@
#include <Core/Defines.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnConst.h>
#include <Common/typeid_cast.h>

View File

@ -3,7 +3,6 @@
#include <Parsers/IAST.h>
#include <Parsers/ASTLiteral.h>
namespace DB

View File

@ -4,8 +4,6 @@
#include <Common/Exception.h>
#include <Common/escapeForFileName.h>
#include <Core/Defines.h>
#include <IO/WriteHelpers.h>
#include <DataTypes/IDataType.h>

View File

@ -1,6 +1,5 @@
#include "CacheDictionary.h"
#include <functional>
#include <memory>
#include <Columns/ColumnString.h>
#include <Common/BitHelpers.h>

View File

@ -1,16 +1,8 @@
#include <iostream>
#include <sstream>
#include <Core/Types.h>
#include <Poco/Util/XMLConfiguration.h>
#include <Parsers/ASTCreateQuery.h>
#include <Parsers/ASTDropQuery.h>
#include <Parsers/DumpASTNode.h>
#include <Parsers/ParserCreateQuery.h>
#include <Parsers/ParserDictionary.h>
#include <Parsers/ParserDropQuery.h>
#include <Parsers/ParserTablePropertiesQuery.h>
#include <Parsers/TablePropertiesQueriesASTs.h>
#include <Parsers/formatAST.h>
#include <Parsers/parseQuery.h>
#include <Dictionaries/getDictionaryConfigurationFromAST.h>

View File

@ -1,7 +1,6 @@
#include "ProtobufColumnMatcher.h"
#if USE_PROTOBUF
#include <Common/Exception.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <Poco/String.h>

View File

@ -1,7 +1,6 @@
#include <string>
#include <iostream>
#include <fstream>
#include <IO/ReadBufferFromFile.h>
#include <IO/WriteBufferFromFile.h>

View File

@ -8,7 +8,6 @@
#include <Common/assert_cast.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypeLowCardinality.h>
#include <IO/WriteHelpers.h>
namespace DB

View File

@ -4,8 +4,6 @@
#include <Interpreters/Context.h>
#include <Interpreters/ExternalModelsLoader.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <Columns/ColumnString.h>
#include <ext/range.h>
#include <string>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionDateOrDateTimeAddInterval.h>

View File

@ -1,6 +1,5 @@
#if defined(__ELF__) && !defined(__FreeBSD__)
#include <Common/Elf.h>
#include <Common/Dwarf.h>
#include <Common/SymbolIndex.h>
#include <Common/HashTable/HashMap.h>
@ -9,7 +8,6 @@
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypeString.h>
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionFactory.h>
#include <IO/WriteBufferFromArena.h>
#include <IO/WriteHelpers.h>

View File

@ -5,7 +5,6 @@
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypeString.h>
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionFactory.h>
#include <Access/AccessFlags.h>
#include <Interpreters/Context.h>

View File

@ -1,5 +1,4 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypeNullable.h>
#include <Core/ColumnNumbers.h>

View File

@ -1,5 +1,4 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypeString.h>
#include <Columns/ColumnString.h>

View File

@ -4,7 +4,6 @@
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/GatherUtils/Algorithms.h>
#include <Functions/GatherUtils/GatherUtils.h>
#include <Functions/GatherUtils/Sinks.h>
#include <Functions/GatherUtils/Slices.h>
#include <Functions/GatherUtils/Sources.h>

View File

@ -1,9 +1,7 @@
#include <common/demangle.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypeString.h>
#include <Functions/IFunction.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionFactory.h>
#include <IO/WriteHelpers.h>
#include <Access/AccessFlags.h>

View File

@ -1,6 +1,5 @@
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionsComparison.h>
#include <Functions/FunctionsLogical.h>
namespace DB

View File

@ -2,16 +2,12 @@
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <DataTypes/DataTypeAggregateFunction.h>
#include <DataTypes/DataTypesNumber.h>
#include <Columns/ColumnAggregateFunction.h>
#include <Common/typeid_cast.h>
#include <Columns/ColumnVector.h>
#include <Columns/ColumnsNumber.h>
#include <iostream>
#include <Common/PODArray.h>
#include <Columns/ColumnArray.h>
namespace DB
{

View File

@ -9,7 +9,6 @@
#include <memory>
#include <string>
#include <vector>
namespace DB

View File

@ -5,12 +5,9 @@
#include <Functions/FunctionHelpers.h>
#include <Functions/IFunctionImpl.h>
#include <pcg_random.hpp>
#include <Common/UTF8Helpers.h>
#include <Common/randomSeed.h>
#include <common/arithmeticOverflow.h>
#include <common/defines.h>
#include <memory>
namespace DB

View File

@ -1,6 +1,5 @@
#include <array>
#include <math.h>
#include <Columns/ColumnConst.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>

View File

@ -6,7 +6,6 @@
#include <Columns/ColumnFixedString.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnTuple.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypesNumber.h>

View File

@ -1,5 +1,4 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/castTypeToEither.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypesNumber.h>

View File

@ -1,4 +0,0 @@
add_executable (number_traits number_traits.cpp)
add_executable (abtesting abtesting.cpp)
target_link_libraries (number_traits PRIVATE dbms)
target_link_libraries (abtesting PRIVATE clickhouse_functions)

View File

@ -1,3 +1,5 @@
#include <gtest/gtest.h>
#include <Functions/abtesting.h>
#include <iostream>
#include <stdio.h>
@ -61,34 +63,37 @@ Variants test_bayesab(std::string dist, PODArray<Float64> xs, PODArray<Float64>
}
int main(int, char **)
TEST(BayesAB, beta)
{
size_t max = 0, min = 0;
auto variants = test_bayesab("beta", {10000, 1000, 900}, {600, 110, 90}, max, min);
if (max != 1) exit(1);
ASSERT_EQ(1, max);
variants = test_bayesab("beta", {3000, 3000, 3000}, {600, 100, 90}, max, min);
if (max != 0) exit(1);
ASSERT_EQ(0, max);
variants = test_bayesab("beta", {3000, 3000, 3000}, {100, 90, 110}, max, min);
if (max != 2) exit(1);
ASSERT_EQ(2, max);
variants = test_bayesab("beta", {3000, 3000, 3000}, {110, 90, 100}, max, min);
if (max != 0) exit(1);
ASSERT_EQ(0, max);
}
variants = test_bayesab("gamma", {10000, 1000, 900}, {600, 110, 90}, max, min);
if (max != 1) exit(1);
TEST(BayesAB, gamma)
{
size_t max = 0, min = 0;
auto variants = test_bayesab("gamma", {10000, 1000, 900}, {600, 110, 90}, max, min);
ASSERT_EQ(1, max);
variants = test_bayesab("gamma", {3000, 3000, 3000}, {600, 100, 90}, max, min);
if (max != 0) exit(1);
ASSERT_EQ(0, max);
variants = test_bayesab("gamma", {3000, 3000, 3000}, {100, 90, 110}, max, min);
if (max != 2) exit(1);
ASSERT_EQ(2, max);
variants = test_bayesab("gamma", {3000, 3000, 3000}, {110, 90, 100}, max, min);
if (max != 0) exit(1);
std::cout << "Successfully done\n";
return 0;
ASSERT_EQ(0, max);
}

View File

@ -0,0 +1,201 @@
#include <gtest/gtest.h>
#include <iostream>
#include <map>
#include <DataTypes/NumberTraits.h>
static const std::map<std::pair<std::string, std::string>, std::string> answer =
{
{{"UInt8", "UInt8"}, "UInt8"},
{{"UInt8", "UInt16"}, "UInt16"},
{{"UInt8", "UInt32"}, "UInt32"},
{{"UInt8", "UInt64"}, "UInt64"},
{{"UInt8", "Int8"}, "Int16"},
{{"UInt8", "Int16"}, "Int16"},
{{"UInt8", "Int32"}, "Int32"},
{{"UInt8", "Int64"}, "Int64"},
{{"UInt8", "Float32"}, "Float32"},
{{"UInt8", "Float64"}, "Float64"},
{{"UInt16", "UInt8"}, "UInt16"},
{{"UInt16", "UInt16"}, "UInt16"},
{{"UInt16", "UInt32"}, "UInt32"},
{{"UInt16", "UInt64"}, "UInt64"},
{{"UInt16", "Int8"}, "Int32"},
{{"UInt16", "Int16"}, "Int32"},
{{"UInt16", "Int32"}, "Int32"},
{{"UInt16", "Int64"}, "Int64"},
{{"UInt16", "Float32"}, "Float32"},
{{"UInt16", "Float64"}, "Float64"},
{{"UInt32", "UInt8"}, "UInt32"},
{{"UInt32", "UInt16"}, "UInt32"},
{{"UInt32", "UInt32"}, "UInt32"},
{{"UInt32", "UInt64"}, "UInt64"},
{{"UInt32", "Int8"}, "Int64"},
{{"UInt32", "Int16"}, "Int64"},
{{"UInt32", "Int32"}, "Int64"},
{{"UInt32", "Int64"}, "Int64"},
{{"UInt32", "Float32"}, "Float64"},
{{"UInt32", "Float64"}, "Float64"},
{{"UInt64", "UInt8"}, "UInt64"},
{{"UInt64", "UInt16"}, "UInt64"},
{{"UInt64", "UInt32"}, "UInt64"},
{{"UInt64", "UInt64"}, "UInt64"},
{{"UInt64", "Int8"}, "Error"},
{{"UInt64", "Int16"}, "Error"},
{{"UInt64", "Int32"}, "Error"},
{{"UInt64", "Int64"}, "Error"},
{{"UInt64", "Float32"}, "Error"},
{{"UInt64", "Float64"}, "Error"},
{{"Int8", "UInt8"}, "Int16"},
{{"Int8", "UInt16"}, "Int32"},
{{"Int8", "UInt32"}, "Int64"},
{{"Int8", "UInt64"}, "Error"},
{{"Int8", "Int8"}, "Int8"},
{{"Int8", "Int16"}, "Int16"},
{{"Int8", "Int32"}, "Int32"},
{{"Int8", "Int64"}, "Int64"},
{{"Int8", "Float32"}, "Float32"},
{{"Int8", "Float64"}, "Float64"},
{{"Int16", "UInt8"}, "Int16"},
{{"Int16", "UInt16"}, "Int32"},
{{"Int16", "UInt32"}, "Int64"},
{{"Int16", "UInt64"}, "Error"},
{{"Int16", "Int8"}, "Int16"},
{{"Int16", "Int16"}, "Int16"},
{{"Int16", "Int32"}, "Int32"},
{{"Int16", "Int64"}, "Int64"},
{{"Int16", "Float32"}, "Float32"},
{{"Int16", "Float64"}, "Float64"},
{{"Int32", "UInt8"}, "Int32"},
{{"Int32", "UInt16"}, "Int32"},
{{"Int32", "UInt32"}, "Int64"},
{{"Int32", "UInt64"}, "Error"},
{{"Int32", "Int8"}, "Int32"},
{{"Int32", "Int16"}, "Int32"},
{{"Int32", "Int32"}, "Int32"},
{{"Int32", "Int64"}, "Int64"},
{{"Int32", "Float32"}, "Float64"},
{{"Int32", "Float64"}, "Float64"},
{{"Int64", "UInt8"}, "Int64"},
{{"Int64", "UInt16"}, "Int64"},
{{"Int64", "UInt32"}, "Int64"},
{{"Int64", "UInt64"}, "Error"},
{{"Int64", "Int8"}, "Int64"},
{{"Int64", "Int16"}, "Int64"},
{{"Int64", "Int32"}, "Int64"},
{{"Int64", "Int64"}, "Int64"},
{{"Int64", "Float32"}, "Error"},
{{"Int64", "Float64"}, "Error"},
{{"Float32", "UInt8"}, "Float32"},
{{"Float32", "UInt16"}, "Float32"},
{{"Float32", "UInt32"}, "Float64"},
{{"Float32", "UInt64"}, "Error"},
{{"Float32", "Int8"}, "Float32"},
{{"Float32", "Int16"}, "Float32"},
{{"Float32", "Int32"}, "Float64"},
{{"Float32", "Int64"}, "Error"},
{{"Float32", "Float32"}, "Float32"},
{{"Float32", "Float64"}, "Float64"},
{{"Float64", "UInt8"}, "Float64"},
{{"Float64", "UInt16"}, "Float64"},
{{"Float64", "UInt32"}, "Float64"},
{{"Float64", "UInt64"}, "Error"},
{{"Float64", "Int8"}, "Float64"},
{{"Float64", "Int16"}, "Float64"},
{{"Float64", "Int32"}, "Float64"},
{{"Float64", "Int64"}, "Error"},
{{"Float64", "Float32"}, "Float64"},
{{"Float64", "Float64"}, "Float64"}
};
static std::string getTypeString(DB::UInt8) { return "UInt8"; }
static std::string getTypeString(DB::UInt16) { return "UInt16"; }
static std::string getTypeString(DB::UInt32) { return "UInt32"; }
static std::string getTypeString(DB::UInt64) { return "UInt64"; }
static std::string getTypeString(DB::Int8) { return "Int8"; }
static std::string getTypeString(DB::Int16) { return "Int16"; }
static std::string getTypeString(DB::Int32) { return "Int32"; }
static std::string getTypeString(DB::Int64) { return "Int64"; }
static std::string getTypeString(DB::Float32) { return "Float32"; }
static std::string getTypeString(DB::Float64) { return "Float64"; }
static std::string getTypeString(DB::NumberTraits::Error) { return "Error"; }
template <typename T0, typename T1>
[[maybe_unused]] void printTypes()
{
std::cout << "{{\"";
std::cout << getTypeString(T0());
std::cout << "\", \"";
std::cout << getTypeString(T1());
std::cout << "\"}, \"";
std::cout << getTypeString(typename DB::NumberTraits::ResultOfIf<T0, T1>::Type());
std::cout << "\"},"<< std::endl;
}
template <typename T0, typename T1>
void ifRightType()
{
auto desired = getTypeString(typename DB::NumberTraits::ResultOfIf<T0, T1>::Type());
auto left = getTypeString(T0());
auto right = getTypeString(T1());
auto expected = answer.find({left, right});
ASSERT_TRUE(expected != answer.end());
ASSERT_EQ(expected->second, desired);
}
template <typename T0>
void ifLeftType()
{
ifRightType<T0, DB::UInt8>();
ifRightType<T0, DB::UInt16>();
ifRightType<T0, DB::UInt32>();
ifRightType<T0, DB::UInt64>();
ifRightType<T0, DB::Int8>();
ifRightType<T0, DB::Int16>();
ifRightType<T0, DB::Int32>();
ifRightType<T0, DB::Int64>();
ifRightType<T0, DB::Float32>();
ifRightType<T0, DB::Float64>();
}
TEST(NumberTraits, ResultOfAdditionMultiplication)
{
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::UInt8>::Type()), "UInt16");
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Int32>::Type()), "Int64");
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Float32>::Type()), "Float64");
}
TEST(NumberTraits, ResultOfSubtraction)
{
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfSubtraction<DB::UInt8, DB::UInt8>::Type()), "Int16");
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::UInt8>::Type()), "Int32");
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::Int8>::Type()), "Int32");
}
TEST(NumberTraits, Others)
{
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt16, DB::Int16>::Type()), "Float64");
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt32, DB::Int16>::Type()), "Float64");
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfIntegerDivision<DB::UInt8, DB::Int16>::Type()), "Int8");
ASSERT_EQ(getTypeString(DB::NumberTraits::ResultOfModulo<DB::UInt32, DB::Int8>::Type()), "Int8");
}
TEST(NumberTraits, FunctionIf)
{
ifLeftType<DB::UInt8>();
ifLeftType<DB::UInt16>();
ifLeftType<DB::UInt32>();
ifLeftType<DB::UInt64>();
ifLeftType<DB::Int8>();
ifLeftType<DB::Int16>();
ifLeftType<DB::Int32>();
ifLeftType<DB::Int64>();
ifLeftType<DB::Float32>();
ifLeftType<DB::Float64>();
}

View File

@ -1,69 +0,0 @@
#include <iostream>
#include <DataTypes/NumberTraits.h>
static void printType(DB::UInt8) { std::cout << "UInt8"; }
static void printType(DB::UInt16) { std::cout << "UInt16"; }
static void printType(DB::UInt32) { std::cout << "UInt32"; }
static void printType(DB::UInt64) { std::cout << "UInt64"; }
static void printType(DB::Int8) { std::cout << "Int8"; }
static void printType(DB::Int16) { std::cout << "Int16"; }
static void printType(DB::Int32) { std::cout << "Int32"; }
static void printType(DB::Int64) { std::cout << "Int64"; }
static void printType(DB::Float32) { std::cout << "Float32"; }
static void printType(DB::Float64) { std::cout << "Float64"; }
static void printType(DB::NumberTraits::Error) { std::cout << "Error"; }
template <typename T0, typename T1>
void ifRightType()
{
printType(T0());
std::cout << ", ";
printType(T1());
std::cout << " -> ";
printType(typename DB::NumberTraits::ResultOfIf<T0, T1>::Type());
std::cout << std::endl;
}
template <typename T0>
void ifLeftType()
{
ifRightType<T0, DB::UInt8>();
ifRightType<T0, DB::UInt16>();
ifRightType<T0, DB::UInt32>();
ifRightType<T0, DB::UInt64>();
ifRightType<T0, DB::Int8>();
ifRightType<T0, DB::Int16>();
ifRightType<T0, DB::Int32>();
ifRightType<T0, DB::Int64>();
ifRightType<T0, DB::Float32>();
ifRightType<T0, DB::Float64>();
}
int main(int, char **)
{
printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::UInt8>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Int32>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Float32>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt8, DB::UInt8>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::UInt8>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::Int8>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt16, DB::Int16>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt32, DB::Int16>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfIntegerDivision<DB::UInt8, DB::Int16>::Type()); std::cout << std::endl;
printType(DB::NumberTraits::ResultOfModulo<DB::UInt32, DB::Int8>::Type()); std::cout << std::endl;
ifLeftType<DB::UInt8>();
ifLeftType<DB::UInt16>();
ifLeftType<DB::UInt32>();
ifLeftType<DB::UInt64>();
ifLeftType<DB::Int8>();
ifLeftType<DB::Int16>();
ifLeftType<DB::Int32>();
ifLeftType<DB::Int64>();
ifLeftType<DB::Float32>();
ifLeftType<DB::Float64>();
return 0;
}

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeLowCardinality.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnLowCardinality.h>
#include <Common/typeid_cast.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,5 +1,4 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypeNullable.h>
#include <Columns/ColumnNullable.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,4 +1,3 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB

View File

@ -1,8 +1,6 @@
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB

Some files were not shown because too many files have changed in this diff Show More