featurebase/sql3/test/defs/defs_create_table.go
rachithrr ad350c2d49
FB-1739: Add ability to add a description to a table on creation (#2332)
* FB-1739: Add ability to add a description to a table on creation

- Added CommentOption to handle text after COMMENT option.
- added description field in the createtable plan.
- The description is stored in the existing index metadata.
2022-12-07 21:05:54 +05:30

102 lines
2.4 KiB
Go

package defs
var createTable = TableTest{
name: "createTable",
SQLTests: []SQLTest{
{
name: "keyPartitionsSetTo0",
SQLs: sqls(
"create table foo (_id id, i1 int) keypartitions 0",
),
ExpErr: "invalid value '0' for key partitions (should be a number between 1-10000)",
},
{
name: "keyPartitionsSetTo10001",
SQLs: sqls(
"create table foo (_id id, i1 int) keypartitions 10001",
),
ExpErr: "invalid value '10001' for key partitions (should be a number between 1-10000)",
},
{
name: "shardWidthSetTo0",
SQLs: sqls(
"create table foo (_id id, i1 int) shardwidth 0",
),
ExpErr: "invalid value '0' for shardwidth (should be a number that is a power of 2 and greater or equal to 2^16)",
},
{
name: "shardWidthSetTo11",
SQLs: sqls(
"create table foo (_id id, i1 int) shardwidth 11",
),
ExpErr: "invalid value '11' for shardwidth (should be a number that is a power of 2 and greater or equal to 2^16)",
},
{
name: "shardWidthSetTo11",
SQLs: sqls(
"create table foo (_id id, i1 int) shardwidth 32",
),
ExpErr: "invalid value '32' for shardwidth (should be a number that is a power of 2 and greater or equal to 2^16)",
},
{
name: "shardWidthSetTo131072",
SQLs: sqls(
"create table foo (_id id, i1 int) shardwidth 131072",
),
},
{
name: "commentInt",
SQLs: sqls(
"create table foo (_id id, i1 int) comment 34",
),
ExpErr: "string literal expected",
},
{
name: "commentStringNoQuote",
SQLs: sqls(
"create table foo (_id id, i1 int) comment bad",
),
ExpErr: "expected literal, found bad",
},
{
name: "commentString",
SQLs: sqls(
"create table bar (_id id, i1 int) comment 'this should work'",
),
},
},
}
var alterTable = TableTest{
name: "alterTable",
Table: tbl(
"alter_table_test",
srcHdrs(
srcHdr("_id", fldTypeID),
srcHdr("a_int", fldTypeInt),
),
),
SQLTests: []SQLTest{
{
name: "alterTableBadTable",
SQLs: sqls(
"alter table alter_table_test_foo add column a_int int",
),
ExpErr: "table 'alter_table_test_foo' not found",
},
{
name: "alterTableAddExistingCol",
SQLs: sqls(
"alter table alter_table_test add column a_int int",
),
ExpErr: "duplicate column 'a_int'",
},
{
name: "alterTableDropNonExistentCol",
SQLs: sqls(
"alter table alter_table_test drop column b_int",
),
ExpErr: "column 'b_int' not found",
},
},
}