diff --git a/velox/connectors/hive/HiveConnectorUtil.cpp b/velox/connectors/hive/HiveConnectorUtil.cpp index 2fadb1fd8acd..09099c37d188 100644 --- a/velox/connectors/hive/HiveConnectorUtil.cpp +++ b/velox/connectors/hive/HiveConnectorUtil.cpp @@ -436,12 +436,16 @@ std::unique_ptr parseSerdeParameters( auto mapKeyIt = serdeParameters.find(dwio::common::SerDeOptions::kMapKeyDelim); + auto escapeCharIt = + serdeParameters.find(dwio::common::SerDeOptions::kEscapeChar); + auto nullStringIt = tableParameters.find( dwio::common::TableParameter::kSerializationNullFormat); if (fieldIt == serdeParameters.end() && collectionIt == serdeParameters.end() && mapKeyIt == serdeParameters.end() && + escapeCharIt == serdeParameters.end() && nullStringIt == tableParameters.end()) { return nullptr; } @@ -458,8 +462,19 @@ std::unique_ptr parseSerdeParameters( if (mapKeyIt != serdeParameters.end()) { mapKeyDelim = parseDelimiter(mapKeyIt->second); } - auto serDeOptions = std::make_unique( - fieldDelim, collectionDelim, mapKeyDelim); + + uint8_t escapeChar; + bool hasEscapeChar = false; + if (escapeCharIt != serdeParameters.end() && !escapeCharIt->second.empty()) { + hasEscapeChar = true; + escapeChar = escapeCharIt->second[0]; + } + + auto serDeOptions = hasEscapeChar + ? std::make_unique( + fieldDelim, collectionDelim, mapKeyDelim, escapeChar, true) + : std::make_unique( + fieldDelim, collectionDelim, mapKeyDelim); if (nullStringIt != tableParameters.end()) { serDeOptions->nullString = nullStringIt->second; } diff --git a/velox/dwio/common/Options.h b/velox/dwio/common/Options.h index 64566f3a1af9..b1240cb2b8ca 100644 --- a/velox/dwio/common/Options.h +++ b/velox/dwio/common/Options.h @@ -83,6 +83,7 @@ class SerDeOptions { inline static const std::string kFieldDelim{"field.delim"}; inline static const std::string kCollectionDelim{"collection.delim"}; inline static const std::string kMapKeyDelim{"mapkey.delim"}; + inline static const std::string kEscapeChar{"escape.delim"}; explicit SerDeOptions( uint8_t fieldDelim = '\1',