Skip to content

Commit 5986549

Browse files
committed
update version to 0.0.7
1 parent d752632 commit 5986549

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</parent>
2929
<groupId>com.aliyun.odps</groupId>
3030
<artifactId>maxcompute-emulator</artifactId>
31-
<version>0.0.6-tpch</version>
31+
<version>0.0.7</version>
3232
<name>maxcompute-emulator</name>
3333
<description>mock version to access MaxCompute</description>
3434
<properties>

src/main/java/com/aliyun/odps/utils/SqlRunner.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public static String handleAddColumn(String mcSql) throws SQLException {
9999
// split on whitespace to get column name
100100
String[] columnDefinitions = columnsPart.split("\\s*,\\s*");
101101
String tableName = noDatabasePrefix.replaceAll("ALTER TABLE (\\S+) ADD COLUMNS.*", "$1");
102+
tableName = unwrapTable(tableName);
102103

103104
String[] alterTableStatements = new String[columnDefinitions.length];
104105

@@ -134,6 +135,7 @@ public static String handleDropColumn(String mcSql) throws SQLException {
134135
String noDatabasePrefix = mcSql.replaceAll("ALTER TABLE \\S+\\.", "ALTER TABLE ");
135136

136137
String tableName = noDatabasePrefix.replaceAll("ALTER TABLE (\\S+) DROP COLUMNS.*", "$1");
138+
tableName = unwrapTable(tableName);
137139
String[] columnsToDrop =
138140
noDatabasePrefix.replaceAll("ALTER TABLE \\S+ DROP COLUMNS ", "").split(",");
139141

@@ -180,6 +182,7 @@ public static String handleRenameColumn(String mcSql) throws SQLException {
180182
String noDatabasePrefix = mcSql.replaceAll("ALTER TABLE \\S+\\.", "ALTER TABLE ");
181183

182184
String tableName = noDatabasePrefix.replaceAll("ALTER TABLE (\\S+) CHANGE COLUMN.*", "$1");
185+
tableName = unwrapTable(tableName);
183186
String[] columnToRename =
184187
noDatabasePrefix.replaceAll("ALTER TABLE \\S+ CHANGE COLUMN ", "").replace("\\s+", "").split(" ");
185188
String oldName;
@@ -211,6 +214,7 @@ public static String handleRenameColumn(String mcSql) throws SQLException {
211214
}
212215

213216
public static SqlLiteSchema getSchema(String tableName) throws SQLException {
217+
tableName = unwrapTable(tableName);
214218
try (Statement stmt = CommonUtils.getConnection().createStatement()) {
215219
ResultSet rs = stmt.executeQuery(
216220
"SELECT schema FROM schemas WHERE table_name = '" + tableName.toUpperCase() + "';");
@@ -229,6 +233,7 @@ public static SqlLiteSchema getSchema(String tableName) throws SQLException {
229233
}
230234

231235
static void updateSchema(String tableName, SqlLiteSchema schema) throws SQLException {
236+
tableName = unwrapTable(tableName);
232237
try (Statement stmt = CommonUtils.getConnection().createStatement()) {
233238
stmt.executeUpdate(
234239
"UPDATE schemas SET schema = '" + schema.toJson() + "' WHERE table_name = '" + tableName +
@@ -275,4 +280,13 @@ private static String processResultSet(ResultSet resultSet) throws SQLException,
275280

276281
return writer.toString();
277282
}
283+
284+
private static String unwrapTable(String tableName) {
285+
tableName = tableName.trim();
286+
if (tableName.startsWith("`") && tableName.endsWith("`")) {
287+
return tableName.substring(1, tableName.length() - 1);
288+
} else {
289+
return tableName;
290+
}
291+
}
278292
}

src/main/resources/banner.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
| |\/| | / _` | \ \/ / | | / _ \ | '_ ` _ \ | '_ \ | | | | | __| / _ \ | __| | '_ ` _ \ | | | | | | / _` | | __| / _ \ | '__|
55
| | | | | (_| | > < | |____ | (_) | | | | | | | | |_) | | |_| | | |_ | __/ | |____ | | | | | | | |_| | | | | (_| | | |_ | (_) | | |
66
|_| |_| \__,_| /_/\_\ \_____| \___/ |_| |_| |_| | .__/ \__,_| \__| \___| |______| |_| |_| |_| \__,_| |_| \__,_| \__| \___/ |_|
7-
| | v0.0.4
7+
| | v0.0.7
88
|_|

0 commit comments

Comments
 (0)