Skip to content

Commit 70740c6

Browse files
committed
fixup! Encapsulate create table/view construction
rename fallible new() to try_new()
1 parent 7d4b3e7 commit 70740c6

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

  • datafusion

datafusion/expr/src/logical_plan/ddl.rs

Lines changed: 6 additions & 6 deletions
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,
@@ -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,
@@ -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,
@@ -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

Lines changed: 5 additions & 5 deletions
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)