Skip to content

Commit 9338341

Browse files
committed
fix: scala format
1 parent 26a7b0a commit 9338341

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

caraml-store-spark/src/main/scala/dev/caraml/spark/odps/CustomDialect.scala

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class CustomDialect extends JdbcDialect {
2727
*/
2828
private def getCommonCatalystType(typeName: String): Option[DataType] = {
2929
typeName.toUpperCase() match {
30-
case "TINYINT" => Option(ByteType)
30+
case "TINYINT" => Option(ByteType)
3131
case "SMALLINT" => Option(ShortType)
32-
case "INT" => Option(IntegerType)
33-
case "BIGINT" => Option(LongType)
34-
case "BINARY" => Option(BinaryType)
35-
case "FLOAT" => Option(FloatType)
36-
case "DOUBLE" => Option(DoubleType)
32+
case "INT" => Option(IntegerType)
33+
case "BIGINT" => Option(LongType)
34+
case "BINARY" => Option(BinaryType)
35+
case "FLOAT" => Option(FloatType)
36+
case "DOUBLE" => Option(DoubleType)
3737
// case s if s.startsWith("DECIMAL") =>
3838
// val mdat = s.stripPrefix("DECIMAL(").stripSuffix(")").split(",")
3939
// if (mdat.length == 2) {
@@ -46,8 +46,8 @@ class CustomDialect extends JdbcDialect {
4646
// case s if s.startsWith("VARCHAR") => Option(VarcharType(s.stripPrefix("VARCHAR(").stripSuffix(")").toInt))
4747
// case s if s.startsWith("CHAR") => Option(CharType(s.stripPrefix("CHAR(").stripSuffix(")").toInt))
4848
case s if s.startsWith("VARCHAR") => Option(StringType)
49-
case s if s.startsWith("CHAR") => Option(StringType)
50-
case "STRING" => Option(StringType)
49+
case s if s.startsWith("CHAR") => Option(StringType)
50+
case "STRING" => Option(StringType)
5151
// case "DATE" => Option(DateType)
5252
// case "DATETIME" => Option(TimestampType)
5353
// case "TIMESTAMP" => Option(TimestampType)
@@ -58,20 +58,29 @@ class CustomDialect extends JdbcDialect {
5858
}
5959
}
6060

61-
override def getCatalystType(sqlType: Int, typeName: String, size: Int, md: MetadataBuilder): Option[DataType] = {
61+
override def getCatalystType(
62+
sqlType: Int,
63+
typeName: String,
64+
size: Int,
65+
md: MetadataBuilder
66+
): Option[DataType] = {
6267
sqlType match {
6368
case java.sql.Types.ARRAY =>
6469
val elementTypeName = typeName.toUpperCase().stripPrefix("ARRAY<").stripSuffix(">")
65-
val elementType = getCommonCatalystType(elementTypeName).map(ArrayType(_))
70+
val elementType = getCommonCatalystType(elementTypeName).map(ArrayType(_))
6671

6772
if (elementType.isEmpty) {
6873
throw new SQLException(s"Unsupported type $typeName")
6974
}
70-
logDebug(s"CustomDialect sqlType: $sqlType md: ${md.build().toString()} size: $size typeName: $typeName elementType: ${elementType.getOrElse(ArrayType(NullType)).elementType}")
75+
logDebug(
76+
s"CustomDialect sqlType: $sqlType md: ${md.build().toString()} size: $size typeName: $typeName elementType: ${elementType.getOrElse(ArrayType(NullType)).elementType}"
77+
)
7178
elementType
7279
case _ =>
7380
val dataType = getCommonCatalystType(typeName.toUpperCase())
74-
logDebug(s"CustomDialect sqlType: $sqlType md: ${md.build().toString()} size: $size typeName: $typeName dataType: $dataType")
81+
logDebug(
82+
s"CustomDialect sqlType: $sqlType md: ${md.build().toString()} size: $size typeName: $typeName dataType: $dataType"
83+
)
7584
dataType
7685
}
7786
}

0 commit comments

Comments
 (0)