forked from github/dataease
feat: 升级calcite(迁移自定义calcite代码至calcite-de)
This commit is contained in:
parent
09da6bbd2a
commit
c63e06449c
@ -16,7 +16,6 @@ import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.datasource.server.EngineServer;
|
||||
import io.dataease.datasource.type.*;
|
||||
import io.dataease.engine.constant.SQLConstants;
|
||||
import io.dataease.engine.func.scalar.ScalarFunctions;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.utils.BeanUtils;
|
||||
@ -26,6 +25,7 @@ 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;
|
||||
|
@ -1,194 +0,0 @@
|
||||
package io.dataease.engine.func.scalar;
|
||||
|
||||
import io.dataease.engine.utils.Utils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class ScalarFunctions {
|
||||
public static String format = "yyyy-MM-dd HH:mm:ss";
|
||||
public static String minuteFormat = "yyyy-MM-dd HH:mm";
|
||||
public static String hourFormat = "yyyy-MM-dd HH";
|
||||
public static String dateOnly = "yyyy-MM-dd";
|
||||
public static String monthOnly = "yyyy-MM";
|
||||
public static String yearOnly = "yyyy";
|
||||
public static String timeOnly = "HH:mm:ss";
|
||||
|
||||
public static String date_format(String date, String format) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(date)) {
|
||||
return null;
|
||||
}
|
||||
format = get_date_format(date);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
|
||||
Date parse = simpleDateFormat.parse(date);
|
||||
return simpleDateFormat.format(parse);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String de_date_format(String date, String format) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(date)) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
|
||||
Date parse = simpleDateFormat.parse(date);
|
||||
return simpleDateFormat.format(parse);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String str_to_date(String date, String format) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(date)) {
|
||||
return null;
|
||||
}
|
||||
format = get_date_format(date);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
|
||||
Date parse = simpleDateFormat.parse(date);
|
||||
return simpleDateFormat.format(parse);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String de_str_to_date(String date, String format) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(date)) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
|
||||
Date parse = simpleDateFormat.parse(date);
|
||||
return simpleDateFormat.format(parse);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String cast_date_format(String date, String sourceFormat, String targetFormat) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(date)) {
|
||||
return null;
|
||||
}
|
||||
sourceFormat = get_date_format(date);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(sourceFormat);
|
||||
Date parse = simpleDateFormat.parse(date);
|
||||
|
||||
SimpleDateFormat s = new SimpleDateFormat(targetFormat);
|
||||
return s.format(parse);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String de_cast_date_format(String date, String sourceFormat, String targetFormat) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(date)) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(sourceFormat);
|
||||
Date parse = simpleDateFormat.parse(date);
|
||||
|
||||
SimpleDateFormat s = new SimpleDateFormat(targetFormat);
|
||||
return s.format(parse);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Long unix_timestamp(String date) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(date)) {
|
||||
return null;
|
||||
}
|
||||
return Utils.allDateFormat2Long(date);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String get_date_format(String date) {
|
||||
// check date split '-' or '/'
|
||||
String format1 = format;
|
||||
String minuteFormat1 = minuteFormat;
|
||||
String hourFormat1 = hourFormat;
|
||||
String timeOnly1 = timeOnly;
|
||||
String dateOnly1 = dateOnly;
|
||||
String monthOnly1 = monthOnly;
|
||||
String yearOnly1 = yearOnly;
|
||||
if (date != null && date.contains("/")) {
|
||||
format1 = format1.replaceAll("-", "/");
|
||||
minuteFormat1 = minuteFormat1.replaceAll("-", "/");
|
||||
hourFormat1 = hourFormat1.replaceAll("-", "/");
|
||||
timeOnly1 = timeOnly1.replaceAll("-", "/");
|
||||
dateOnly1 = dateOnly1.replaceAll("-", "/");
|
||||
monthOnly1 = monthOnly1.replaceAll("-", "/");
|
||||
yearOnly1 = yearOnly1.replaceAll("-", "/");
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format1);
|
||||
simpleDateFormat.parse(date);
|
||||
return format1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(minuteFormat1);
|
||||
simpleDateFormat.parse(date);
|
||||
return minuteFormat1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(hourFormat1);
|
||||
simpleDateFormat.parse(date);
|
||||
return hourFormat1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeOnly1);
|
||||
simpleDateFormat.parse(date);
|
||||
return timeOnly1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateOnly1);
|
||||
simpleDateFormat.parse(date);
|
||||
return dateOnly1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(monthOnly1);
|
||||
simpleDateFormat.parse(date);
|
||||
return monthOnly1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(yearOnly1);
|
||||
simpleDateFormat.parse(date);
|
||||
return yearOnly1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return format1;
|
||||
}
|
||||
|
||||
public static String from_unixtime(Long timestamp, String format) {
|
||||
try {
|
||||
if (ObjectUtils.isEmpty(timestamp)) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
|
||||
Date date = new Date(timestamp);
|
||||
return simpleDateFormat.format(date);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String concat(String str1, String str2) {
|
||||
return str1 + str2;
|
||||
}
|
||||
}
|
@ -6,8 +6,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.func.scalar.ScalarFunctions;
|
||||
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;
|
||||
|
||||
|
@ -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.func.scalar.ScalarFunctions;
|
||||
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;
|
||||
|
||||
|
@ -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.func.scalar.ScalarFunctions;
|
||||
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;
|
||||
|
File diff suppressed because it is too large
Load Diff
2
pom.xml
2
pom.xml
@ -25,7 +25,7 @@
|
||||
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
|
||||
<h2.version>1.4.199</h2.version>
|
||||
<knife4j.version>4.1.0</knife4j.version>
|
||||
<calcite-core.version>1.35.0</calcite-core.version>
|
||||
<calcite-core.version>1.36.0</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>
|
||||
|
Loading…
Reference in New Issue
Block a user