简体   繁体   English

从超级字段中提取值

[英]Extract value from a super field

I have a field event_params that is type super .我有一个类型为super的字段event_params

Example value of event_params: event_params 的示例值:

[
{"key":"type","value":{"string_value":"blah"}},
{"key":"value","value":{"double_value":5.99}},
{"key":"category","value":{"string_value":"add-ons"}},
{"key":"event_id","value":{"string_value":"956bb654-be90-5334-91a3-ee97074da0eb"}},
]

I would like to get event_id without unfolding the whole thing, I just want to drill down into it and pull up event id.我想在不展开整个事情的情况下获得 event_id,我只想深入了解它并提取事件 ID。

Afterreading docs and messing around, I can d0 this: 阅读文档并弄乱之后,我可以这样做:

select
    event_params[4].value,
    event_params[4].key,
    event_params
from "myschema"."mytable"
where event_name = 'purchase'
and event_timestamp = 1660193632449615;

Here I used indexing with 4. But data will not necessarily be in the same order.这里我使用了 4 的索引。但是数据不一定是相同的顺序。 INstead I want to filter based on the key being event_id .相反,我想根据作为event_idkey进行过滤。

How can I modify this: event_params[4].key to instead filter based on the name of the key I want, in this case event_id ?我该如何修改: event_params[4].key以根据我想要的键的名称进行过滤,在本例中为event_id

You can try something like this:你可以尝试这样的事情:

select
    event_name,
    ep
from 
    "myschema"."mytable" m, 
     m.event_params as ep
where 
    event_name = 'purchase'
    and event_timestamp = 1660193632449615
    and ep.key = 'event_id';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 UPDATE、SUM 和 EXTRACT 函数从计算字段更新列 - Updating a column from a calculated field using UPDATE, SUM & EXTRACT functions 如何从 BigQuery 中的字符串中提取值 - How to extract the value from the string in BigQuery 在逻辑应用程序中从 sql json 中提取值 - extract value from sql json in logic apps 根据标签值从 soap 响应中提取值 - Extract value from soap response based on tag value 如何从 AWS Athena 中的 JSON 对象数组中提取字段? - How to extract a field from an array of JSON objects in AWS Athena? 是否可以从 EventBridge 事件数据中提取“instanceId”并将其用作目标值? - Is it possible to extract "instanceId" from EventBridge event data, and use it as Target Value? 如何从文档中获取特定字段值 - How to get specific field value from document Firebase 搜索不同字段时从一个字段获取值 - Firebase get value from one field when searching for different field 如何将来自 Firestore 的字段值存储在 Flutter 中? - How to store field value from firestore in Flutter? 来自字符串字段的 AWS Athena json_extract 查询返回空值 - AWS Athena json_extract query from string field returns empty values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM