Skip to content

Commit

Permalink
add log
Browse files Browse the repository at this point in the history
  • Loading branch information
wenym1 committed Nov 4, 2024
1 parent cc1def9 commit 7fd5a68
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/connector/src/parser/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::sync::LazyLock;

use mysql_async::Row as MysqlRow;
use risingwave_common::catalog::Schema;
use risingwave_common::log::LogSuppresser;
use risingwave_common::row::OwnedRow;
use thiserror_ext::AsReport;

use crate::parser::util::log_error;

static LOG_SUPPERSSER: LazyLock<LogSuppresser> = LazyLock::new(LogSuppresser::default);
use anyhow::anyhow;
use chrono::NaiveDate;
use mysql_async::Row as MysqlRow;
use risingwave_common::bail;
use risingwave_common::catalog::Schema;
use risingwave_common::row::OwnedRow;
use risingwave_common::types::{
DataType, Date, Datum, Decimal, JsonbVal, ScalarImpl, Time, Timestamp, Timestamptz,
};
use rust_decimal::Decimal as RustDecimal;
use thiserror_ext::AsReport;
use tracing::error;

macro_rules! handle_data_type {
($row:expr, $i:expr, $name:expr, $type:ty) => {{
Expand All @@ -56,7 +50,7 @@ macro_rules! handle_data_type {
"column: {}, index: {}, rust_type: {}",
$name,
$i,
stringify!($ty),
stringify!($type),
))),
}
}};
Expand Down Expand Up @@ -200,14 +194,19 @@ pub fn mysql_datum_to_rw_datum(
}

pub fn mysql_row_to_owned_row(mysql_row: &mut MysqlRow, schema: &Schema) -> OwnedRow {
// TODO: recover the debug string
let debug_string = format!(
"mysql_row_to_owned_row: row: [{:?}], schema: {:?}",
mysql_row, schema
);
let mut datums = vec![];
for i in 0..schema.fields.len() {
let rw_field = &schema.fields[i];
let name = rw_field.name.as_str();
let datum = match mysql_datum_to_rw_datum(mysql_row, i, name, &rw_field.data_type) {
Ok(val) => val,
Err(e) => {
log_error!(name, e, "parse column failed");
error!(name, e = ?e.as_report(), debug_string, "parse column failed");
None
}
};
Expand Down

0 comments on commit 7fd5a68

Please sign in to comment.