fix: 处理sql中的分号

This commit is contained in:
taojinlong 2023-01-04 16:28:06 +08:00
parent 43ffde295d
commit f08042998e
8 changed files with 10 additions and 9 deletions

View File

@ -824,7 +824,7 @@ public class CKQueryProvider extends QueryProvider {
if(isTable){
return "SELECT COUNT(*) from " + String.format(CKConstants.KEYWORD_TABLE, sql);
}else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}

View File

@ -815,7 +815,7 @@ public class Db2QueryProvider extends QueryProvider {
schema = String.format(Db2Constants.KEYWORD_TABLE, schema);
return "SELECT COUNT(*) from " + schema + "." + String.format(Db2Constants.KEYWORD_TABLE, sql);
} else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}

View File

@ -774,7 +774,7 @@ public class HiveQueryProvider extends QueryProvider {
if(isTable){
return "SELECT COUNT(*) from " + String.format(HiveConstants.KEYWORD_TABLE, sql);
}else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}

View File

@ -772,7 +772,7 @@ public class ImpalaQueryProvider extends QueryProvider {
if(isTable){
return "SELECT COUNT(*) from " + String.format(ImpalaConstants.KEYWORD_TABLE, sql);
}else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}

View File

@ -815,7 +815,7 @@ public class MysqlQueryProvider extends QueryProvider {
if(isTable){
return "SELECT COUNT(*) from " + String.format(MySQLConstants.KEYWORD_TABLE, sql);
}else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}
@ -1123,6 +1123,7 @@ public class MysqlQueryProvider extends QueryProvider {
}
private String sqlFix(String sql) {
sql = sql.trim();
if (sql.lastIndexOf(";") == (sql.length() - 1)) {
sql = sql.substring(0, sql.length() - 1);
}

View File

@ -866,7 +866,7 @@ public class OracleQueryProvider extends QueryProvider {
schema = String.format(OracleConstants.KEYWORD_TABLE, schema);
return "SELECT COUNT(*) from " + schema + "." + String.format(OracleConstants.KEYWORD_TABLE, sql);
} else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}

View File

@ -806,7 +806,7 @@ public class PgQueryProvider extends QueryProvider {
String tableWithSchema = String.format(PgConstants.KEYWORD_TABLE, schema) + "." + String.format(PgConstants.KEYWORD_TABLE, sql);
return "SELECT COUNT(*) from " + tableWithSchema;
}else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}

View File

@ -813,7 +813,7 @@ public class RedshiftQueryProvider extends QueryProvider {
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, sql);
return "SELECT COUNT(*) from " + String.format(ImpalaConstants.KEYWORD_TABLE, tableWithSchema);
}else {
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
}
}
@ -826,7 +826,7 @@ public class RedshiftQueryProvider extends QueryProvider {
}).toArray(String[]::new);
if (ds != null) {
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table);
String tableWithSchema = String.format(RedshiftConstants.KEYWORD_TABLE, schema) + "." + String.format(RedshiftConstants.KEYWORD_TABLE, table);
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_PAGE_SIZE OFFSET DE_OFFSET ", StringUtils.join(array, ","), tableWithSchema);
} else {
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_PAGE_SIZE OFFSET DE_OFFSET ", StringUtils.join(array, ","), table);