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

如何在Denodo 9.0.10中用VQL映射逗号与波浪线分隔的两列

Denodo 9.0.10 提取AttributeMask中10049对应ChangeData值的VQL实现

实现思路

通过Denodo内置的字符串处理和数组展开函数,将AttributeMask和ChangeData按规则拆分为数组,再通过位置索引关联对应元素,最终筛选出目标值10049及其对应的ChangeData内容。

VQL代码

CREATE OR REPLACE VIEW vw_Audit_10049 AS
SELECT
    attr_element AS attribute_value,
    change_element AS corresponding_change_data
FROM (
    SELECT
        -- 移除AttributeMask首尾逗号后拆分为数组
        split(substr(AttributeMask, 2, length(AttributeMask)-2), ',') AS attr_array,
        -- 将ChangeData按波浪线拆分为数组(连续波浪线对应空字符串)
        split(ChangeData, '~') AS change_array
    FROM bv_AuditBase
) AS base_arrays
-- 展开AttributeMask数组并保留元素位置
UNNEST attr_array AS attr_element WITH ORDINALITY AS attr_pos
-- 展开ChangeData数组并保留元素位置
UNNEST change_array AS change_element WITH ORDINALITY AS change_pos
-- 匹配位置并筛选目标属性值
WHERE attr_element = '10049' AND attr_pos = change_pos;

代码说明

  1. 处理AttributeMask:

    • substr(AttributeMask, 2, length(AttributeMask)-2):移除首尾的逗号,提取有效属性值字符串。
    • split(..., ','):将处理后的字符串按逗号拆分为数组,每个元素对应一个属性值。
  2. 处理ChangeData:

    • split(ChangeData, '~'):直接按波浪线拆分字符串,连续波浪线会生成空字符串,完美匹配缺失值规则。
  3. 关联与筛选:

    • UNNEST ... WITH ORDINALITY:展开数组的同时获取每个元素的位置索引(从1开始计数)。
    • 通过attr_pos = change_pos确保属性值与变更数据的位置一一对应,再筛选出attr_element = '10049'的记录,得到最终结果。

示例结果

基于提供的测试数据,执行后会得到以下结果:

attribute_valuecorresponding_change_data
10049100
10049101
10049104
10049100

内容的提问来源于stack exchange,提问作者Coppertank

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 03:14:53