Skip to content

Commit fc29c3e

Browse files
authored
Remove unnecessary result (#9990)
1 parent 0a4d9a6 commit fc29c3e

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

datafusion/common/src/dfschema.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl DFSchema {
319319
&self,
320320
qualifier: Option<&TableReference>,
321321
name: &str,
322-
) -> Result<Option<usize>> {
322+
) -> Option<usize> {
323323
let mut matches = self
324324
.iter()
325325
.enumerate()
@@ -345,19 +345,19 @@ impl DFSchema {
345345
(None, Some(_)) | (None, None) => f.name() == name,
346346
})
347347
.map(|(idx, _)| idx);
348-
Ok(matches.next())
348+
matches.next()
349349
}
350350

351351
/// Find the index of the column with the given qualifier and name
352352
pub fn index_of_column(&self, col: &Column) -> Result<usize> {
353-
self.index_of_column_by_name(col.relation.as_ref(), &col.name)?
353+
self.index_of_column_by_name(col.relation.as_ref(), &col.name)
354354
.ok_or_else(|| field_not_found(col.relation.clone(), &col.name, self))
355355
}
356356

357357
/// Check if the column is in the current schema
358-
pub fn is_column_from_schema(&self, col: &Column) -> Result<bool> {
358+
pub fn is_column_from_schema(&self, col: &Column) -> bool {
359359
self.index_of_column_by_name(col.relation.as_ref(), &col.name)
360-
.map(|idx| idx.is_some())
360+
.is_some()
361361
}
362362

363363
/// Find the field with the given name
@@ -381,7 +381,7 @@ impl DFSchema {
381381
) -> Result<(Option<&TableReference>, &Field)> {
382382
if let Some(qualifier) = qualifier {
383383
let idx = self
384-
.index_of_column_by_name(Some(qualifier), name)?
384+
.index_of_column_by_name(Some(qualifier), name)
385385
.ok_or_else(|| field_not_found(Some(qualifier.clone()), name, self))?;
386386
Ok((self.field_qualifiers[idx].as_ref(), self.field(idx)))
387387
} else {
@@ -519,7 +519,7 @@ impl DFSchema {
519519
name: &str,
520520
) -> Result<&Field> {
521521
let idx = self
522-
.index_of_column_by_name(Some(qualifier), name)?
522+
.index_of_column_by_name(Some(qualifier), name)
523523
.ok_or_else(|| field_not_found(Some(qualifier.clone()), name, self))?;
524524

525525
Ok(self.field(idx))
@@ -1190,11 +1190,8 @@ mod tests {
11901190
.to_string(),
11911191
expected_help
11921192
);
1193-
assert!(schema.index_of_column_by_name(None, "y").unwrap().is_none());
1194-
assert!(schema
1195-
.index_of_column_by_name(None, "t1.c0")
1196-
.unwrap()
1197-
.is_none());
1193+
assert!(schema.index_of_column_by_name(None, "y").is_none());
1194+
assert!(schema.index_of_column_by_name(None, "t1.c0").is_none());
11981195

11991196
Ok(())
12001197
}
@@ -1284,28 +1281,28 @@ mod tests {
12841281
{
12851282
let col = Column::from_qualified_name("t1.c0");
12861283
let schema = DFSchema::try_from_qualified_schema("t1", &test_schema_1())?;
1287-
assert!(schema.is_column_from_schema(&col)?);
1284+
assert!(schema.is_column_from_schema(&col));
12881285
}
12891286

12901287
// qualified not exists
12911288
{
12921289
let col = Column::from_qualified_name("t1.c2");
12931290
let schema = DFSchema::try_from_qualified_schema("t1", &test_schema_1())?;
1294-
assert!(!schema.is_column_from_schema(&col)?);
1291+
assert!(!schema.is_column_from_schema(&col));
12951292
}
12961293

12971294
// unqualified exists
12981295
{
12991296
let col = Column::from_name("c0");
13001297
let schema = DFSchema::try_from_qualified_schema("t1", &test_schema_1())?;
1301-
assert!(schema.is_column_from_schema(&col)?);
1298+
assert!(schema.is_column_from_schema(&col));
13021299
}
13031300

13041301
// unqualified not exists
13051302
{
13061303
let col = Column::from_name("c2");
13071304
let schema = DFSchema::try_from_qualified_schema("t1", &test_schema_1())?;
1308-
assert!(!schema.is_column_from_schema(&col)?);
1305+
assert!(!schema.is_column_from_schema(&col));
13091306
}
13101307

13111308
Ok(())

datafusion/expr/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ pub fn check_all_columns_from_schema(
933933
schema: DFSchemaRef,
934934
) -> Result<bool> {
935935
for col in columns.iter() {
936-
let exist = schema.is_column_from_schema(col)?;
936+
let exist = schema.is_column_from_schema(col);
937937
if !exist {
938938
return Ok(false);
939939
}

datafusion/sql/src/statement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
13501350
.enumerate()
13511351
.map(|(i, c)| {
13521352
let column_index = table_schema
1353-
.index_of_column_by_name(None, &c)?
1353+
.index_of_column_by_name(None, &c)
13541354
.ok_or_else(|| unqualified_field_not_found(&c, &table_schema))?;
13551355
if value_indices[column_index].is_some() {
13561356
return schema_err!(SchemaError::DuplicateUnqualifiedField {

0 commit comments

Comments
 (0)