提交 73c95317 authored 作者: taojinlong's avatar taojinlong

fix: pg 时间类型转换

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