mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Merge pull request #42469 from amosbird/issue_42456
Fix misbehavior of key analysis
This commit is contained in:
commit
f64e632707
@ -236,10 +236,11 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
|
||||
}
|
||||
|
||||
if (which_type.isDateTime64()
|
||||
&& (which_from_type.isNativeInt() || which_from_type.isNativeUInt() || which_from_type.isDate() || which_from_type.isDate32() || which_from_type.isDateTime() || which_from_type.isDateTime64()))
|
||||
&& (src.getType() == Field::Types::UInt64 || src.getType() == Field::Types::Int64 || src.getType() == Field::Types::Decimal64))
|
||||
{
|
||||
const auto scale = static_cast<const DataTypeDateTime64 &>(type).getScale();
|
||||
const auto decimal_value = DecimalUtils::decimalFromComponents<DateTime64>(applyVisitor(FieldVisitorConvertToNumber<Int64>(), src), 0, scale);
|
||||
const auto decimal_value
|
||||
= DecimalUtils::decimalFromComponents<DateTime64>(applyVisitor(FieldVisitorConvertToNumber<Int64>(), src), 0, scale);
|
||||
return Field(DecimalField<DateTime64>(decimal_value, scale));
|
||||
}
|
||||
}
|
||||
|
@ -1197,7 +1197,8 @@ bool KeyCondition::transformConstantWithValidFunctions(
|
||||
|
||||
if (is_valid_chain)
|
||||
{
|
||||
auto const_type = cur_node->result_type;
|
||||
out_type = removeLowCardinality(out_type);
|
||||
auto const_type = removeLowCardinality(cur_node->result_type);
|
||||
auto const_column = out_type->createColumnConst(1, out_value);
|
||||
auto const_value = (*castColumnAccurateOrNull({const_column, out_type, ""}, const_type))[0];
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
printer1
|
@ -0,0 +1,9 @@
|
||||
drop table if exists test;
|
||||
|
||||
create table test (Printer LowCardinality(String), IntervalStart DateTime) engine MergeTree partition by (hiveHash(Printer), toYear(IntervalStart)) order by (Printer, IntervalStart);
|
||||
|
||||
insert into test values ('printer1', '2006-02-07 06:28:15');
|
||||
|
||||
select Printer from test where Printer='printer1';
|
||||
|
||||
drop table test;
|
Loading…
Reference in New Issue
Block a user