mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Small clean up
This commit is contained in:
parent
dfc3db23b1
commit
fb4317f12c
@ -52,8 +52,6 @@ void optimizeFunctionEmpty(QueryTreeNodePtr &, FunctionNode & function_node, Col
|
||||
/// Replace `notEmpty(argument)` with `notEquals(argument.size0, 0)` if not positive
|
||||
/// `argument` may be Array or Map.
|
||||
|
||||
std::cerr << "optimizeFunctionEmpty " << ctx.column.name << "\n";
|
||||
|
||||
NameAndTypePair column{ctx.column.name + ".size0", std::make_shared<DataTypeUInt64>()};
|
||||
auto & function_arguments_nodes = function_node.getArguments().getNodes();
|
||||
|
||||
@ -236,18 +234,9 @@ std::tuple<FunctionNode *, ColumnNode *, TableNode *> getTypedNodesForOptimizati
|
||||
return {};
|
||||
|
||||
auto column_in_table = storage_snapshot->tryGetColumn(GetColumnsOptions::All, column.name);
|
||||
std::cerr << "getTypedNodesForOptimization " << column.name << "\n";
|
||||
if (!column_in_table || !column_in_table->type->equals(*column.type))
|
||||
{
|
||||
std::cerr << "getTypedNodesForOptimization FAIL\n";
|
||||
if (column_in_table)
|
||||
std::cerr << column_in_table->type->getName() << "/" << column.type->getName() << "\n";
|
||||
else
|
||||
std::cerr << "null\n";
|
||||
return {};
|
||||
}
|
||||
|
||||
std::cerr << "getTypedNodesForOptimization OK\n";
|
||||
return std::make_tuple(function_node, first_argument_column_node, table_node);
|
||||
}
|
||||
|
||||
@ -433,15 +422,9 @@ public:
|
||||
auto table_name = table_node->getStorage()->getStorageID().getFullTableName();
|
||||
|
||||
Identifier qualified_name({table_name, column.name});
|
||||
std::cerr << "FunctionToSubcolumnsVisitorSecondPass " << column.name << "\n";
|
||||
|
||||
if (!identifiers_to_optimize.contains(qualified_name))
|
||||
{
|
||||
std::cerr << "FunctionToSubcolumnsVisitorSecondPass FAIL\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "FunctionToSubcolumnsVisitorSecondPass OK\n";
|
||||
auto transformer_it = node_transformers.find({column.type->getTypeId(), function_node->getFunctionName()});
|
||||
if (transformer_it != node_transformers.end())
|
||||
{
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include <Common/FieldVisitorToString.h>
|
||||
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeFunction.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypeObjectDeprecated.h>
|
||||
#include <DataTypes/DataTypeSet.h>
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <DataTypes/DataTypeTuple.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypeFunction.h>
|
||||
#include <DataTypes/DataTypeSet.h>
|
||||
#include <DataTypes/getLeastSupertype.h>
|
||||
|
||||
#include <Functions/FunctionFactory.h>
|
||||
|
@ -130,7 +130,6 @@ std::pair<std::string_view, std::string_view> splitSubcolumnName(std::string_vie
|
||||
std::unique_ptr<IDataType::SubstreamData> DataTypeDynamic::getDynamicSubcolumnData(std::string_view subcolumn_name, const DB::IDataType::SubstreamData & data, bool throw_if_null) const
|
||||
{
|
||||
auto [subcolumn_type_name, subcolumn_nested_name] = splitSubcolumnName(subcolumn_name);
|
||||
// std::cerr << "Dynamic subcolumn: " << subcolumn_name << ", " << subcolumn_nested_name << "\n";
|
||||
|
||||
/// Check if requested subcolumn is a valid data type.
|
||||
auto subcolumn_type = DataTypeFactory::instance().tryGet(String(subcolumn_type_name));
|
||||
|
@ -3,28 +3,28 @@
|
||||
#include <Analyzer/FunctionNode.h>
|
||||
#include <Analyzer/QueryNode.h>
|
||||
#include <Analyzer/Utils.h>
|
||||
#include <DataTypes/ObjectUtils.h>
|
||||
#include <DataTypes/DataTypeObjectDeprecated.h>
|
||||
#include <DataTypes/DataTypeNothing.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/DataTypeNested.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <DataTypes/getLeastSupertype.h>
|
||||
#include <DataTypes/NestedUtils.h>
|
||||
#include <Storages/StorageSnapshot.h>
|
||||
#include <Columns/ColumnObjectDeprecated.h>
|
||||
#include <Columns/ColumnTuple.h>
|
||||
#include <Columns/ColumnArray.h>
|
||||
#include <Columns/ColumnMap.h>
|
||||
#include <Columns/ColumnNullable.h>
|
||||
#include <Columns/ColumnObjectDeprecated.h>
|
||||
#include <Columns/ColumnTuple.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypeNested.h>
|
||||
#include <DataTypes/DataTypeNothing.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypeObjectDeprecated.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/NestedUtils.h>
|
||||
#include <DataTypes/ObjectUtils.h>
|
||||
#include <DataTypes/getLeastSupertype.h>
|
||||
#include <IO/Operators.h>
|
||||
#include <Parsers/ASTExpressionList.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <Parsers/ASTLiteral.h>
|
||||
#include <Parsers/ASTSelectQuery.h>
|
||||
#include <Storages/StorageSnapshot.h>
|
||||
#include <Parsers/ASTExpressionList.h>
|
||||
#include <Parsers/ASTLiteral.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <IO/Operators.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
|
@ -491,69 +491,4 @@ State * ISerialization::checkAndGetState(const StatePtr & state, const ISerializ
|
||||
return state_concrete;
|
||||
}
|
||||
|
||||
|
||||
WITH snaps AS (
|
||||
SELECT
|
||||
rs.brokerfk brokerfk,
|
||||
rs.brokerinstancefk brokerinstancefk,
|
||||
rs.tradedt tradedt,
|
||||
min(rs.snapdttm) snapdttmmin,
|
||||
max(rs.snapdttm) snapdttmmax
|
||||
FROM risksnapshothistory rs
|
||||
WHERE rs.snapdttm >= now() - interval '10 minutes'
|
||||
AND rs.snapdttm <= now()
|
||||
GROUP BY rs.brokerfk, rs.brokerinstancefk, rs.tradedt
|
||||
ORDER BY rs.brokerfk, rs.brokerinstancefk, rs.tradedt
|
||||
),
|
||||
start_snaps_by_trade_dt AS (
|
||||
SELECT
|
||||
rs.*
|
||||
FROM risksnapshothistory rs
|
||||
WHERE (rs.brokerfk, rs.brokerinstancefk, rs.tradedt, rs.snapdttm) IN (
|
||||
SELECT
|
||||
s.brokerfk s_brokerfk,
|
||||
s.brokerinstancefk s_brokerinstancefk,
|
||||
s.tradedt s_tradedt,
|
||||
s.snapdttmmin s_snapdttmmin
|
||||
FROM snaps s)
|
||||
ORDER BY rs.brokerfk, rs.brokerinstancefk, rs.snapdttm
|
||||
),
|
||||
end_snaps_by_trade_dt AS (
|
||||
SELECT
|
||||
rs.*
|
||||
FROM risksnapshothistory rs
|
||||
WHERE (rs.brokerfk, rs.brokerinstancefk, rs.tradedt, rs.snapdttm) IN (
|
||||
SELECT
|
||||
s.brokerfk s_brokerfk,
|
||||
s.brokerinstancefk s_brokerinstancefk,
|
||||
s.tradedt s_tradedt,
|
||||
s.snapdttmmax s_snapdttmmax
|
||||
FROM snaps s)
|
||||
ORDER BY rs.brokerfk, rs.brokerinstancefk, rs.snapdttm
|
||||
),
|
||||
data as (
|
||||
SELECT
|
||||
ssbtd.snapdttm startdttm,
|
||||
esbtd.snapdttm enddttm,
|
||||
case when(ssbtd.snapdttm = '1970-01-01 00:00:00.000000') then 0 else 1 end hasstart,
|
||||
case when(esbtd.snapdttm = '1970-01-01 00:00:00.000000') then 0 else 1 end hasend,
|
||||
IF(esbtd.brokerfk = 0, ssbtd.brokerfk, esbtd.brokerfk) brokerfk,
|
||||
IF(esbtd.brokerinstancefk = 0, ssbtd.brokerinstancefk, esbtd.brokerinstancefk) brokerinstancefk
|
||||
FROM start_snaps_by_trade_dt ssbtd
|
||||
FULL OUTER JOIN end_snaps_by_trade_dt esbtd ON ssbtd.brokerfk = esbtd.brokerfk AND ssbtd.brokerinstancefk = esbtd.brokerinstancefk AND ssbtd.tradedt = esbtd.tradedt AND ssbtd.traderfk = esbtd.traderfk AND ssbtd.brokersymbolfk = esbtd.brokersymbolfk
|
||||
)
|
||||
SELECT
|
||||
d.brokerfk, d.brokerinstancefk,
|
||||
max(startdttm) startdttm,
|
||||
max(enddttm) enddttm,
|
||||
countIf(d.hasstart =1 and d.hasend=1) matches,
|
||||
countIf(d.hasstart =1 and d.hasend=0) beforeonly,
|
||||
countIf(d.hasstart =0 and d.hasend=1) afteronly,
|
||||
(select array_agg(toJSONString(map(
|
||||
'snapdttmmax', toString(snapdttmmax), 'snapdttmmin', toString(snapdttmmin),
|
||||
'tradedt', toString(tradedt), 'brokerfk', toString(brokerfk), 'brokerinstancefk', toString(brokerinstancefk))))
|
||||
from snaps) snaps
|
||||
FROM data d
|
||||
GROUP BY d.brokerfk, d.brokerinstancefk
|
||||
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
//
|
||||
// Created by Павел Круглов on 05/07/2024.
|
||||
//
|
@ -1,8 +0,0 @@
|
||||
//
|
||||
// Created by Павел Круглов on 05/07/2024.
|
||||
//
|
||||
|
||||
#ifndef CLICKHOUSE_SERIALIZATIONJSONELEMENT_H
|
||||
#define CLICKHOUSE_SERIALIZATIONJSONELEMENT_H
|
||||
|
||||
#endif //CLICKHOUSE_SERIALIZATIONJSONELEMENT_H
|
@ -1,3 +0,0 @@
|
||||
//
|
||||
// Created by Павел Круглов on 05/07/2024.
|
||||
//
|
@ -1,8 +0,0 @@
|
||||
//
|
||||
// Created by Павел Круглов on 05/07/2024.
|
||||
//
|
||||
|
||||
#ifndef CLICKHOUSE_SERIALIZATIONJSONELEMENT_H
|
||||
#define CLICKHOUSE_SERIALIZATIONJSONELEMENT_H
|
||||
|
||||
#endif //CLICKHOUSE_SERIALIZATIONJSONELEMENT_H
|
@ -32,7 +32,7 @@ extern const int UNSUPPORTED_METHOD;
|
||||
|
||||
void check(const DataTypePtr & type)
|
||||
{
|
||||
std::cerr << "Check " << type->getName() << "\n";
|
||||
// std::cerr << "Check " << type->getName() << "\n";
|
||||
WriteBufferFromOwnString ostr;
|
||||
encodeDataType(type, ostr);
|
||||
ReadBufferFromString istr(ostr.str());
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypeObjectDeprecated.h>
|
||||
#include <DataTypes/Serializations/SerializationNullable.h>
|
||||
#include <Formats/EscapingRuleUtils.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <Formats/JSONUtils.h>
|
||||
#include <Formats/ReadSchemaUtils.h>
|
||||
#include <Formats/EscapingRuleUtils.h>
|
||||
#include <IO/ReadBufferFromString.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteBufferValidUTF8.h>
|
||||
#include <DataTypes/Serializations/SerializationNullable.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypeObjectDeprecated.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
|
||||
#include <base/find_symbols.h>
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeDate.h>
|
||||
#include <DataTypes/DataTypeDateTime.h>
|
||||
#include <DataTypes/DataTypeDateTime64.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <DataTypes/DataTypeLowCardinality.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypeNothing.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypeObjectDeprecated.h>
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <DataTypes/DataTypeTuple.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/transformTypesRecursively.h>
|
||||
#include <Formats/SchemaInferenceUtils.h>
|
||||
#include <IO/PeekableReadBuffer.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <DataTypes/DataTypeDateTime64.h>
|
||||
#include <DataTypes/DataTypeDateTime.h>
|
||||
#include <DataTypes/DataTypeDate.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeTuple.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypeLowCardinality.h>
|
||||
#include <DataTypes/DataTypeNothing.h>
|
||||
#include <DataTypes/transformTypesRecursively.h>
|
||||
#include <DataTypes/DataTypeObjectDeprecated.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <IO/ReadBufferFromString.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/parseDateTimeBestEffort.h>
|
||||
#include <IO/PeekableReadBuffer.h>
|
||||
#include <IO/readFloatText.h>
|
||||
|
||||
#include <Core/Block.h>
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <Columns/ColumnAggregateFunction.h>
|
||||
#include <Columns/ColumnArray.h>
|
||||
#include <Columns/ColumnConst.h>
|
||||
#include <Columns/ColumnDynamic.h>
|
||||
#include <Columns/ColumnFixedString.h>
|
||||
#include <Columns/ColumnLowCardinality.h>
|
||||
#include <Columns/ColumnMap.h>
|
||||
@ -16,6 +15,7 @@
|
||||
#include <Columns/ColumnStringHelpers.h>
|
||||
#include <Columns/ColumnTuple.h>
|
||||
#include <Columns/ColumnVariant.h>
|
||||
#include <Columns/ColumnDynamic.h>
|
||||
#include <Columns/ColumnsCommon.h>
|
||||
#include <Core/AccurateComparison.h>
|
||||
#include <Core/Types.h>
|
||||
@ -25,7 +25,6 @@
|
||||
#include <DataTypes/DataTypeDate32.h>
|
||||
#include <DataTypes/DataTypeDateTime.h>
|
||||
#include <DataTypes/DataTypeDateTime64.h>
|
||||
#include <DataTypes/DataTypeDynamic.h>
|
||||
#include <DataTypes/DataTypeEnum.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <DataTypes/DataTypeFixedString.h>
|
||||
@ -42,12 +41,13 @@
|
||||
#include <DataTypes/DataTypeTuple.h>
|
||||
#include <DataTypes/DataTypeUUID.h>
|
||||
#include <DataTypes/DataTypeVariant.h>
|
||||
#include <DataTypes/DataTypeDynamic.h>
|
||||
#include <DataTypes/DataTypesDecimal.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/ObjectUtils.h>
|
||||
#include <DataTypes/Serializations/SerializationDecimal.h>
|
||||
#include <Formats/FormatFactory.h>
|
||||
#include <Formats/FormatSettings.h>
|
||||
#include <Formats/FormatFactory.h>
|
||||
#include <Functions/CastOverloadResolver.h>
|
||||
#include <Functions/DateTimeTransforms.h>
|
||||
#include <Functions/FunctionFactory.h>
|
||||
@ -4020,6 +4020,7 @@ private:
|
||||
/// TODO: support CAST between JSON types with different parameters
|
||||
/// support CAST from Map to JSON
|
||||
/// support CAST from Tuple to JSON
|
||||
/// support CAST from Object('json') to JSON
|
||||
throw Exception(ErrorCodes::TYPE_MISMATCH, "Cast to {} can be performed only from String. Got: {}", magic_enum::enum_name(to_object->getSchemaFormat()), from_type->getName());
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <Parsers/ParserCreateQuery.h>
|
||||
#include <Common/StringUtils.h>
|
||||
|
||||
#include <Common/logger_useful.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user