diff --git a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/DataType.scala b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/DataType.scala index a603e08775..036cd8bfa2 100644 --- a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/DataType.scala +++ b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/domain/DataType.scala @@ -62,7 +62,7 @@ object DataType extends Logging { case "date" => DateType case "timestamp" => TimestampType case "binary" => BinaryType - case "decimal" | DECIMAL_REGEX() => DecimalType(dataType, 3) + case "decimal" | DECIMAL_REGEX() => DecimalType case ARRAY_REGEX() => ArrayType case MAP_REGEX() => MapType case LIST_REGEX() => ListType @@ -89,8 +89,7 @@ object DataType extends Logging { case LongType | BigIntType => if (isNumberNull(newValue)) null else newValue.toLong case FloatType => if (isNumberNull(newValue)) null else newValue.toFloat case DoubleType => if (isNumberNull(newValue)) null else newValue.toDouble - case DecimalType(_, _) => - if (isNumberNull(newValue)) null else new JavaBigDecimal(newValue) + case DecimalType => if (isNumberNull(newValue)) null else new JavaBigDecimal(newValue) case DateType => if (isNumberNull(newValue)) null else Date.valueOf(newValue) case TimestampType => if (isNumberNull(newValue)) null else Timestamp.valueOf(newValue).toString.stripSuffix(".0") @@ -146,16 +145,12 @@ case object VarcharType extends DataType("varchar", 12) case object DateType extends DataType("date", 91) case object TimestampType extends DataType("timestamp", 93) case object BinaryType extends DataType("binary", -2) +case object DecimalType extends DataType("decimal", 3) case object ArrayType extends DataType("array", 2003) case object MapType extends DataType("map", 2000) case object ListType extends DataType("list", 2001) case object StructType extends DataType("struct", 2002) - -case class DecimalType(override val typeName: String, override val javaSQLType: Int) - extends DataType(typeName, javaSQLType) - -case class BigDecimalType(override val typeName: String, override val javaSQLType: Int) - extends DataType(typeName, javaSQLType) +case object BigDecimalType extends DataType("bigdecimal", 3) case class Column(columnName: String, dataType: DataType, comment: String) { diff --git a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/excel/StorageExcelWriter.scala b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/excel/StorageExcelWriter.scala index 3740dc1aaf..9ea83130df 100644 --- a/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/excel/StorageExcelWriter.scala +++ b/linkis-commons/linkis-storage/src/main/scala/org/apache/linkis/storage/excel/StorageExcelWriter.scala @@ -97,8 +97,8 @@ class StorageExcelWriter( case VarcharType => style.setDataFormat(format.getFormat("@")) case DateType => style.setDataFormat(format.getFormat("m/d/yy h:mm")) case TimestampType => style.setDataFormat(format.getFormat("m/d/yy h:mm")) - case DecimalType(_, _) => style.setDataFormat(format.getFormat("#.000000000")) - case BigDecimalType(_, _) => style.setDataFormat(format.getFormat("#.000000000")) + case DecimalType => style.setDataFormat(format.getFormat("#.000000000")) + case BigDecimalType => style.setDataFormat(format.getFormat("#.000000000")) case _ => style.setDataFormat(format.getFormat("@")) } } @@ -171,10 +171,10 @@ class StorageExcelWriter( case VarcharType => cell.setCellValue(DataType.valueToString(elem)) case DateType => cell.setCellValue(getDate(elem)) case TimestampType => cell.setCellValue(getDate(elem)) - case DecimalType(_, _) => + case DecimalType => doubleCheck(DataType.valueToString(elem)) cell.setCellValue(DataType.valueToString(elem).toDouble) - case BigDecimalType(_, _) => + case BigDecimalType => doubleCheck(DataType.valueToString(elem)) cell.setCellValue(DataType.valueToString(elem).toDouble) case _ => diff --git a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/utils/UJESClientUtils.scala b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/utils/UJESClientUtils.scala index e31136f6ae..e75929ea8f 100644 --- a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/utils/UJESClientUtils.scala +++ b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/utils/UJESClientUtils.scala @@ -21,7 +21,6 @@ import org.apache.linkis.ujes.client.exception.UJESClientBuilderException import org.apache.linkis.ujes.client.request.JobExecuteAction.{EngineType, RunType} import org.apache.linkis.ujes.client.response.ResultSetResult -import java.math.{BigDecimal => JavaBigDecimal} import java.util import java.util.Locale @@ -30,7 +29,6 @@ import com.google.gson.{Gson, JsonObject} object UJESClientUtils { val gson: Gson = new Gson() - val DECIMAL_REGEX = "^decimal\\(\\s*\\d*\\s*,\\s*\\d*\\s*\\)".r.unanchored def toEngineType(engineType: String): EngineType = engineType match { case "spark" => EngineType.SPARK @@ -77,7 +75,7 @@ object UJESClientUtils { case "boolean" => value.toBoolean case "byte" => value.toByte case "bigint" => value.toLong - case "decimal" | DECIMAL_REGEX() => new JavaBigDecimal(value) + case "decimal" => value.toDouble case "array" => gson.fromJson(value, classOf[util.ArrayList[Object]]) case "map" => gson.fromJson(value, classOf[util.HashMap[Object, Object]]) case "struct" => gson.fromJson(value, classOf[JsonObject]) diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCHelper.java b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCHelper.java index 8117c617de..0747a836c6 100644 --- a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCHelper.java +++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCHelper.java @@ -146,7 +146,7 @@ public static String getTypeStr(int type) { retVal = BinaryType.typeName(); break; case Types.DECIMAL: - retVal = new DecimalType("decimal", 3).typeName(); + retVal = DecimalType.typeName(); break; case Types.ARRAY: retVal = ArrayType.typeName(); diff --git a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/spark/sql/execution/datasources/csv/DolphinToSpark.scala b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/spark/sql/execution/datasources/csv/DolphinToSpark.scala index dc4f1bfff0..1a0eecc794 100644 --- a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/spark/sql/execution/datasources/csv/DolphinToSpark.scala +++ b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/spark/sql/execution/datasources/csv/DolphinToSpark.scala @@ -77,7 +77,7 @@ object DolphinToSpark { case wds.BigIntType => LongType case wds.FloatType => FloatType case wds.DoubleType => DoubleType - case wds.DecimalType(_, _) => DecimalType(bigDecimalPrecision, bigDecimalScale) + case wds.DecimalType => DecimalType(bigDecimalPrecision, bigDecimalScale) case wds.DateType => DateType // case wds.TimestampType => TimestampType case wds.BinaryType => BinaryType diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java index 76f4373dd7..a9a3c09b48 100644 --- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java +++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java @@ -762,6 +762,9 @@ public Message queryFailedTaskDiagnosis( if (StringUtils.isBlank(taskID)) { return Message.error("Invalid jobId cannot be empty"); } + if (!QueryUtils.checkNumberValid(taskID)) { + throw new LinkisCommonErrorException(21304, "Invalid taskID : " + taskID); + } JobHistory jobHistory = null; boolean isAdmin = Configuration.isJobHistoryAdmin(username) || Configuration.isAdmin(username); boolean isDepartmentAdmin = Configuration.isDepartmentAdmin(username); diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala index 582183d07f..1e8d9370f2 100644 --- a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala +++ b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala @@ -50,8 +50,10 @@ object QueryUtils extends Logging { private val LENGTH_SPLIT = "#" private val NAME_REGEX = "^[a-zA-Z\\-\\d_\\.]+$" private val INSTANCE_NAME_REGEX = "^[a-zA-Z\\-\\d_\\.:]+$" + private val NUMBER_REGEX = "^[0-9]+$" private val nameRegexPattern = Pattern.compile(NAME_REGEX) private val instanceNameRegexPattern = Pattern.compile(INSTANCE_NAME_REGEX) + private val numberRegexPattern = Pattern.compile(NUMBER_REGEX) private val dateFormatLocal = new ThreadLocal[SimpleDateFormat]() { override protected def initialValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") @@ -173,4 +175,8 @@ object QueryUtils extends Logging { instanceNameRegexPattern.matcher(param).find() } + def checkNumberValid(param: String): Boolean = { + numberRegexPattern.matcher(param).find() + } + }