Skip to content

Commit ff30239

Browse files
authored
Merge pull request #51 from aws-samples/48-cqlreplicator-on-glue-add-support-for-blob-primary-keys
Added support for blob data type in primary key. Removed "var" from t…
2 parents 440d85f + 81fdd26 commit ff30239

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

glue/sbin/CQLReplicator.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ object GlueApp {
318318
case "decimal" => row.getDecimal(position)
319319
case "tinyint" => row.getByte(position)
320320
case "uuid" => row.getString(position)
321+
case "blob" => s"0${lit(row.getAs[Array[Byte]](colName)).toString.toLowerCase.replaceAll("'","")}"
321322
case _ => throw new CassandraTypeException("Unrecognized data type")
322323
}
323324
whereStmt.append(s"$colName=$v")
@@ -408,19 +409,18 @@ object GlueApp {
408409
tiles.foreach(tile => {
409410
keyspacesConn.withSessionDo {
410411
session => {
411-
var tailLoadStatus = ""
412-
var headLoadStatus = ""
413412
val rsTail = session.execute(s"SELECT * FROM migration.ledger WHERE ks='$srcKeyspaceName' and tbl='$srcTableName' and tile=$tile and ver='tail'").one()
414413
val rsHead = session.execute(s"SELECT * FROM migration.ledger WHERE ks='$srcKeyspaceName' and tbl='$srcTableName' and tile=$tile and ver='head'").one()
415414

416415
val tail = Option(rsTail)
417416
val head = Option(rsHead)
418-
419-
if (!tail.isEmpty) {
420-
tailLoadStatus = rsTail.getString("load_status")
417+
val tailLoadStatus = tail match {
418+
case t if !t.isEmpty => rsTail.getString("load_status")
419+
case _=> ""
421420
}
422-
if (!head.isEmpty) {
423-
headLoadStatus = rsHead.getString("load_status")
421+
val headLoadStatus = head match {
422+
case h if !h.isEmpty => rsHead.getString("load_status")
423+
case _=> ""
424424
}
425425

426426
logger.info(s"Processing $tile, head is $head, tail is $tail, head status is $headLoadStatus, tail status is $tailLoadStatus")

0 commit comments

Comments
 (0)