From c619a17d9d0bf8c8da6585799b2a706a1776176d Mon Sep 17 00:00:00 2001 From: evenyag Date: Tue, 15 Aug 2023 21:26:37 +0800 Subject: [PATCH] feat: sort fields by column id --- src/mito2/src/read.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mito2/src/read.rs b/src/mito2/src/read.rs index ac0112f56b59..94747c1eec01 100644 --- a/src/mito2/src/read.rs +++ b/src/mito2/src/read.rs @@ -47,6 +47,9 @@ pub struct Batch { /// UInt8 type, not null. op_types: Arc, /// Fields organized in columnar format. + /// + /// Fields are ordered by their column id so the batch after projection + /// is always consistent. fields: Vec, } @@ -261,6 +264,8 @@ impl BatchBuilder { } ); } + // Sort fields by column id. + self.fields.sort_unstable_by_key(|field| field.column_id); Ok(Batch { primary_key: self.primary_key,