seokjin0414 commented on code in PR #3799: URL: https://github.com/apache/iggy/pull/3799#discussion_r4161976544
########## core/connectors/sources/fluss_source/src/mapping.rs: ########## @@ -0,0 +1,355 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use base64::Engine; +use base64::engine::general_purpose::STANDARD as BASE64; +use chrono::{DateTime, NaiveDate, NaiveTime, Utc}; +use fluss::metadata::{DataField, DataType}; +use fluss::row::InternalRow; +use iggy_connector_sdk::Error; +use serde_json::{Map, Number, Value}; + +const MILLIS_PER_SECOND: i64 = 1_000; +const NANOS_PER_MILLI: i64 = 1_000_000; + +/// Temporal values are formatted with their full fractional precision, the way the +/// PostgreSQL source formats them. A number of milliseconds would drop the microseconds of +/// the default `TIMESTAMP(6)`. `TIMESTAMP` carries no timezone and is written without one, +/// while `TIMESTAMP_LTZ` is an instant and is written in UTC. +pub(crate) fn row_to_json( + row: &dyn InternalRow, + fields: &[DataField], +) -> Result<Map<String, Value>, Error> { + let mut object = Map::with_capacity(fields.len()); + for (position, field) in fields.iter().enumerate() { + let value = read_field(row, position, field.data_type())?; + object.insert(field.name().to_owned(), value); Review Comment: Fixed in f8151c1. `JsonRow` now writes each row straight into the payload, borrowing column names and string values. On random rows and schemas it produces the same keys and values as the old map-based mapping. Keys now always come in column order, where the old map sorted them by name unless serde_json's `preserve_order` was unified into the build. -- 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]
