fix: DB2数据集,没有根据数据源侧配置的schema 进行正确的读取

This commit is contained in:
taojinlong 2023-09-07 12:31:53 +08:00
parent 085b9141a3
commit 3f09367414
3 changed files with 19 additions and 8 deletions

View File

@ -14,11 +14,19 @@ public class Db2Configuration extends JdbcConfiguration {
public String getJdbc() { public String getJdbc() {
if(StringUtils.isEmpty(extraParams.trim())){ if(StringUtils.isEmpty(extraParams.trim())){
return "jdbc:db2://HOSTNAME:PORT/DATABASE:currentSchema=SCHEMA;" if (StringUtils.isEmpty(getSchema())) {
.replace("HOSTNAME", getHost().trim()) return "jdbc:db2://HOSTNAME:PORT/DATABASE:currentSchema=SCHEMA;"
.replace("PORT", getPort().toString().trim()) .replace("HOSTNAME", getHost().trim())
.replace("DATABASE", getDataBase().trim() .replace("PORT", getPort().toString().trim())
.replace("SCHEMA",getSchema().trim())); .replace("DATABASE", getDataBase().trim());
} else {
return "jdbc:db2://HOSTNAME:PORT/DATABASE:currentSchema=SCHEMA;"
.replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim())
.replace("DATABASE", getDataBase().trim())
.replace("SCHEMA", getSchema().trim());
}
}else { }else {
return "jdbc:hive2://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS" return "jdbc:hive2://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.replace("HOSTNAME", getHost().trim()) .replace("HOSTNAME", getHost().trim())

View File

@ -31,11 +31,9 @@ import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupFile; import org.stringtemplate.v4.STGroupFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.Format;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -1415,6 +1413,11 @@ public class CKQueryProvider extends QueryProvider {
} }
} }
@Override
public String sqlForPreview(String table, Datasource ds) {
return "SELECT * FROM " + String.format(CKConstants.KEYWORD_TABLE, table);
}
public List<Dateformat> dateformat() { public List<Dateformat> dateformat() {
return JSONArray.parseArray("[\n" + return JSONArray.parseArray("[\n" +
"{\"dateformat\": \"%Y%m%d\"},\n" + "{\"dateformat\": \"%Y%m%d\"},\n" +

View File

@ -211,7 +211,7 @@ public class ExtractDataService {
for (DatasetTableField oldField : oldFields) { for (DatasetTableField oldField : oldFields) {
boolean delete = true; boolean delete = true;
for (DatasetTableField datasetTableField : datasetTableFields) { for (DatasetTableField datasetTableField : datasetTableFields) {
if (oldField.getDataeaseName().equalsIgnoreCase(datasetTableField.getDataeaseName())) { if (oldField.getDataeaseName().equalsIgnoreCase(datasetTableField.getDataeaseName()) && oldField.getType().equalsIgnoreCase(datasetTableField.getType())) {
delete = false; delete = false;
} }
} }