/
MySqlCreateTableTest93.java
83 lines (76 loc) · 5.01 KB
/
MySqlCreateTableTest93.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright [2013-2021], Alibaba Group Holding Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.polardbx.druid.bvt.sql.mysql.createTable;
import com.alibaba.polardbx.druid.sql.MysqlTest;
import com.alibaba.polardbx.druid.sql.ast.SQLStatement;
import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement;
import com.alibaba.polardbx.druid.sql.dialect.mysql.parser.MySqlStatementParser;
import java.util.List;
public class MySqlCreateTableTest93 extends MysqlTest {
public void test_0() throws Exception {
String sql = "CREATE TABLE `dc_job_instance` (\n" +
" `id` int(11) NOT NULL AUTO_INCREMENT,\n" +
" `code` varchar(45) NOT NULL,\n" +
" `name` varchar(512) DEFAULT NULL,\n" +
" `cluster_code` varchar(64) DEFAULT NULL,\n" +
" `engine_inst_code` varchar(45) DEFAULT NULL,\n" +
" `dependent_code` varchar(1024) DEFAULT NULL COMMENT '依赖上一个实例code',\n" +
" `concurrent_rely` varchar(1024) DEFAULT NULL COMMENT '并发依赖',\n" +
" `job_text` longtext,\n" +
" `project_code` varchar(45) DEFAULT NULL COMMENT '项目code',\n" +
" `job_name` varchar(128) DEFAULT NULL COMMENT 'job名称',\n" +
" `job_code` varchar(45) DEFAULT NULL,\n" +
" `job_id` int(11) DEFAULT NULL,\n" +
" `job_type` varchar(45) DEFAULT NULL,\n" +
" `type` varchar(45) NOT NULL DEFAULT 'test' COMMENT '开发实例:dev\\n调度实例:schedule\\n测试实例:test\\n补数据实例:supplement',\n" +
" `version` int(11) NOT NULL DEFAULT '0',\n" +
" `status` int(11) NOT NULL DEFAULT '0' COMMENT '1:等待运行,3:等待资源,5:运行中,7:运行失败,9:运行成功, 11:暂停, 13:终止',\n" +
" `schedule_start` datetime DEFAULT NULL COMMENT '调度开始时间',\n" +
" `run_start` datetime DEFAULT NULL COMMENT '运行开始时间',\n" +
" `run_end` datetime DEFAULT NULL COMMENT '运行结束时间',\n" +
" `owner` varchar(64) NOT NULL,\n" +
" `bizdate` varchar(64) DEFAULT NULL COMMENT '业务日期:yyyy-MM-dd\\n',\n" +
" `rundate` varchar(64) DEFAULT NULL COMMENT '运行日期:yyyy-MM-dd',\n" +
" `run_mode` varchar(45) DEFAULT NULL COMMENT '运行模式:jobserver, thriftserver, phoenix、tidb',\n" +
" `runtimes` int(16) DEFAULT '0' COMMENT '运行时间,单位秒',\n" +
" `res_cu` decimal(20,5) DEFAULT '0.00000' COMMENT '计算消耗资源,单位cu',\n" +
" `retry_count` int(11) DEFAULT '0',\n" +
" `failure_count` int(11) DEFAULT NULL COMMENT '失败次数',\n" +
" `last_notify_time` datetime DEFAULT NULL COMMENT '最新一次告警通知时间',\n" +
" `alarm_count` int(11) DEFAULT '0' COMMENT '告警次数',\n" +
" `error_type` varchar(45) DEFAULT NULL COMMENT '系统异常:sys\\n作业异常:job',\n" +
" `spark_application_id` varchar(128) DEFAULT 'spark app id',\n" +
" `spark_group_id` varchar(128) DEFAULT NULL COMMENT 'Spark group id',\n" +
" `spark_web_url` varchar(256) DEFAULT NULL,\n" +
" `gmt_created` datetime NOT NULL,\n" +
" `gmt_modified` datetime DEFAULT NULL,\n" +
" `creater` varchar(45) NOT NULL,\n" +
" `modifier` varchar(45) DEFAULT NULL,\n" +
" PRIMARY KEY (`id`),\n" +
" UNIQUE KEY `code_UNIQUE` (`code`),\n" +
" KEY `project_code_index` (`project_code`),\n" +
" KEY `job_code_index` (`job_code`),\n" +
" KEY `type_index` (`type`),\n" +
" KEY `spark_app_id_index` (`spark_application_id`),\n" +
" FULLTEXT KEY `ft_job_text` (`job_text`,`spark_application_id`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=23185 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
MySqlCreateTableStatement stmt = (MySqlCreateTableStatement)statementList.get(0);
assertEquals(1, statementList.size());
assertEquals(44, stmt.getTableElementList().size());
}
}