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

minor: remove redundant unwrap() #4463

Merged
merged 2 commits into from
Dec 5, 2022
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
6 changes: 2 additions & 4 deletions datafusion-examples/examples/custom_datasource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ async fn search_accounts(
provider_as_source(Arc::new(db)),
None,
vec![],
)
.unwrap()
.build()
.unwrap();
)?
.build()?;

let mut dataframe = DataFrame::new(ctx.state, &logical_plan)
.select_columns(&["id", "bank_account"])?;
Expand Down
36 changes: 16 additions & 20 deletions datafusion/core/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,15 +914,14 @@ mod tests {
async fn select_with_periods() -> Result<()> {
// define data with a column name that has a "." in it:
let array: Int32Array = [1, 10].into_iter().collect();
let batch =
RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)]).unwrap();
let batch = RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)])?;

let ctx = SessionContext::new();
ctx.register_batch("t", batch).unwrap();
ctx.register_batch("t", batch)?;

let df = ctx.table("t").unwrap().select_columns(&["f.c1"]).unwrap();
let df = ctx.table("t")?.select_columns(&["f.c1"])?;

let df_results = df.collect().await.unwrap();
let df_results = df.collect().await?;

assert_batches_sorted_eq!(
vec!["+------+", "| f.c1 |", "+------+", "| 1 |", "| 10 |", "+------+",],
Expand Down Expand Up @@ -1386,7 +1385,7 @@ mod tests {

let plan = df.explain(false, false)?.collect().await?;
// Filters all the way to Parquet
let formatted = pretty::pretty_format_batches(&plan).unwrap().to_string();
let formatted = pretty::pretty_format_batches(&plan)?.to_string();
assert!(formatted.contains("FilterExec: id@0 = 1"));

Ok(())
Expand Down Expand Up @@ -1445,8 +1444,8 @@ mod tests {
GROUP BY
column_1"#;

let df = ctx.sql(sql).await.unwrap();
df.show_limit(10).await.unwrap();
let df = ctx.sql(sql).await?;
df.show_limit(10).await?;

Ok(())
}
Expand All @@ -1455,20 +1454,17 @@ mod tests {
async fn with_column_name() -> Result<()> {
// define data with a column name that has a "." in it:
let array: Int32Array = [1, 10].into_iter().collect();
let batch =
RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)]).unwrap();
let batch = RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)])?;

let ctx = SessionContext::new();
ctx.register_batch("t", batch).unwrap();
ctx.register_batch("t", batch)?;

let df = ctx
.table("t")
.unwrap()
.table("t")?
// try and create a column with a '.' in it
.with_column("f.c2", lit("hello"))
.unwrap();
.with_column("f.c2", lit("hello"))?;

let df_results = df.collect().await.unwrap();
let df_results = df.collect().await?;

assert_batches_sorted_eq!(
vec![
Expand Down Expand Up @@ -1648,8 +1644,8 @@ mod tests {
| JoinType::LeftSemi
| JoinType::LeftAnti => {
let left_exprs: Vec<Arc<dyn PhysicalExpr>> = vec![
Arc::new(Column::new_with_schema("c1", &join_schema).unwrap()),
Arc::new(Column::new_with_schema("c2", &join_schema).unwrap()),
Arc::new(Column::new_with_schema("c1", &join_schema)?),
Arc::new(Column::new_with_schema("c2", &join_schema)?),
];
assert_eq!(
out_partitioning,
Expand All @@ -1658,8 +1654,8 @@ mod tests {
}
JoinType::Right | JoinType::RightSemi | JoinType::RightAnti => {
let right_exprs: Vec<Arc<dyn PhysicalExpr>> = vec![
Arc::new(Column::new_with_schema("c2_c1", &join_schema).unwrap()),
Arc::new(Column::new_with_schema("c2_c2", &join_schema).unwrap()),
Arc::new(Column::new_with_schema("c2_c1", &join_schema)?),
Arc::new(Column::new_with_schema("c2_c2", &join_schema)?),
];
assert_eq!(
out_partitioning,
Expand Down
Loading