Skip to content

Commit

Permalink
fixup! Encapsulate create table/view construction
Browse files Browse the repository at this point in the history
rename fallible new() to try_new()
  • Loading branch information
findepi committed Nov 28, 2024
1 parent 7d4b3e7 commit 70740c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions datafusion/expr/src/logical_plan/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl PartialOrd for CreateExternalTable {
}

impl CreateExternalTable {
pub fn new(fields: CreateExternalTableFields) -> Result<Self> {
pub fn try_new(fields: CreateExternalTableFields) -> Result<Self> {
let CreateExternalTableFields {
name,
schema,
Expand Down Expand Up @@ -497,7 +497,7 @@ impl CreateExternalTableBuilder {
}

pub fn build(self) -> Result<CreateExternalTable> {
CreateExternalTable::new(CreateExternalTableFields {
CreateExternalTable::try_new(CreateExternalTableFields {
name: self.name.expect("name is required"),
schema: self.schema.expect("schema is required"),
location: self.location.expect("location is required"),
Expand Down Expand Up @@ -536,7 +536,7 @@ pub struct CreateMemoryTable {
}

impl CreateMemoryTable {
pub fn new(fields: CreateMemoryTableFields) -> Result<Self> {
pub fn try_new(fields: CreateMemoryTableFields) -> Result<Self> {
let CreateMemoryTableFields {
name,
constraints,
Expand Down Expand Up @@ -664,7 +664,7 @@ impl CreateMemoryTableBuilder {
}

pub fn build(self) -> Result<CreateMemoryTable> {
CreateMemoryTable::new(CreateMemoryTableFields {
CreateMemoryTable::try_new(CreateMemoryTableFields {
name: self.name.expect("name is required"),
constraints: self.constraints,
input: self.input.expect("input is required"),
Expand Down Expand Up @@ -693,7 +693,7 @@ pub struct CreateView {
}

impl CreateView {
pub fn new(fields: CreateViewFields) -> Result<Self> {
pub fn try_new(fields: CreateViewFields) -> Result<Self> {
let CreateViewFields {
name,
input,
Expand Down Expand Up @@ -795,7 +795,7 @@ impl CreateViewBuilder {
}

pub fn build(self) -> Result<CreateView> {
CreateView::new(CreateViewFields {
CreateView::try_new(CreateViewFields {
name: self.name.expect("name is required"),
input: self.input.expect("input is required"),
or_replace: self.or_replace,
Expand Down
10 changes: 5 additions & 5 deletions datafusion/proto/src/logical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ impl AsLogicalPlan for LogicalPlanNode {
}

Ok(LogicalPlan::Ddl(DdlStatement::CreateExternalTable(
CreateExternalTable::new(CreateExternalTableFields {
CreateExternalTable::try_new(CreateExternalTableFields {
schema: pb_schema.try_into()?,
name: from_table_reference(
create_extern_table.name.as_ref(),
Expand Down Expand Up @@ -602,8 +602,8 @@ impl AsLogicalPlan for LogicalPlanNode {
None
};

Ok(LogicalPlan::Ddl(DdlStatement::CreateView(CreateView::new(
CreateViewFields {
Ok(LogicalPlan::Ddl(DdlStatement::CreateView(
CreateView::try_new(CreateViewFields {
name: from_table_reference(
create_view.name.as_ref(),
"CreateView",
Expand All @@ -612,8 +612,8 @@ impl AsLogicalPlan for LogicalPlanNode {
input: Arc::new(plan),
or_replace: create_view.or_replace,
definition,
},
)?)))
})?,
)))
}
LogicalPlanType::CreateCatalogSchema(create_catalog_schema) => {
let pb_schema = (create_catalog_schema.schema.clone()).ok_or_else(|| {
Expand Down

0 comments on commit 70740c6

Please sign in to comment.