diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java
index 7116ba8d12..786ee685e1 100644
--- a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java
+++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java
@@ -25,11 +25,9 @@ import io.dataease.utils.LogUtil;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.apache.calcite.adapter.jdbc.JdbcSchema;
-import org.apache.calcite.func.scalar.ScalarFunctions;
import org.apache.calcite.jdbc.CalciteConnection;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.SchemaPlus;
-import org.apache.calcite.schema.impl.ScalarFunctionImpl;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@@ -37,7 +35,6 @@ import org.springframework.util.CollectionUtils;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Method;
import java.net.URL;
import java.sql.*;
import java.util.*;
@@ -206,20 +203,9 @@ public class CalciteProvider {
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDsList(dsMap);
SchemaPlus rootSchema = buildSchema(datasourceRequest, calciteConnection);
- addCustomFunctions(rootSchema);
return connection;
}
- private void addCustomFunctions(SchemaPlus rootSchema) {
- // scalar functions
- Class> clazz = ScalarFunctions.class;
- Method[] methods = clazz.getMethods();
- for (Method method : methods) {
- rootSchema.add(method.getName().toUpperCase(), ScalarFunctionImpl.create(
- ScalarFunctions.class, method.getName()));
- }
- }
-
private void registerDriver() {
for (String driverClass : getDriver()) {
try {
@@ -691,7 +677,6 @@ public class CalciteProvider {
try {
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
SchemaPlus rootSchema = buildSchema(datasourceRequest, calciteConnection);
- addCustomFunctions(rootSchema);
} catch (Exception e) {
DEException.throwException(e.getMessage());
}
diff --git a/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java b/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java
index 642be9c3d6..c0f06dd061 100644
--- a/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java
+++ b/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java
@@ -6,11 +6,12 @@ import io.dataease.api.dataset.union.model.SQLMeta;
import io.dataease.api.dataset.union.model.SQLObj;
import io.dataease.dto.dataset.DatasetTableFieldDTO;
import io.dataease.engine.constant.SQLConstants;
+import io.dataease.engine.utils.DateUtils;
import io.dataease.engine.utils.Utils;
-import org.apache.calcite.func.scalar.ScalarFunctions;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
@@ -55,7 +56,7 @@ public class CustomWhere2Str {
}
if (field.getDeExtractType() == 1) {
// 此处获取标准格式的日期
- String f = ScalarFunctions.get_date_format(originName);
+ String f = DateUtils.get_date_format(originName);
whereName = String.format(SQLConstants.DATE_FORMAT, originName, f);
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
@@ -90,11 +91,11 @@ public class CustomWhere2Str {
if (field.getDeType() == 1) {
// 规定几种日期格式,一一匹配,匹配到就是该格式
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
- String f = ScalarFunctions.get_date_format(filterItemDTO.getValue());
+ String f = DateUtils.get_date_format(filterItemDTO.getValue());
String n = String.format(SQLConstants.DE_CAST_DATE_FORMAT, whereName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT, f);
whereNameReal = String.format(SQLConstants.UNIX_TIMESTAMP, n);
} else {
- String f = ScalarFunctions.get_date_format(filterItemDTO.getValue());
+ String f = DateUtils.get_date_format(filterItemDTO.getValue());
String n = String.format(SQLConstants.DE_DATE_FORMAT, whereName, f);
whereNameReal = String.format(SQLConstants.UNIX_TIMESTAMP, n);
}
@@ -136,4 +137,5 @@ public class CustomWhere2Str {
}
}
+
}
diff --git a/core/core-backend/src/main/java/io/dataease/engine/trans/ExtWhere2Str.java b/core/core-backend/src/main/java/io/dataease/engine/trans/ExtWhere2Str.java
index 3c5865dc87..14cc25e598 100644
--- a/core/core-backend/src/main/java/io/dataease/engine/trans/ExtWhere2Str.java
+++ b/core/core-backend/src/main/java/io/dataease/engine/trans/ExtWhere2Str.java
@@ -5,8 +5,8 @@ import io.dataease.api.dataset.union.model.SQLMeta;
import io.dataease.api.dataset.union.model.SQLObj;
import io.dataease.dto.dataset.DatasetTableFieldDTO;
import io.dataease.engine.constant.SQLConstants;
+import io.dataease.engine.utils.DateUtils;
import io.dataease.engine.utils.Utils;
-import org.apache.calcite.func.scalar.ScalarFunctions;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@@ -57,7 +57,7 @@ public class ExtWhere2Str {
if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
date_format = "yyyy-MM-dd HH:mm:ss";
} else {
- date_format = ScalarFunctions.get_date_format(value.get(0));
+ date_format = DateUtils.get_date_format(value.get(0));
}
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
// 此处获取标准格式的日期
diff --git a/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java b/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java
index 5087a44a7b..7480db3c5e 100644
--- a/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java
+++ b/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java
@@ -8,8 +8,8 @@ import io.dataease.api.permissions.dataset.dto.DatasetRowPermissionsTreeObj;
import io.dataease.dto.dataset.DatasetTableFieldDTO;
import io.dataease.engine.constant.ExtFieldConstant;
import io.dataease.engine.constant.SQLConstants;
+import io.dataease.engine.utils.DateUtils;
import io.dataease.engine.utils.Utils;
-import org.apache.calcite.func.scalar.ScalarFunctions;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@@ -98,7 +98,7 @@ public class WhereTree2Str {
whereName = String.format(SQLConstants.FROM_UNIXTIME, cast, SQLConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 1) {
- String f = ScalarFunctions.get_date_format(originName);
+ String f = DateUtils.get_date_format(originName);
whereName = String.format(SQLConstants.DATE_FORMAT, originName, f);
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
@@ -130,12 +130,12 @@ public class WhereTree2Str {
if (field.getDeType() == 1) {
// 规定几种日期格式,一一匹配,匹配到就是该格式
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
- String f = ScalarFunctions.get_date_format(item.getValue());
- whereName = String.format(SQLConstants.DE_CAST_DATE_FORMAT, whereName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT, f);
+ String f = DateUtils.get_date_format(item.getValue());
+ whereName = String.format(SQLConstants.DE_STR_TO_DATE, whereName, f);
whereName = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
} else {
- String f = ScalarFunctions.get_date_format(item.getValue());
- whereName = String.format(SQLConstants.DE_DATE_FORMAT, whereName, f);
+ String f = DateUtils.get_date_format(item.getValue());
+ whereName = String.format(SQLConstants.DE_STR_TO_DATE, whereName, f);
whereName = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
}
}
diff --git a/pom.xml b/pom.xml
index 00ec74aab9..a8cbe273fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@