Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(driver): enable tests for select iter #57

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ build:
test:
cargo test --all --all-features --lib -- --nocapture

integration-down:
make -C tests down

integration-tests:
make -C tests

Expand Down
165 changes: 77 additions & 88 deletions driver/tests/driver/select_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,94 +24,83 @@ async fn prepare(name: &str) -> (Box<dyn Connection>, String) {
(conn, table)
}

// TODO:(everpcpc) tmp disable for https://github.com/jorgecarleitao/arrow2/pull/1446
// #[tokio::test]
// async fn select_iter() {
// let (mut conn, table) = prepare("select_iter").await;
// let sql_create = format!(
// "CREATE TABLE `{}` (
// i64 Int64,
// u64 UInt64,
// f64 Float64,
// s String,
// s2 String,
// a16 Array(Int16),
// a8 Array(UInt8),
// d Date,
// t DateTime
// );",
// table
// );
// conn.exec(&sql_create).await.unwrap();
// let sql_insert = format!(
// "INSERT INTO `{}` VALUES
// (-1, 1, 1.0, '1', '1', [1], [10], '2011-03-06', '2011-03-06 06:20:00'),
// (-2, 2, 2.0, '2', '2', [2], [20], '2012-05-31', '2012-05-31 11:20:00'),
// (-3, 3, 3.0, '3', '2', [3], [30], '2016-04-04', '2016-04-04 11:30:00')",
// table
// );
// type RowResult = (
// i64,
// u64,
// f64,
// String,
// String,
// String,
// String,
// chrono::NaiveDate,
// chrono::NaiveDateTime,
// );
// let expected: Vec<RowResult> = vec![
// (
// -1,
// 1,
// 1.0,
// "1".into(),
// "1".into(),
// "[1]".into(),
// "[10]".into(),
// chrono::NaiveDate::from_ymd_opt(2011, 3, 6).unwrap(),
// chrono::DateTime::parse_from_rfc3339("2011-03-06T06:20:00Z")
// .unwrap()
// .naive_utc(),
// ),
// (
// -2,
// 2,
// 2.0,
// "2".into(),
// "2".into(),
// "[2]".into(),
// "[20]".into(),
// chrono::NaiveDate::from_ymd_opt(2012, 5, 31).unwrap(),
// chrono::DateTime::parse_from_rfc3339("2012-05-31T11:20:00Z")
// .unwrap()
// .naive_utc(),
// ),
// (
// -3,
// 3,
// 3.0,
// "3".into(),
// "2".into(),
// "[3]".into(),
// "[30]".into(),
// chrono::NaiveDate::from_ymd_opt(2016, 4, 4).unwrap(),
// chrono::DateTime::parse_from_rfc3339("2016-04-04T11:30:00Z")
// .unwrap()
// .naive_utc(),
// ),
// ];
// conn.exec(&sql_insert).await.unwrap();
// let sql_select = format!("SELECT * FROM `{}`", table);
// let mut rows = conn.query_iter(&sql_select).await.unwrap();
// let mut row_count = 0;
// while let Some(row) = rows.next().await {
// let v: RowResult = row.unwrap().try_into().unwrap();
// assert_eq!(v, expected[row_count]);
// row_count += 1;
// }
// }
#[tokio::test]
async fn select_iter() {
let (mut conn, table) = prepare("select_iter").await;
let sql_create = format!(
"CREATE TABLE `{}` (
i64 Int64,
u64 UInt64,
f64 Float64,
s String,
s2 String,
d Date,
t DateTime
);",
table
);
conn.exec(&sql_create).await.unwrap();
let sql_insert = format!(
"INSERT INTO `{}` VALUES
(-1, 1, 1.0, '1', '1', '2011-03-06', '2011-03-06 06:20:00'),
(-2, 2, 2.0, '2', '2', '2012-05-31', '2012-05-31 11:20:00'),
(-3, 3, 3.0, '3', '2', '2016-04-04', '2016-04-04 11:30:00')",
table
);
type RowResult = (
i64,
u64,
f64,
String,
String,
chrono::NaiveDate,
chrono::NaiveDateTime,
);
let expected: Vec<RowResult> = vec![
(
-1,
1,
1.0,
"1".into(),
"1".into(),
chrono::NaiveDate::from_ymd_opt(2011, 3, 6).unwrap(),
chrono::DateTime::parse_from_rfc3339("2011-03-06T06:20:00Z")
.unwrap()
.naive_utc(),
),
(
-2,
2,
2.0,
"2".into(),
"2".into(),
chrono::NaiveDate::from_ymd_opt(2012, 5, 31).unwrap(),
chrono::DateTime::parse_from_rfc3339("2012-05-31T11:20:00Z")
.unwrap()
.naive_utc(),
),
(
-3,
3,
3.0,
"3".into(),
"2".into(),
chrono::NaiveDate::from_ymd_opt(2016, 4, 4).unwrap(),
chrono::DateTime::parse_from_rfc3339("2016-04-04T11:30:00Z")
.unwrap()
.naive_utc(),
),
];
conn.exec(&sql_insert).await.unwrap();
let sql_select = format!("SELECT * FROM `{}`", table);
let mut rows = conn.query_iter(&sql_select).await.unwrap();
let mut row_count = 0;
while let Some(row) = rows.next().await {
let v: RowResult = row.unwrap().try_into().unwrap();
assert_eq!(v, expected[row_count]);
row_count += 1;
}
}

#[tokio::test]
async fn select_numbers() {
Expand Down