Unverified Commit efd8cbb3 authored by Licho's avatar Licho Committed by GitHub

fix: print like problem (#2780)

Signed-off-by: 's avatarlicho <lecho.sun@gmail.com>
parent 005e0920
......@@ -155,10 +155,8 @@ public class Explainer {
int port = Integer.parseInt(config.getOrDefault("dinky.dinkyPrintPort", "7125"));
String[] tableNames = PrintStatementExplainer.getTableNames(statement);
for (String tableName : tableNames) {
ddl.add(new StatementParam(
PrintStatementExplainer.getCreateStatement(tableName, host, port), SqlType.CREATE));
trans.add(
new StatementParam(PrintStatementExplainer.getInsertStatement(tableName), SqlType.INSERT));
trans.add(new StatementParam(
PrintStatementExplainer.getCreateStatement(tableName, host, port), SqlType.CTAS));
}
} else {
UDF udf = UDFUtil.toUDF(statement, jobManager.getDinkyClassLoader());
......
......@@ -38,8 +38,7 @@ public class PrintStatementExplainer {
public static final String CREATE_SQL_TEMPLATE = "CREATE TABLE print_{0} WITH (''connector'' = ''printnet'', "
+ "''port''=''{2,number,#}'', ''hostName'' = ''{1}'')\n"
+ "LIKE {0};";
public static final String INSERT_SQL_TEMPLATE = "insert into print_{0} select * from {0};";
+ "AS SELECT * FROM {0}";
public static final int DEFAULT_PORT = 7125;
public static String[] getTableNames(String statement) {
......@@ -55,10 +54,6 @@ public class PrintStatementExplainer {
throw new IllegalArgumentException("Invalid print statement: " + statement);
}
public static String getInsertStatement(String tableName) {
return MessageFormat.format(INSERT_SQL_TEMPLATE, tableName);
}
public static String getCreateStatement(String tableName, String localIp, Integer localPort) {
String ip = Strings.isNullOrEmpty(localIp)
? getSystemLocalIp().map(InetAddress::getHostAddress).orElse("127.0.0.1")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment