Skip to content

Commit

Permalink
Bump rust 1.80 (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayWhite2357 authored Aug 28, 2024
1 parent bfe2c56 commit 6d7a046
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 34 deletions.
12 changes: 6 additions & 6 deletions crates/proof-of-sql-parser/src/intermediate_ast_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,14 @@ fn we_can_parse_a_query_with_three_logical_not_and_or_filter_expressions() {

#[test]
fn we_can_parse_a_query_with_the_minimum_i128_value_as_the_equal_filter_literal() {
let ast = ("select a from sxt_tab where b = ".to_owned() + &std::i128::MIN.to_string())
let ast = ("select a from sxt_tab where b = ".to_owned() + &i128::MIN.to_string())
.parse::<SelectStatement>()
.unwrap();
let expected_ast = select(
query(
cols_res(&["a"]),
tab(None, "sxt_tab"),
equal(col("b"), lit(std::i128::MIN)),
equal(col("b"), lit(i128::MIN)),
vec![],
),
vec![],
Expand All @@ -517,7 +517,7 @@ fn we_can_parse_a_query_with_the_minimum_i128_value_as_the_equal_filter_literal(
query(
cols_res(&["a"]),
tab(None, "sxt_tab"),
equal(col("b"), lit(std::i128::MIN)),
equal(col("b"), lit(i128::MIN)),
vec![],
),
vec![],
Expand All @@ -530,22 +530,22 @@ fn we_can_parse_a_query_with_the_minimum_i128_value_as_the_equal_filter_literal(
fn we_cannot_parse_a_query_with_the_literals_overflowing() {
// note: see the minus sign in front of the literal, causing the overflow
assert!(
("select a from sxt_tab where b = -".to_owned() + &std::i128::MIN.to_string())
("select a from sxt_tab where b = -".to_owned() + &i128::MIN.to_string())
.parse::<SelectStatement>()
.is_err()
);
}

#[test]
fn we_can_parse_a_query_with_the_maximum_i128_value_as_the_equal_filter_literal() {
let ast = ("select a from sxt_tab where b = ".to_owned() + &std::i128::MAX.to_string())
let ast = ("select a from sxt_tab where b = ".to_owned() + &i128::MAX.to_string())
.parse::<SelectStatement>()
.unwrap();
let expected_ast = select(
query(
cols_res(&["a"]),
tab(None, "sxt_tab"),
equal(col("b"), lit(std::i128::MAX)),
equal(col("b"), lit(i128::MAX)),
vec![],
),
vec![],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ fn num_rows_of_columns<'a>(
Ok(num_rows)
}

#[cfg(all(test, feature = "arrow, blitzar"))]
#[cfg(all(test, feature = "arrow", feature = "blitzar"))]
mod tests {
use super::*;
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions crates/proof-of-sql/src/base/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ mod record_batch_utility;
#[cfg(feature = "arrow")]
pub use record_batch_utility::ToArrow;

#[cfg(all(test, feature = "arrow, test"))]
#[cfg(all(test, feature = "arrow", feature = "test"))]
mod test_accessor_utility;
#[cfg(all(test, feature = "arrow, test"))]
#[cfg(all(test, feature = "arrow", feature = "test"))]
pub use test_accessor_utility::{make_random_test_accessor_data, RandomTestAccessorDescriptor};

mod owned_column;
Expand Down
12 changes: 10 additions & 2 deletions crates/proof-of-sql/src/base/database/test_accessor_utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arrow::{
StringArray, TimestampMicrosecondArray, TimestampMillisecondArray,
TimestampNanosecondArray, TimestampSecondArray,
},
datatypes::{i256, DataType, Field, Schema},
datatypes::{i256, DataType, Field, Schema, TimeUnit},
record_batch::RecordBatch,
};
use proof_of_sql_parser::posql_time::PoSQLTimeUnit;
Expand Down Expand Up @@ -121,7 +121,15 @@ pub fn make_random_test_accessor_data(
ColumnType::TimestampTZ(tu, tz) => {
column_fields.push(Field::new(
*col_name,
DataType::Timestamp((*tu).into(), Some(Arc::from(tz.to_string()))),
DataType::Timestamp(
match tu {
PoSQLTimeUnit::Second => TimeUnit::Second,
PoSQLTimeUnit::Millisecond => TimeUnit::Millisecond,
PoSQLTimeUnit::Microsecond => TimeUnit::Microsecond,
PoSQLTimeUnit::Nanosecond => TimeUnit::Nanosecond,
},
Some(Arc::from(tz.to_string())),
),
false,
));
// Create the correct timestamp array based on the time unit
Expand Down
10 changes: 5 additions & 5 deletions crates/proof-of-sql/src/base/encode/varint_trait_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn test_decode_max_u64() {
let max_vec_encoded = vec![0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01];
assert_eq!(
u64::decode_var(max_vec_encoded.as_slice()).unwrap().0,
u64::max_value()
u64::MAX
);
}

Expand All @@ -68,11 +68,11 @@ fn test_encode_i64() {
4294967295_u64.encode_var_vec()
);
assert_eq!(
i64::max_value().encode_var_vec(),
i64::MAX.encode_var_vec(),
&[0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01]
);
assert_eq!(
i64::min_value().encode_var_vec(),
i64::MIN.encode_var_vec(),
&[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01]
);
}
Expand All @@ -82,7 +82,7 @@ fn test_decode_min_i64() {
let min_vec_encoded = vec![0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01];
assert_eq!(
i64::decode_var(min_vec_encoded.as_slice()).unwrap().0,
i64::min_value()
i64::MIN
);
}

Expand All @@ -91,7 +91,7 @@ fn test_decode_max_i64() {
let max_vec_encoded = vec![0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01];
assert_eq!(
i64::decode_var(max_vec_encoded.as_slice()).unwrap().0,
i64::max_value()
i64::MAX
);
}

Expand Down
17 changes: 0 additions & 17 deletions crates/proof-of-sql/src/proof_primitive/dory/offset_to_bytes.rs
Original file line number Diff line number Diff line change
@@ -1,74 +1,57 @@
use zerocopy::AsBytes;

pub trait OffsetToBytes {
const IS_SIGNED: bool;
fn offset_to_bytes(&self) -> Vec<u8>;
}

impl OffsetToBytes for u8 {
const IS_SIGNED: bool = false;

fn offset_to_bytes(&self) -> Vec<u8> {
vec![*self]
}
}

impl OffsetToBytes for i16 {
const IS_SIGNED: bool = true;

fn offset_to_bytes(&self) -> Vec<u8> {
let shifted = self.wrapping_sub(i16::MIN);
shifted.to_le_bytes().to_vec()
}
}

impl OffsetToBytes for i32 {
const IS_SIGNED: bool = true;

fn offset_to_bytes(&self) -> Vec<u8> {
let shifted = self.wrapping_sub(i32::MIN);
shifted.to_le_bytes().to_vec()
}
}

impl OffsetToBytes for i64 {
const IS_SIGNED: bool = true;

fn offset_to_bytes(&self) -> Vec<u8> {
let shifted = self.wrapping_sub(i64::MIN);
shifted.to_le_bytes().to_vec()
}
}

impl OffsetToBytes for i128 {
const IS_SIGNED: bool = true;

fn offset_to_bytes(&self) -> Vec<u8> {
let shifted = self.wrapping_sub(i128::MIN);
shifted.to_le_bytes().to_vec()
}
}

impl OffsetToBytes for bool {
const IS_SIGNED: bool = false;

fn offset_to_bytes(&self) -> Vec<u8> {
vec![*self as u8]
}
}

impl OffsetToBytes for u64 {
const IS_SIGNED: bool = false;

fn offset_to_bytes(&self) -> Vec<u8> {
let bytes = self.to_le_bytes();
bytes.to_vec()
}
}

impl OffsetToBytes for [u64; 4] {
const IS_SIGNED: bool = false;

fn offset_to_bytes(&self) -> Vec<u8> {
let slice = self.as_bytes();
slice.to_vec()
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.78.0"
channel = "1.80.0"

0 comments on commit 6d7a046

Please sign in to comment.