Skip to content

Commit e0ecbb8

Browse files
committed
Rename builders' new() to try_new()
1 parent 7d4b3e7 commit e0ecbb8

File tree

2 files changed

+14
-14
lines changed
  • datafusion

2 files changed

+14
-14
lines changed

datafusion/expr/src/logical_plan/ddl.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl PartialOrd for CreateExternalTable {
291291
}
292292

293293
impl CreateExternalTable {
294-
pub fn new(fields: CreateExternalTableFields) -> Result<Self> {
294+
pub fn try_new(fields: CreateExternalTableFields) -> Result<Self> {
295295
let CreateExternalTableFields {
296296
name,
297297
schema,
@@ -365,7 +365,7 @@ impl CreateExternalTable {
365365

366366
/// A struct with same fields as [`CreateExternalTable`] struct so that the DDL can be conveniently
367367
/// destructed with validation that each field is handled, while still requiring that all
368-
/// construction goes through the [`CreateExternalTable::new`] constructor or the builder.
368+
/// construction goes through the [`CreateExternalTable::try_new`] constructor or the builder.
369369
pub struct CreateExternalTableFields {
370370
/// The table name
371371
pub name: TableReference,
@@ -497,7 +497,7 @@ impl CreateExternalTableBuilder {
497497
}
498498

499499
pub fn build(self) -> Result<CreateExternalTable> {
500-
CreateExternalTable::new(CreateExternalTableFields {
500+
CreateExternalTable::try_new(CreateExternalTableFields {
501501
name: self.name.expect("name is required"),
502502
schema: self.schema.expect("schema is required"),
503503
location: self.location.expect("location is required"),
@@ -536,7 +536,7 @@ pub struct CreateMemoryTable {
536536
}
537537

538538
impl CreateMemoryTable {
539-
pub fn new(fields: CreateMemoryTableFields) -> Result<Self> {
539+
pub fn try_new(fields: CreateMemoryTableFields) -> Result<Self> {
540540
let CreateMemoryTableFields {
541541
name,
542542
constraints,
@@ -586,7 +586,7 @@ impl CreateMemoryTable {
586586

587587
/// A struct with same fields as [`CreateMemoryTable`] struct so that the DDL can be conveniently
588588
/// destructed with validation that each field is handled, while still requiring that all
589-
/// construction goes through the [`CreateMemoryTable::new`] constructor or the builder.
589+
/// construction goes through the [`CreateMemoryTable::try_new`] constructor or the builder.
590590
pub struct CreateMemoryTableFields {
591591
/// The table name
592592
pub name: TableReference,
@@ -664,7 +664,7 @@ impl CreateMemoryTableBuilder {
664664
}
665665

666666
pub fn build(self) -> Result<CreateMemoryTable> {
667-
CreateMemoryTable::new(CreateMemoryTableFields {
667+
CreateMemoryTable::try_new(CreateMemoryTableFields {
668668
name: self.name.expect("name is required"),
669669
constraints: self.constraints,
670670
input: self.input.expect("input is required"),
@@ -693,7 +693,7 @@ pub struct CreateView {
693693
}
694694

695695
impl CreateView {
696-
pub fn new(fields: CreateViewFields) -> Result<Self> {
696+
pub fn try_new(fields: CreateViewFields) -> Result<Self> {
697697
let CreateViewFields {
698698
name,
699699
input,
@@ -735,7 +735,7 @@ impl CreateView {
735735

736736
/// A struct with same fields as [`CreateView`] struct so that the DDL can be conveniently
737737
/// destructed with validation that each field is handled, while still requiring that all
738-
/// construction goes through the [`CreateView::new`] constructor or the builder.
738+
/// construction goes through the [`CreateView::try_new`] constructor or the builder.
739739
pub struct CreateViewFields {
740740
/// The table name
741741
pub name: TableReference,
@@ -795,7 +795,7 @@ impl CreateViewBuilder {
795795
}
796796

797797
pub fn build(self) -> Result<CreateView> {
798-
CreateView::new(CreateViewFields {
798+
CreateView::try_new(CreateViewFields {
799799
name: self.name.expect("name is required"),
800800
input: self.input.expect("input is required"),
801801
or_replace: self.or_replace,

datafusion/proto/src/logical_plan/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl AsLogicalPlan for LogicalPlanNode {
568568
}
569569

570570
Ok(LogicalPlan::Ddl(DdlStatement::CreateExternalTable(
571-
CreateExternalTable::new(CreateExternalTableFields {
571+
CreateExternalTable::try_new(CreateExternalTableFields {
572572
schema: pb_schema.try_into()?,
573573
name: from_table_reference(
574574
create_extern_table.name.as_ref(),
@@ -602,8 +602,8 @@ impl AsLogicalPlan for LogicalPlanNode {
602602
None
603603
};
604604

605-
Ok(LogicalPlan::Ddl(DdlStatement::CreateView(CreateView::new(
606-
CreateViewFields {
605+
Ok(LogicalPlan::Ddl(DdlStatement::CreateView(
606+
CreateView::try_new(CreateViewFields {
607607
name: from_table_reference(
608608
create_view.name.as_ref(),
609609
"CreateView",
@@ -612,8 +612,8 @@ impl AsLogicalPlan for LogicalPlanNode {
612612
input: Arc::new(plan),
613613
or_replace: create_view.or_replace,
614614
definition,
615-
},
616-
)?)))
615+
})?,
616+
)))
617617
}
618618
LogicalPlanType::CreateCatalogSchema(create_catalog_schema) => {
619619
let pb_schema = (create_catalog_schema.schema.clone()).ok_or_else(|| {

0 commit comments

Comments
 (0)