对于第一个 table 中不匹配的行,Talend tMap left outer join 输出零而不是 null
Talend tMap left outer join outputs zero instead of null for unmattched lines in first table
两个 table T1 和 T2 默认左连接,return table T1 中的所有行通过匹配结果连接到 table T2,对于T1 的行在 T2 中没有匹配项,左连接用空值
完成它们
假设 T1 包含以下行
| id | class | student_id |
|-------------------------|
| 1 | math | null |
| 2 | svt | 1 |
并且 T2 包含以下行:
| id | name |
|-----------|
| 1 | rach |
T1 左连接到 T2 的结果
select *
from T1 left join T2 on T1.student_id = T2.id
会是这样的(我提取了很多细节来展示案例问题)
| id | class | student_id | id | name |
|---------------------------------------|
| 1 | math | null | null| null |
| 2 | svt | 1 | 1 | rach |
作为使用 tMap 进行左连接的后果,我希望有相同的行为,更重要的是,不匹配的行应该用空而不是零填充
上面的图片显示了实验的简化版本,以说明 Talend 中的问题
在 bref 中,对于 table res_partner 中不匹配的行,输出 sales_rep_key 的值为零而不是 null
谁能给我解释一下。
这在很大程度上取决于输入数据如何适用于您的用例,包括 main
和 lookup
行集。如果我采用您的示例数据库案例并在 Talend 中实施它,我会收到符合您期望的输出。 NULL
所有不匹配的记录 row/columns。
根据你的演示,我看到你正在尝试执行类似 -
(sales_rep.id == 0) ? context.sales_rep_unko
但是我觉得你应该像这样使用(下面 - 组合中的任何一个都可以)而不是因为 left-join
in tMap
会有不匹配的行
(Relational.ISNULL(sales_rep.id) || sales_rep.id.isEmpty() || sales_rep.id.toString() == null)
两个 table T1 和 T2 默认左连接,return table T1 中的所有行通过匹配结果连接到 table T2,对于T1 的行在 T2 中没有匹配项,左连接用空值
完成它们假设 T1 包含以下行
| id | class | student_id |
|-------------------------|
| 1 | math | null |
| 2 | svt | 1 |
并且 T2 包含以下行:
| id | name |
|-----------|
| 1 | rach |
T1 左连接到 T2 的结果
select *
from T1 left join T2 on T1.student_id = T2.id
会是这样的(我提取了很多细节来展示案例问题)
| id | class | student_id | id | name |
|---------------------------------------|
| 1 | math | null | null| null |
| 2 | svt | 1 | 1 | rach |
作为使用 tMap 进行左连接的后果,我希望有相同的行为,更重要的是,不匹配的行应该用空而不是零填充
上面的图片显示了实验的简化版本,以说明 Talend 中的问题 在 bref 中,对于 table res_partner 中不匹配的行,输出 sales_rep_key 的值为零而不是 null
谁能给我解释一下。
这在很大程度上取决于输入数据如何适用于您的用例,包括 main
和 lookup
行集。如果我采用您的示例数据库案例并在 Talend 中实施它,我会收到符合您期望的输出。 NULL
所有不匹配的记录 row/columns。
根据你的演示,我看到你正在尝试执行类似 -
(sales_rep.id == 0) ? context.sales_rep_unko
但是我觉得你应该像这样使用(下面 - 组合中的任何一个都可以)而不是因为 left-join
in tMap
会有不匹配的行
(Relational.ISNULL(sales_rep.id) || sales_rep.id.isEmpty() || sales_rep.id.toString() == null)