Skip to content

Commit 92b4037

Browse files
committed
modify support create table field type(for match standard SQL)
1 parent b8c9251 commit 92b4037

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ sh submit.sh -sql D:\sideSql.txt -name xctest -remoteSqlPluginPath /opt/dtstack
139139

140140
```
141141
CREATE TABLE MyTable(
142-
name string,
143-
channel STRING,
144-
pv INT,
142+
name varchar,
143+
channel varchar,
144+
pv int,
145145
xctime bigint,
146146
CHARACTER_LENGTH(channel) AS timeLeng
147147
)WITH(
@@ -154,8 +154,8 @@ CREATE TABLE MyTable(
154154
);
155155
156156
CREATE TABLE MyResult(
157-
channel VARCHAR,
158-
pv VARCHAR
157+
channel varchar,
158+
pv varchar
159159
)WITH(
160160
type ='mysql',
161161
url ='jdbc:mysql://172.16.8.104:3306/test?charset=utf8',
@@ -166,8 +166,8 @@ CREATE TABLE MyResult(
166166
);
167167
168168
CREATE TABLE workerinfo(
169-
cast(logtime as TIMESTAMP)AS rtime,
170-
cast(logtime)AS rtime
169+
cast(logtime as TIMESTAMP) AS rtime,
170+
cast(logtime) AS rtime
171171
)WITH(
172172
type ='hbase',
173173
zookeeperQuorum ='rdos1:2181',
@@ -178,8 +178,8 @@ CREATE TABLE workerinfo(
178178
);
179179
180180
CREATE TABLE sideTable(
181-
cf:name String as name,
182-
cf:info String as info,
181+
cf:name varchar as name,
182+
cf:info varchar as info,
183183
PRIMARY KEY(name),
184184
PERIOD FOR SYSTEM_TIME
185185
)WITH(

core/src/main/java/com/dtstack/flink/sql/util/ClassUtil.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package com.dtstack.flink.sql.util;
2222

23+
import java.math.BigDecimal;
2324
import java.sql.Date;
2425
import java.sql.Timestamp;
2526

@@ -35,25 +36,24 @@ public static Class<?> stringConvertClass(String str) {
3536
switch (str.toLowerCase()) {
3637
case "boolean":
3738
return Boolean.class;
39+
40+
case "integer":
3841
case "int":
3942
return Integer.class;
4043

4144
case "bigint":
4245
return Long.class;
4346

4447
case "tinyint":
45-
case "byte":
4648
return Byte.class;
4749

48-
case "short":
4950
case "smallint":
5051
return Short.class;
5152

52-
case "char":
5353
case "varchar":
54-
case "string":
5554
return String.class;
5655

56+
case "real":
5757
case "float":
5858
return Float.class;
5959

@@ -66,6 +66,9 @@ public static Class<?> stringConvertClass(String str) {
6666
case "timestamp":
6767
return Timestamp.class;
6868

69+
case "decimal":
70+
return BigDecimal.class;
71+
6972
}
7073

7174
throw new RuntimeException("不支持 " + str + " 类型");

docs/colType.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
| ------ | ----- |
33
| boolean | Boolean |
44
| int | Integer |
5+
| integer| Integer |
56
| bigint | Long |
67
| tinyint | Byte |
7-
| byte | Byte |
8-
| short | Short |
98
| smallint | Short|
10-
| char | String|
119
| varchar | String |
12-
| string | String|
10+
| real | Float |
1311
| float | Float|
1412
| double | Double|
1513
| date | Date |
16-
| timestamp | Timestamp |
14+
| timestamp | Timestamp |
15+
| decimal |BigDecimal|

0 commit comments

Comments
 (0)