Skip to content

Commit

Permalink
*: fix tipb::ColumnInfo to TiDB::ColumnInfo (#9086) (#9089)
Browse files Browse the repository at this point in the history
close #9084, close #9085

fix the issue that query result may be wrong when query missing columns with default value in Disaggrate TiFlash.

Signed-off-by: Lloyd-Pottiger <[email protected]>

Co-authored-by: Lloyd-Pottiger <[email protected]>
Co-authored-by: Lloyd-Pottiger <[email protected]>
Co-authored-by: JaySon <[email protected]>
  • Loading branch information
4 people authored May 27, 2024
1 parent c183800 commit 8e8e369
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbms/src/Flash/Coprocessor/GenSchemaAndColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <TiDB/Decode/TypeMapping.h>
#include <TiDB/Schema/TiDB.h>


namespace DB
{
namespace
Expand Down Expand Up @@ -121,7 +122,6 @@ std::tuple<DM::ColumnDefinesPtr, int> genColumnDefinesForDisaggregatedRead(const
break;
}
default:
// TODO: Is it ok to use the default value here?
column_defines->emplace_back(DM::ColumnDefine{
column_info.id,
output_name,
Expand Down
5 changes: 5 additions & 0 deletions dbms/src/TiDB/Schema/TiDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,11 @@ ColumnInfo toTiDBColumnInfo(const tipb::ColumnInfo & tipb_column_info)
tidb_column_info.flag = tipb_column_info.flag();
tidb_column_info.flen = tipb_column_info.columnlen();
tidb_column_info.decimal = tipb_column_info.decimal();
// TiFlash get default value from origin_default_value, check `Field ColumnInfo::defaultValueToField() const`
// So we need to set origin_default_value to tipb_column_info.default_val()
// Related logic in tidb, https://github.com/pingcap/tidb/blob/45318da24d8e4c0c6aab836d291a33f949dd18bf/pkg/table/tables/tables.go#L2303-L2329
tidb_column_info.origin_default_value = tipb_column_info.default_val();
tidb_column_info.collate = tipb_column_info.collation();
for (int i = 0; i < tipb_column_info.elems_size(); ++i)
tidb_column_info.elems.emplace_back(tipb_column_info.elems(i), i + 1);
return tidb_column_info;
Expand Down

0 comments on commit 8e8e369

Please sign in to comment.