提交 9fa66031 authored 作者: taojinlong's avatar taojinlong

fix: pg 时间类型转换

上级 d0e079b5
......@@ -19,8 +19,6 @@ public class PgConstants extends SQLConstants {
public static final String FROM_UNIXTIME = "to_timestamp(%s)";
public static final String TO_DATE = "to_date(%s,'%s')";
public static final String CAST = "CAST(%s AS %s)";
public static final String DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH24:MI:SS";
......
......@@ -790,7 +790,7 @@ public class PgQueryProvider extends QueryProvider {
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
......@@ -854,7 +854,7 @@ public class PgQueryProvider extends QueryProvider {
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
......@@ -945,7 +945,7 @@ public class PgQueryProvider extends QueryProvider {
if (x.getDeType() == DeTypeConstants.DE_TIME) {
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
fieldName = String.format(PgConstants.DATE_FORMAT, String.format(PgConstants.TO_DATE, originField, "YYYY-MM-DD HH24:MI:SS"), format);
fieldName = String.format(PgConstants.DATE_FORMAT, String.format(PgConstants.CAST, originField, "timestamp"), format);
} else {
String cast = String.format(PgConstants.CAST, originField, "bigint");
String from_unixtime = String.format(PgConstants.FROM_UNIXTIME, cast);
......
......@@ -727,7 +727,7 @@ public class RedshiftQueryProvider extends QueryProvider {
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
......@@ -785,7 +785,7 @@ public class RedshiftQueryProvider extends QueryProvider {
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.TO_DATE, originName, PgConstants.DEFAULT_DATE_FORMAT);
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论