Skip to content

Commit

Permalink
Fix special NewDecimal type passed from TiDB (#4329)
Browse files Browse the repository at this point in the history
close #4147
  • Loading branch information
yibin87 authored Mar 22, 2022
1 parent e919a61 commit 288aa19
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dbms/src/Flash/Coprocessor/DAGUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,11 +990,12 @@ String getColumnNameForColumnExpr(const tipb::Expr & expr, const std::vector<Nam
// So far the known invalid field types are:
// 1. decimal type with scale == -1
// 2. decimal type with precision == 0
// 3. decimal type with precision == -1
bool exprHasValidFieldType(const tipb::Expr & expr)
{
return expr.has_field_type()
&& !(expr.field_type().tp() == TiDB::TP::TypeNewDecimal
&& (expr.field_type().decimal() == -1 || expr.field_type().flen() == 0));
&& (expr.field_type().decimal() == -1 || expr.field_type().flen() == 0 || expr.field_type().flen() == -1));
}

bool isUnsupportedEncodeType(const std::vector<tipb::FieldType> & types, tipb::EncodeType encode_type)
Expand Down
26 changes: 26 additions & 0 deletions tests/fullstack-test/expr/special_new_decimal_type.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022 PingCAP, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

mysql> drop table if exists test.t
mysql> create table test.t(a int primary key)
mysql> alter table test.t set tiflash replica 1
func> wait_table test t
mysql> set tidb_enforce_mpp=1; select count(*) from test.t where case when a then isnull(a) else 12.991 end;
+----------+
| count(*) |
+----------+
| 0 |
+----------+

mysql> drop table test.t

0 comments on commit 288aa19

Please sign in to comment.