Skip to content

Commit

Permalink
add column comment when create clickhouse table
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonliu committed Aug 4, 2022
1 parent 828c0b0 commit eb33863
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ object SchemaUtils {
StructType(structFields)
}

def toClickHouseSchema(catalystSchema: StructType): Seq[(String, String)] =
def toClickHouseSchema(catalystSchema: StructType): Seq[(String, String, String)] =
catalystSchema.fields
.map { field =>
val chType = toClickHouseType(field.dataType)
(field.name, maybeNullable(chType, field.nullable))
(field.name, maybeNullable(chType, field.nullable), field.getComment().map(s" COMMENT " + _).getOrElse(""))
}

private[clickhouse] def maybeNullable(chType: String, nullable: Boolean): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ClickHouseCatalog extends TableCatalog

val fieldsClause = SchemaUtils
.toClickHouseSchema(schema)
.map { case (fieldName, ckType) => s"${quoted(fieldName)} $ckType" }
.map { case (fieldName, ckType, comment) => s"${quoted(fieldName)} $ckType$comment" }
.mkString(",\n ")

val clusterOpt = props.get("cluster")
Expand Down

0 comments on commit eb33863

Please sign in to comment.