Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug that results of where <string> is wrong because it will be converted to int type. (#3463) #3478

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dbms/src/Flash/Coprocessor/DAGExpressionAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ String DAGExpressionAnalyzer::convertToUInt8(ExpressionActionsPtr & actions, con
// the basic rule is:
// 1. if the column is only null, just return it is fine
// 2. if the column is numeric, compare it with 0
// 3. if the column is string, convert it to numeric column, and compare with 0
// 3. if the column is string, convert it to float-point column, and compare with 0
// 4. if the column is date/datetime, compare it with zeroDate
// 5. if the column is other type, throw exception
if (actions->getSampleBlock().getByName(column_name).type->onlyNull())
Expand All @@ -629,9 +629,10 @@ String DAGExpressionAnalyzer::convertToUInt8(ExpressionActionsPtr & actions, con
/// use tidb_cast to make it compatible with TiDB
tipb::FieldType field_type;
// TODO: Use TypeDouble as return type, to be compatible with TiDB
field_type.set_tp(TiDB::TypeLongLong);
field_type.set_tp(TiDB::TypeDouble);
field_type.set_flen(-1);
tipb::Expr type_expr;
constructStringLiteralTiExpr(type_expr, "Nullable(Int64)");
constructStringLiteralTiExpr(type_expr, "Nullable(Double)");
auto type_expr_name = getActions(type_expr, actions);
String num_col_name = buildCastFunctionInternal(this, {column_name, type_expr_name}, false, field_type, actions);

Expand Down
15 changes: 15 additions & 0 deletions tests/fullstack-test/expr/issue_3447.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mysql> drop table if exists test.t;
mysql> create table test.t(a char(5));
mysql> alter table test.t set tiflash replica 1;
mysql> insert into test.t values ('0.1'), ('-0.1'), ('0.0'), ('-1'), ('a0.1'), ('0x01');

func> wait_table test t
mysql> select /*+ read_from_storage(tiflash[t]) */ * from test.t where a;
+------+
| a |
+------+
| 0.1 |
| -0.1 |
| -1 |
| 0x01 |
+------+