Skip to content

Commit

Permalink
Improve imports
Browse files Browse the repository at this point in the history
  • Loading branch information
lewiszlw committed Jan 31, 2024
1 parent d11988d commit 93b7628
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bustubx/src/planner/logical_planner/logical_planner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{BustubxError, BustubxResult};
use sqlparser::ast::{Ident, JoinConstraint, JoinOperator, Statement, TableFactor, TableWithJoins};
use sqlparser::ast::{JoinConstraint, JoinOperator, Statement, TableFactor, TableWithJoins};
use std::sync::Arc;

use crate::catalog::{Catalog, DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME};
Expand Down
17 changes: 7 additions & 10 deletions bustubx/src/planner/logical_planner/plan_create_index.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
use crate::common::table_ref::TableReference;
use crate::expression::{ColumnExpr, Expr};
use crate::expression::Expr;
use crate::planner::logical_plan::LogicalPlan;
use crate::planner::logical_plan_v2::{CreateIndex, LogicalPlanV2};
use crate::planner::operator::LogicalOperator;
use crate::{BustubxError, BustubxResult};
use itertools::Itertools;
use sqlparser::ast::{ObjectName, OrderByExpr};

use super::LogicalPlanner;

impl<'a> LogicalPlanner<'a> {
pub fn plan_create_index(
&self,
index_name: &ObjectName,
table_name: &ObjectName,
columns: &Vec<OrderByExpr>,
index_name: &sqlparser::ast::ObjectName,
table_name: &sqlparser::ast::ObjectName,
columns: &Vec<sqlparser::ast::OrderByExpr>,
) -> LogicalPlan {
let table = self.bind_base_table_by_name(table_name.to_string().as_str(), None);
let columns = columns
Expand Down Expand Up @@ -44,9 +41,9 @@ impl<'a> LogicalPlanner<'a> {

pub fn plan_create_index_v2(
&self,
index_name: &ObjectName,
table_name: &ObjectName,
columns: &Vec<OrderByExpr>,
index_name: &sqlparser::ast::ObjectName,
table_name: &sqlparser::ast::ObjectName,
columns: &Vec<sqlparser::ast::OrderByExpr>,
) -> BustubxResult<LogicalPlanV2> {
let index_name = index_name
.0
Expand Down
9 changes: 4 additions & 5 deletions bustubx/src/planner/logical_planner/plan_create_table.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::BustubxResult;
use sqlparser::ast::{ColumnDef, ObjectName};

use crate::catalog::Column;
use crate::catalog::Schema;
Expand All @@ -12,8 +11,8 @@ use super::LogicalPlanner;
impl<'a> LogicalPlanner<'a> {
pub fn plan_create_table(
&self,
name: &ObjectName,
column_defs: &Vec<ColumnDef>,
name: &sqlparser::ast::ObjectName,
column_defs: &Vec<sqlparser::ast::ColumnDef>,
) -> LogicalPlan {
let table_name = name.to_string();
let columns = column_defs
Expand All @@ -29,8 +28,8 @@ impl<'a> LogicalPlanner<'a> {

pub fn plan_create_table_v2(
&self,
name: &ObjectName,
column_defs: &Vec<ColumnDef>,
name: &sqlparser::ast::ObjectName,
column_defs: &Vec<sqlparser::ast::ColumnDef>,
) -> BustubxResult<LogicalPlanV2> {
let name = self.plan_table_name(name)?;
let mut columns = vec![];
Expand Down
15 changes: 7 additions & 8 deletions bustubx/src/planner/logical_planner/plan_insert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::expression::{Cast, Expr};
use crate::BustubxResult;
use sqlparser::ast::{Ident, ObjectName, Query, SetExpr};
use std::sync::Arc;

use crate::planner::logical_plan::LogicalPlan;
Expand All @@ -12,11 +11,11 @@ use super::LogicalPlanner;
impl<'a> LogicalPlanner<'a> {
pub fn plan_insert(
&self,
table_name: &ObjectName,
columns_ident: &Vec<Ident>,
source: &Query,
table_name: &sqlparser::ast::ObjectName,
columns_ident: &Vec<sqlparser::ast::Ident>,
source: &sqlparser::ast::Query,
) -> LogicalPlan {
if let SetExpr::Values(values) = source.body.as_ref() {
if let sqlparser::ast::SetExpr::Values(values) = source.body.as_ref() {
if let Some(table_info) = self
.context
.catalog
Expand Down Expand Up @@ -71,9 +70,9 @@ impl<'a> LogicalPlanner<'a> {

pub fn plan_insert_v2(
&self,
table_name: &ObjectName,
columns_ident: &Vec<Ident>,
source: &Query,
table_name: &sqlparser::ast::ObjectName,
columns_ident: &Vec<sqlparser::ast::Ident>,
source: &sqlparser::ast::Query,
) -> BustubxResult<LogicalPlanV2> {
let values = self.plan_set_expr(source.body.as_ref())?;
let table = self.plan_table_name(table_name)?;
Expand Down

0 comments on commit 93b7628

Please sign in to comment.