diff --git a/src/storage/column_store/ob_co_sstable_row_scanner.cpp b/src/storage/column_store/ob_co_sstable_row_scanner.cpp index d4744773c9..91fe945eaf 100644 --- a/src/storage/column_store/ob_co_sstable_row_scanner.cpp +++ b/src/storage/column_store/ob_co_sstable_row_scanner.cpp @@ -411,15 +411,17 @@ int ObCOSSTableRowScanner::construct_cg_iter_params_for_single_row( } else { ObTableIterParam* cg_param = nullptr; const common::ObIArray *access_cgs = nullptr; - const int64_t schema_rowkey_cnt = row_param.get_read_info()->get_schema_rowkey_count(); + const int64_t rowkey_cnt = row_param.get_read_info()->get_rowkey_count(); + const ObColumnIndexArray &cols_index = row_param.get_read_info()->get_columns_index(); if (OB_ISNULL(access_cgs = row_param.get_read_info()->get_cg_idxs())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("Unexpected null access cg index", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < row_param.out_cols_project_->count(); ++i) { const int32_t col_offset = row_param.out_cols_project_->at(i); + const int32_t col_index = cols_index.at(col_offset); sql::ObExpr* expr = row_param.output_exprs_ == nullptr ? nullptr : row_param.output_exprs_->at(i); - if ((nullptr == expr || !is_group_idx_expr(expr)) && col_offset >= schema_rowkey_cnt) { + if ((nullptr == expr || !is_group_idx_expr(expr)) && col_index >= rowkey_cnt) { int32_t cg_idx = access_cgs->at(col_offset); if (OB_FAIL(cg_param_pool_->get_iter_param(cg_idx, row_param, expr, cg_param))) { LOG_WARN("Fail to get cg iter param", K(ret), K(i), K(cg_idx), K(row_param), KPC(access_cgs)); @@ -450,7 +452,6 @@ int ObCOSSTableRowScanner::construct_cg_iter_params( } else { ObTableIterParam* cg_param = nullptr; const common::ObIArray *access_cgs = nullptr; - const int64_t schema_rowkey_cnt = row_param.get_read_info()->get_schema_rowkey_count(); // Assert only one column in one column group if (row_param.enable_pd_aggregate()) { if (OB_FAIL(construct_cg_agg_iter_params(row_param, context, iter_params))) { @@ -470,7 +471,6 @@ int ObCOSSTableRowScanner::construct_cg_iter_params( } else { int32_t idx = 0; for (int64_t i = 0; OB_SUCC(ret) && i < row_param.output_exprs_->count(); ++i) { - const int32_t col_offset = row_param.out_cols_project_->at(i); const bool need_iter_param = (nullptr == row_param.output_sel_mask_ || row_param.output_sel_mask_->at(i)); if (!is_group_idx_expr(row_param.output_exprs_->at(i)) && need_iter_param) { int32_t cg_idx = access_cgs->at(row_param.out_cols_project_->at(i));