在Streamsets中写入Cassandra时,如何解决“ CodecNotFoundException:找不到所需操作的编解码器:[blob <-> java.lang.String]”

时间:2019-06-14 07:04:45

标签: cassandra jython streamsets

我正在尝试使用Streamsets将Oracle表迁移到Cassandra。由于他们的文档说默认字段映射不适用于Cassandra中的Blob类型,因此,我尝试使用Jython Evaluator脚本手动转换BLOB字段。但我收到“ CodecNotFoundException:找不到所需操作的编解码器:[blob <-> java.lang.String]”

以下是我的Oracle表模式和相应的Cassandra模式。

CREATE TABLE SCHEMA1.TABLE1
(
  ID RAW(16) NOT NULL, 
  CREATED_DATE TIMESTAMP(6), 
  TYPE VARCHAR2(255 CHAR), 
  DETAILS BLOB 
) 


CREATE TABLE schema1.table1 (
    id uuid,
    created_date_timestamp timestamp,
    type text,
    details blob,
    PRIMARY KEY (id)
)

下面给出了Jython脚本中存在的代码段。

try: 
    import uuid
    from java.nio import ByteBuffer
    for record in records:
         record.value['DETAILS'] = ByteBuffer.wrap(bytearray(record.value['DETAILS']))
         output.write(record)
except Exception as e:
    for record in records:
        error.write(record, e.message)

0 个答案:

没有答案