diff --git a/src/Storages/MergeTree/KeyCondition.cpp b/src/Storages/MergeTree/KeyCondition.cpp index ed686a0b38b..b8ef2152a99 100644 --- a/src/Storages/MergeTree/KeyCondition.cpp +++ b/src/Storages/MergeTree/KeyCondition.cpp @@ -1183,7 +1183,7 @@ bool KeyCondition::tryPrepareSetIndex( /// Note: in case of ActionsDAG, tuple may be a constant. /// In this case, there is no keys in tuple. So, we don't have to check it. auto left_arg_tuple = left_arg.toFunctionNode(); - if (left_arg_tuple.getFunctionName() == "tuple") + if (left_arg_tuple.getFunctionName() == "tuple" && left_arg_tuple.getArgumentsSize() > 1) { left_args_count = left_arg_tuple.getArgumentsSize(); for (size_t i = 0; i < left_args_count; ++i) diff --git a/tests/queries/0_stateless/02731_in_operator_with_one_size_tuple.reference b/tests/queries/0_stateless/02731_in_operator_with_one_size_tuple.reference new file mode 100644 index 00000000000..d7ede115bc2 --- /dev/null +++ b/tests/queries/0_stateless/02731_in_operator_with_one_size_tuple.reference @@ -0,0 +1,2 @@ +2023-04-17 1 +2023-04-17 1 diff --git a/tests/queries/0_stateless/02731_in_operator_with_one_size_tuple.sql b/tests/queries/0_stateless/02731_in_operator_with_one_size_tuple.sql new file mode 100644 index 00000000000..eab7d24a92e --- /dev/null +++ b/tests/queries/0_stateless/02731_in_operator_with_one_size_tuple.sql @@ -0,0 +1,10 @@ +CREATE TABLE test(`report_date` Date, `sspid` UInt64) ENGINE MergeTree PARTITION BY report_date ORDER BY report_date; + +INSERT INTO test SELECT toDate('2023-04-20'), 0; +INSERT INTO test SELECT toDate('2023-04-19'), 0; +INSERT INTO test SELECT toDate('2023-04-17'), 1; +INSERT INTO test SELECT toDate('2023-04-17'), 1; + + +SELECT * FROM test WHERE tuple(report_date) IN tuple(toDate('2023-04-17')); +DROP TABLE test; \ No newline at end of file