Skip to content

Commit

Permalink
Merge branch 'master' into unsafe-recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
glorv committed Apr 10, 2024
2 parents 278eab3 + cc1376f commit 36581b3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion components/tidb_query_datatype/src/def/eval_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl std::convert::TryFrom<crate::FieldTypeTp> for EvalType {
| crate::FieldTypeTp::Null => EvalType::Bytes,
crate::FieldTypeTp::Enum => EvalType::Enum,
_ => {
// TODO: we need to handle FieldTypeTp::{Enum, Set} after we implement encode
// TODO: we need to handle FieldTypeTp::{Set} after we implement encode
// and decode.
return Err(crate::DataTypeError::UnsupportedType {
name: tp.to_string(),
Expand Down
22 changes: 12 additions & 10 deletions components/tidb_query_executors/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ impl BatchExecutorsRunner<()> {
}

#[inline]
fn is_arrow_encodable(schema: &[FieldType]) -> bool {
schema
.iter()
.all(|schema| EvalType::try_from(schema.as_accessor().tp()).is_ok())
fn is_arrow_encodable<'a>(mut schema: impl Iterator<Item = &'a FieldType>) -> bool {
schema.all(|schema| EvalType::try_from(schema.as_accessor().tp()).is_ok())
}

#[allow(clippy::explicit_counter_loop)]
Expand Down Expand Up @@ -448,12 +446,6 @@ impl<SS: 'static> BatchExecutorsRunner<SS> {
* end where last scan is finished */
)?;

let encode_type = if !is_arrow_encodable(out_most_executor.schema()) {
EncodeType::TypeDefault
} else {
req.get_encode_type()
};

// Check output offsets
let output_offsets = req.take_output_offsets();
let schema_len = out_most_executor.schema().len();
Expand All @@ -467,6 +459,16 @@ impl<SS: 'static> BatchExecutorsRunner<SS> {
}
}

// Only check output schema field types
let new_schema = output_offsets
.iter()
.map(|&i| &out_most_executor.schema()[i as usize]);
let encode_type = if !is_arrow_encodable(new_schema) {
EncodeType::TypeDefault
} else {
req.get_encode_type()
};

let exec_stats = ExecuteStats::new(executors_len);

Ok(Self {
Expand Down
10 changes: 9 additions & 1 deletion components/tidb_query_expr/src/impl_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ pub fn elt(raw_args: &[ScalarValueRef]) -> Result<Option<Bytes>> {
None => None,
Some(i) => {
let i = *i;
if i <= 0 || i + 1 > raw_args.len() as i64 {
if i <= 0 || i >= raw_args.len() as i64 {
return Ok(None);
}
raw_args[i as usize].as_bytes().map(|x| x.to_vec())
Expand Down Expand Up @@ -3666,6 +3666,14 @@ mod tests {
],
None,
),
(
vec![
Some(9223372036854775807).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
None,
),
(
vec![
Some(4).into(),
Expand Down
16 changes: 9 additions & 7 deletions tests/integrations/backup/disk_snap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ fn test_conf_change() {
let mut suite = Suite::new(4);
let the_region = suite.cluster.get_region(b"");
let last_peer = the_region.peers.last().unwrap();
let res = block_on(
suite
.cluster
.async_remove_peer(the_region.get_id(), last_peer.clone())
.unwrap(),
);
assert_success(&res);
eventually(Duration::from_millis(200), Duration::from_secs(2), || {
let res = block_on(
suite
.cluster
.async_remove_peer(the_region.get_id(), last_peer.clone())
.unwrap(),
);
!res.get_header().has_error()
});
eventually(Duration::from_millis(100), Duration::from_secs(2), || {
let r = suite.cluster.get_region(b"");
!r.peers.iter().any(|p| p.id == last_peer.id)
Expand Down

0 comments on commit 36581b3

Please sign in to comment.