-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support index upsert #819
Support index upsert #819
Conversation
the following test fails
error message
|
@marsishandsome The test case is due to a bug in encodeRow.
After
|
319da0c
to
8af0f60
Compare
c5b699d
to
46ed424
Compare
/run-all-tests |
bc90f7a
to
b657a9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase #843 to let build success
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls update documents in the same PR
core/src/test/scala/com/pingcap/tispark/datasource/AddingIndexUpsertSuite.scala
Outdated
Show resolved
Hide resolved
core/src/test/scala/com/pingcap/tispark/datasource/AddingIndexUpsertSuite.scala
Outdated
Show resolved
Hide resolved
core/src/test/scala/com/pingcap/tispark/datasource/OnlyOnePkSuite.scala
Outdated
Show resolved
Hide resolved
core/src/test/scala/com/pingcap/tispark/datasource/OnlyOnePkSuite.scala
Outdated
Show resolved
Hide resolved
fe697f3
to
9fa4ce5
Compare
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add some test in DeduplicateSuite
to test the following code
uniqueIndices.foreach { index =>
{
mutableRdd = mutableRdd
.map { wrappedRow =>
val indexKey = buildUniqueIndexKey(wrappedRow.row, index)
(indexKey, wrappedRow)
}
.groupByKey()
.map(_._2.head)
}
}
core/src/test/scala/com/pingcap/tispark/datasource/AddingIndexUpsertSuite.scala
Outdated
Show resolved
Hide resolved
tikv-client/src/main/java/com/pingcap/tikv/allocator/RowIDAllocator.java
Outdated
Show resolved
Hide resolved
tikv-client/src/test/java/com/pingcap/tikv/codec/TableCodecTest.java
Outdated
Show resolved
Hide resolved
tikv-client/src/main/java/com/pingcap/tikv/codec/TableCodec.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would u pls provide a test design document?
@@ -428,6 +471,39 @@ class TiBatchWrite(@transient val df: DataFrame, | |||
} | |||
} | |||
|
|||
private def generateDataToBeRemovedRdd(rdd: RDD[WrappedRow], startTs: TiTimestamp) = { | |||
rdd | |||
.map { wrappedRow => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change rdd.map
to rdd.mapPartitions
, cause if use rdd.map
the following code will be called rdd.size
times
val snapshot = TiSessionCache.getSession(tiConf).createSnapshot(startTs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is planned to be done when we support batch get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be done without batch get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly LGTM
|
||
If `replace` is false, then | ||
* if primary key or unique index exists in db, data having conflicts expects an expection. | ||
* if no same primary key or unique index exists, data will be inserted. | ||
|
||
| SaveMode | Support | Semantics | | ||
| -------- | ------- | --------- | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls update this line
TiSpark's `Append` means upsert. If primary key is same, data will be updated; if no same primary key exists, data will be inserted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
LGTM |
In this PR, we support pk and index upsert.