Copilot commented on code in PR #171:
URL: https://github.com/apache/hbase-connectors/pull/171#discussion_r4399666353
##########
spark/hbase-spark/src/main/scala/org/apache/hadoop/hbase/spark/DefaultSource.scala:
##########
@@ -226,9 +226,20 @@ case class HBaseRelation(
val rdd = data.rdd
def convertToPut(row: Row) = {
// construct bytes for row key
- val rowBytes = rkIdxedFields.map {
- case (x, y) =>
- Utils.toBytes(row(x), y)
+ val rowBytes = rkIdxedFields.zipWithIndex.map {
+ case ((x, field), index) =>
+ val bytes = Utils.toBytes(row(x), field)
+ if (field.length == -1 && field.dt == StringType) {
+ require(
+ !bytes.contains(HBaseTableCatalog.delimiter),
+ s"Row key column '${field.colName}' cannot contain the
delimiter")
Review Comment:
This check rejects NUL bytes even in single-component keys and final string
components, so writing a key such as `"a\u0000b"` now fails instead of storing
its bytes unchanged. Restrict delimiter rejection to non-final strings, and
make both readers consume the remaining bytes for final variable-length strings
rather than searching for a delimiter. The same validation issue occurs in
`spark4/hbase-spark4/src/main/scala/org/apache/hadoop/hbase/spark/datasources/HBaseDataWriter.scala:118–120`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]