in streampark-common/src/main/scala/org/apache/streampark/common/util/SqlConvertUtils.scala [60:92]
private[this] def toClickhouseDataType(dataType: String, length: String): String = {
dataType.toUpperCase() match {
case "TEXT" | "LONGTEXT" | "BLOB" | "VARCHAR" | "VARBINARY" => "String"
case "DATETIME" | "TIMESTAMP" => "DateTime"
case "TINYINT" => "Int8"
case "SMALLINT" => "Int16"
case "FLOAT" => "Float32"
case "DOUBLE" => "Float64"
case "DATE" => "Date"
case "BIGINT" | "INT" =>
length match {
case null => "Int32"
case x =>
x.trim.toInt match {
case x if x < 3 => "Int8"
case x if x < 5 => "Int16"
case x if x < 9 => "Int32"
case _ => "Int64"
}
}
case "DECIMAL" =>
length.split(",").map(_.trim.toInt) match {
case Array(p, s) =>
p + s match {
case x if x <= 32 => s"Decimal32($s)"
case x if x <= 64 => s"Decimal64($s)"
case _ => s"Decimal128($s)"
}
case _ => throw new IllegalArgumentException
}
case x => x.toUpperCase()
}
}