Merge pull request #12371 from dataease/pr@dev-v2@fix_ds

fix(数据源): 修复ClickHouse日期格式化问题
This commit is contained in:
Junjun 2024-09-23 11:51:54 +08:00 committed by GitHub
commit c2961d5612
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 8 deletions

View File

@ -30,7 +30,7 @@
<mybatis-plus.version>3.5.6</mybatis-plus.version>
<h2.version>2.2.220</h2.version>
<knife4j.version>4.4.0</knife4j.version>
<calcite-core.version>1.35.13</calcite-core.version>
<calcite-core.version>1.35.14</calcite-core.version>
<commons-dbcp2.version>2.6.0</commons-dbcp2.version>
<antlr.version>3.5.2</antlr.version>
<java-jwt.version>3.12.1</java-jwt.version>

View File

@ -14,10 +14,10 @@ public class DatasourceDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1175287571828910222L;
@JsonSerialize(using= ToStringSerializer.class)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@JsonSerialize(using= ToStringSerializer.class)
@JsonSerialize(using = ToStringSerializer.class)
private Long pid;
/**
* 数据源名称
@ -73,10 +73,10 @@ public class DatasourceDTO implements Serializable {
private TaskDTO syncSetting;
private Integer editType;
private String nodeType;
private String action;
private String fileName;
private String size;
private String nodeType;
private String action;
private String fileName;
private String size;
/**
* 上次成功更新时间
*/
@ -91,4 +91,6 @@ public class DatasourceDTO implements Serializable {
private String taskStatus;
private Boolean enableDataFill;
private int dsVersion = -1;
}

View File

@ -136,6 +136,10 @@ public abstract class Provider {
try {
DatasourceSchemaDTO value = dsMap.entrySet().iterator().next().getValue();
// 获取数据库version
ConnectionObj connection = getConnection(value);
value.setDsVersion(connection.getConnection().getMetaData().getDatabaseMajorVersion());
SqlParser parser = SqlParser.create(sql, SqlParser.Config.DEFAULT.withLex(Lex.JAVA));
SqlNode sqlNode = parser.parseStmt();
return sqlNode.toSqlString(getDialect(value)).toString();
@ -218,7 +222,7 @@ public abstract class Provider {
sqlDialect = RedshiftSqlDialect.DEFAULT;
break;
case ck:
sqlDialect = ClickHouseSqlDialect.DEFAULT;
sqlDialect = new ClickHouseSqlDialect(ClickHouseSqlDialect.DEFAULT_CONTEXT, coreDatasource.getDsVersion());
break;
case h2:
sqlDialect = H2SqlDialect.DEFAULT;