1+ use std:: collections:: HashSet ;
2+
3+ use anyhow:: Result ;
4+ use sqlparser:: ast:: { ColumnDef , ObjectName } ;
5+
16use super :: Binder ;
27use crate :: binder:: { lower_case_name, split_name} ;
3- use crate :: catalog:: { Column , ColumnDesc } ;
8+ use crate :: catalog:: ColumnCatalog ;
49use crate :: planner:: logical_create_table_plan:: LogicalCreateTablePlan ;
5- use crate :: planner:: LogicalPlan ;
6- use crate :: types:: { ColumnId , TableId } ;
7- use anyhow:: Result ;
8- use sqlparser:: ast:: { ColumnDef , ObjectName } ;
9- use std:: collections:: HashSet ;
1010
1111impl Binder {
1212 pub ( crate ) fn bind_create_table (
@@ -29,10 +29,10 @@ impl Binder {
2929 }
3030 }
3131
32- let mut columns: Vec < Column > = columns
32+ let columns: Vec < ColumnCatalog > = columns
3333 . iter ( )
3434 . enumerate ( )
35- . map ( |( _, col) | Column :: from ( col) )
35+ . map ( |( _, col) | ColumnCatalog :: from ( col. clone ( ) ) )
3636 . collect ( ) ;
3737
3838 let plan = LogicalCreateTablePlan {
@@ -48,36 +48,31 @@ impl Binder {
4848
4949#[ cfg( test) ]
5050mod tests {
51+ use sqlparser:: ast:: CharacterLength ;
52+
5153 use super :: * ;
5254 use crate :: binder:: BinderContext ;
53- use crate :: catalog:: Root ;
54- use crate :: types:: { DataTypeExt , DataTypeKind } ;
55- use sqlparser:: ast:: CharacterLength ;
56- use std:: sync:: Arc ;
55+ use crate :: catalog:: { ColumnDesc , RootCatalog } ;
56+ use crate :: planner:: LogicalPlan ;
57+ use crate :: types:: LogicalType ;
5758
5859 #[ test]
5960 fn test_create_bind ( ) {
6061 let sql = "create table t1 (id int , name varchar(10))" ;
61- let mut binder = Binder :: new ( BinderContext :: new ( Root :: new ( ) ) ) ;
62+ let binder = Binder :: new ( BinderContext :: new ( RootCatalog :: new ( ) ) ) ;
6263 let stmt = crate :: parser:: parse_sql ( sql) . unwrap ( ) ;
6364 let plan1 = binder. bind ( & stmt[ 0 ] ) . unwrap ( ) ;
6465
65- let character_length = CharacterLength {
66- length : 10 ,
67- unit : None ,
68- } ;
6966 let plan2 = LogicalPlan :: CreateTable ( LogicalCreateTablePlan {
7067 table_name : "t1" . to_string ( ) ,
7168 columns : vec ! [
7269 (
7370 "id" . to_string( ) ,
74- DataTypeKind :: Int ( None ) . nullable ( ) . to_column ( ) ,
71+ ColumnDesc :: new ( LogicalType :: Integer , false ) ,
7572 ) ,
7673 (
7774 "name" . to_string( ) ,
78- DataTypeKind :: Varchar ( Option :: from( character_length) )
79- . nullable( )
80- . to_column( ) ,
75+ ColumnDesc :: new( LogicalType :: Varchar , false ) ,
8176 ) ,
8277 ] ,
8378 } ) ;
0 commit comments