Sigma-Ma commented on code in PR #171:
URL: https://github.com/apache/hbase-connectors/pull/171#discussion_r4401866887
##########
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:
Thanks. I’ve limited the NUL check to non-final string fields and updated
both readers to consume the remaining bytes for the final string. Moving the
check alone would still truncate the value on read. I added round-trip tests
for single-component and final composite keys in both Spark modules.
--
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]