Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.apache.hudi.config.HoodieBootstrapConfig.{BASE_PATH, INDEX_CLASS_NAME
import org.apache.hudi.config.{HoodieInternalConfig, HoodieWriteConfig}
import org.apache.hudi.exception.HoodieException
import org.apache.hudi.execution.bulkinsert.{BulkInsertInternalPartitionerWithRowsFactory, NonSortPartitionerWithRows}
import org.apache.hudi.hive.util.ConfigUtils
import org.apache.hudi.hive.{HiveSyncConfig, HiveSyncTool}
import org.apache.hudi.index.SparkHoodieIndexFactory
import org.apache.hudi.internal.DataSourceInternalWriterHelper
Expand All @@ -45,6 +46,7 @@ import org.apache.hudi.table.BulkInsertPartitioner
import org.apache.log4j.LogManager
import org.apache.spark.api.java.JavaSparkContext
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.hudi.HoodieOptionConfig
import org.apache.spark.sql.internal.{SQLConf, StaticSQLConf}
import org.apache.spark.sql.types.StructType
import org.apache.spark.sql.{DataFrame, Dataset, Row, SQLContext, SaveMode, SparkSession}
Expand Down Expand Up @@ -577,6 +579,7 @@ object HoodieSparkSqlWriter {
var metaSyncEnabled = hoodieConfig.getStringOrDefault(META_SYNC_ENABLED).toBoolean
var syncClientToolClassSet = scala.collection.mutable.Set[String]()
hoodieConfig.getString(META_SYNC_CLIENT_TOOL_CLASS_NAME).split(",").foreach(syncClass => syncClientToolClassSet += syncClass)
hoodieConfig.setValue(HIVE_TABLE_SERDE_PROPERTIES, getHiveTableSerdeProperties(hoodieConfig))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, this code and getHiveTableSerdeProperties is for this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


// for backward compatibility
if (hiveSyncEnabled) {
Expand Down Expand Up @@ -608,6 +611,24 @@ object HoodieSparkSqlWriter {
metaSyncSuccess
}

private def getHiveTableSerdeProperties(hoodieConfig: HoodieConfig): String = {
val serdeOption = new java.util.HashMap[String, String]

if (hoodieConfig.getString(RECORDKEY_FIELD) != null) {
serdeOption.put(HoodieOptionConfig.SQL_KEY_TABLE_PRIMARY_KEY.sqlKeyName, hoodieConfig.getString(RECORDKEY_FIELD))
}

if (hoodieConfig.getString(PRECOMBINE_FIELD) != null) {
serdeOption.put(HoodieOptionConfig.SQL_KEY_PRECOMBINE_FIELD.sqlKeyName, hoodieConfig.getString(PRECOMBINE_FIELD))
}

if (hoodieConfig.getString(TABLE_TYPE) != null) {
serdeOption.put(HoodieOptionConfig.SQL_KEY_TABLE_TYPE.sqlKeyName, HoodieOptionConfig.reverseValueMapping(hoodieConfig.getString(TABLE_TYPE)))
}

ConfigUtils.configToString(serdeOption)
}

/**
* Group all table/action specific information into a case class.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ object HoodieOptionConfig {
SQL_VALUE_TABLE_TYPE_MOR -> DataSourceWriteOptions.MOR_TABLE_TYPE_OPT_VAL
)

private lazy val reverseValueMapping = valueMapping.map(f => f._2 -> f._1)
lazy val reverseValueMapping = valueMapping.map(f => f._2 -> f._1)

def withDefaultSqlOptions(options: Map[String, String]): Map[String, String] = defaultSqlOptions ++ options

Expand Down