fresh-borzoni commented on code in PR #288:
URL: https://github.com/apache/fluss-rust/pull/288#discussion_r2780060710


##########
bindings/cpp/src/types.rs:
##########
@@ -646,6 +646,151 @@ fn core_row_to_ffi_fields(
     fields
 }
 
+impl Default for ffi::FfiDatum {
+    fn default() -> Self {
+        Self {
+            datum_type: DATUM_TYPE_NULL,
+            bool_val: false,
+            i32_val: 0,
+            i64_val: 0,
+            f32_val: 0.0,
+            f64_val: 0.0,
+            string_val: String::new(),
+            bytes_val: vec![],
+            decimal_precision: 0,
+            decimal_scale: 0,
+            i128_hi: 0,
+            i128_lo: 0,
+        }
+    }
+}
+
+/// Convert any InternalRow to FfiGenericRow using Fluss schema metadata.
+/// Used for lookup results (CompactedRow) where Arrow schema is unavailable.
+pub fn internal_row_to_ffi_row(
+    row: &dyn fcore::row::InternalRow,
+    table_info: &fcore::metadata::TableInfo,
+) -> Result<ffi::FfiGenericRow> {
+    let schema = table_info.get_schema();
+    let columns = schema.columns();
+    let mut fields = Vec::with_capacity(columns.len());
+
+    for (i, col) in columns.iter().enumerate() {
+        if row.is_null_at(i) {
+            fields.push(ffi::FfiDatum::default());
+            continue;
+        }
+
+        let datum = match col.data_type() {
+            fcore::metadata::DataType::Boolean(_) => ffi::FfiDatum {
+                datum_type: DATUM_TYPE_BOOL,
+                bool_val: row.get_boolean(i),
+                ..Default::default()
+            },
+            fcore::metadata::DataType::TinyInt(_) => ffi::FfiDatum {
+                datum_type: DATUM_TYPE_INT32,
+                i32_val: row.get_byte(i) as i32,
+                ..Default::default()
+            },
+            fcore::metadata::DataType::SmallInt(_) => ffi::FfiDatum {
+                datum_type: DATUM_TYPE_INT32,
+                i32_val: row.get_short(i) as i32,
+                ..Default::default()
+            },

Review Comment:
   Yeah, this a bug here, let me fix it and review this path more thoroughly



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to