Skip to content

Commit

Permalink
fix(connector): improve mysql error message (#20135) (#20143)
Browse files Browse the repository at this point in the history
Co-authored-by: Noel Kwan <[email protected]>
  • Loading branch information
github-actions[bot] and kwannoel authored Jan 14, 2025
1 parent 26fcf7a commit 5d6e0f2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/connector/src/parser/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use risingwave_common::types::{
use rust_decimal::Decimal as RustDecimal;

macro_rules! handle_data_type {
($row:expr, $i:expr, $name:expr, $type:ty) => {{
match $row.take_opt::<Option<$type>, _>($i) {
($row:expr, $i:expr, $name:expr, $typ:ty) => {{
match $row.take_opt::<Option<$typ>, _>($i) {
None => bail!("no value found at column: {}, index: {}", $name, $i),
Some(Ok(val)) => Ok(val.map(|v| ScalarImpl::from(v))),
Some(Err(e)) => Err(anyhow::Error::new(e.clone())
Expand All @@ -42,21 +42,21 @@ macro_rules! handle_data_type {
"column: {}, index: {}, rust_type: {}",
$name,
$i,
stringify!($type),
stringify!($typ),
))),
}
}};
($row:expr, $i:expr, $name:expr, $type:ty, $rw_type:ty) => {{
match $row.take_opt::<Option<$type>, _>($i) {
($row:expr, $i:expr, $name:expr, $typ:ty, $rw_type:ty) => {{
match $row.take_opt::<Option<$typ>, _>($i) {
None => bail!("no value found at column: {}, index: {}", $name, $i),
Some(Ok(val)) => Ok(val.map(|v| ScalarImpl::from(<$rw_type>::from(v)))),
Some(Err(e)) => Err(anyhow::Error::new(e.clone())
.context("failed to deserialize MySQL value into rust value")
.context("failed to deserialize MySQL value into rw value")
.context(format!(
"column: {}, index: {}, rust_type: {}",
"column: {}, index: {}, rw_type: {}",
$name,
$i,
stringify!($ty),
stringify!($rw_type),
))),
}
}};
Expand Down

0 comments on commit 5d6e0f2

Please sign in to comment.