You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache NiFi HBase Lookup返回MapRecord,如何提取单一值?

Fixing HBase Lookup's MapRecord Value Extraction in Apache NiFi

Hey there! Let's work through this issue where your HBase Lookup is returning a MapRecord[{SERIAL_NUM=123456789}] instead of the raw value you need for hbase_integid. I’ve dealt with this exact scenario before, so here’s how to extract that value cleanly:

Why You’re Seeing MapRecord

First, a quick context: The HBase Lookup processor returns a Record object (in your case, a MapRecord) by default. This object wraps all the columns you queried from HBase, which is why you see the key-value pair structure instead of just the number.

Step-by-Step Solutions

You’ve got a couple straightforward ways to pull out the 123456789 value and assign it to hbase_integid:

Option 1: Use EvaluateJsonPath (Extract as Flow File Attribute)

If you want to first store the value as an attribute (useful if you need to reference it in other processors later):

  • Add an EvaluateJsonPath processor right after your HBase Lookup.
  • Set the Destination property to flowfile-attribute.
  • Add a new property:
    • Name: hbase_integid
    • Value: $.SERIAL_NUM
    • This JSON Path expression targets the SERIAL_NUM field inside the returned Record.

Option 2: Use UpdateRecord (Directly Modify Your JSON Flow File)

If you want to add the hbase_integid field directly to your output JSON data:

  • Add an UpdateRecord processor after HBase Lookup.
  • Configure the Record Reader to JsonTreeReader and Record Writer to JsonRecordSetWriter (make sure these are properly set up to handle your JSON schema).
  • In the Record Path Value section, add a new entry:
    • Record Path: /hbase_integid (this is the new field you want to add)
    • Value: ${record:value('/SERIAL_NUM')}
    • This NiFi Expression Language (NEL) call pulls the SERIAL_NUM value from the HBase Lookup’s returned Record.

Quick Tip

Double-check that your HBase Lookup has the Return Single Row option enabled. This ensures you only get one matching row back, which simplifies extracting the value (no need to handle multiple records).

Once you implement either of these, you’ll have the plain 123456789 value assigned to hbase_integid as needed!

内容的提问来源于stack exchange,提问作者erkan.oktay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:06:16