Skip to content

Commit 5eb3caa

Browse files
committed
fix: create schema table at application start
1 parent edf1097 commit 5eb3caa

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/com/aliyun/odps/MaxcomputeEmulatorApplication.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818

1919
package com.aliyun.odps;
2020

21+
import com.aliyun.odps.utils.SqlRunner;
2122
import org.springframework.boot.SpringApplication;
2223
import org.springframework.boot.autoconfigure.SpringBootApplication;
2324

25+
import java.sql.SQLException;
26+
2427
@SpringBootApplication
2528
public class MaxcomputeEmulatorApplication {
2629

27-
public static void main(String[] args) {
30+
public static void main(String[] args) throws SQLException {
31+
SqlRunner.executeSql("CREATE TABLE IF NOT EXISTS schemas(table_name TEXT, schema TEXT);");
2832
SpringApplication.run(MaxcomputeEmulatorApplication.class, args);
2933
}
3034

src/main/java/com/aliyun/odps/function/CreateTable.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ private static void run(String originSql) throws SQLException {
5858
walker.walk(listener, tree);
5959

6060
SqlRunner.executeSql(listener.getResult());
61-
if (!Table.of("schemas").exist()) {
62-
SqlRunner.executeSql("CREATE TABLE schemas(table_name TEXT, schema TEXT);");
63-
}
6461
SqlRunner.executeSql(
6562
"INSERT INTO schemas VALUES ('" + listener.getTableName() + "', '" + listener.getSchema().toJson() +
6663
"');");

0 commit comments

Comments
 (0)