Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dinky port configure #2791

Merged
merged 4 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: print like problem
Signed-off-by: licho <lecho.sun@gmail.com>
  • Loading branch information
leechor committed Dec 25, 2023
commit 7a9b127c69551d0394af8174a7eb51c1fef4befd
6 changes: 2 additions & 4 deletions dinky-core/src/main/java/org/dinky/explainer/Explainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ public JobParam pretreatStatements(String[] statements) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -55,10 +54,6 @@ public static String[] splitTableNames(String statement) {
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")
Expand Down
Loading