added HBase timestamp support#297
Open
sbarnoud wants to merge 2 commits intohortonworks-spark:masterfrom
Open
Conversation
regata
reviewed
Apr 22, 2019
| val tsSeq = { | ||
| if (relation.catalog.ts.isPresent) { | ||
| val f = relation.catalog.getTimestamp.head | ||
| Seq((f, result.rawCells()(0).getTimestamp)).toMap |
There was a problem hiding this comment.
@sbarnoud when there are multiple cells in a single column, each cell will have different timestamp. However, this code reads the timestamp only from the latest cell. Is this intended behavior?
There was a problem hiding this comment.
plus tsSeq is not used inside buildRows
regata
reviewed
Apr 23, 2019
| } | ||
| } | ||
|
|
||
| val valueSeq: Seq[Map[Long, (Field, Any)]] = fields.filter(c => HBaseTableCatalog.isNotReserved(c.cf)).map { x => |
There was a problem hiding this comment.
how about this?
val tsField = relation.catalog.getTimestamp.head // ADDED
val valueSeq: Seq[Map[Long, (Field, Any)]] = fields.filter(c => HBaseTableCatalog.isNotReserved(c.cf)).map { x =>
import scala.collection.JavaConverters.asScalaBufferConverter
val dataType = SHCDataTypeFactory.create(x)
val kvs = result.getColumnCells(
relation.catalog.shcTableCoder.toBytes(x.cf),
relation.catalog.shcTableCoder.toBytes(x.col)).asScala
kvs.map(kv => {
val v = CellUtil.cloneValue(kv)
(kv.getTimestamp, x -> dataType.fromBytes(v))
}).toMap.withDefaultValue(x -> null)
}
val ts = valueSeq.foldLeft(Set.empty[Long])((acc, map) => acc ++ map.keySet)
//we are loosing duplicate here, because we didn't support passing version (timestamp) to the row
ts.map(version => {
val tsSeq = Seq((tsField, version)).toMap // ADDED
keySeq ++ tsSeq ++ valueSeq.map(_.apply(version)).toMap // MODIFIED
}).map { unioned =>
// Return the row ordered by the requested order
Row.fromSeq(fields.map(unioned.get(_).getOrElse(null)))
}The only extra change that is required is to specify timestamp column when mergeToLatest is false
Author
There was a problem hiding this comment.
My bad.In my use case, i have a single version, and i forget this point.
Yes, we should have the ts corresponding to the version!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#210
What changes were proposed in this pull request?
Added support of HBase timestamp.
How was this patch tested?
New TU. Added control in TU that "reserved" column families (rowkey and timestamp) are not created.