如何在PDI中获取未知字段名称?

发布于 2025-01-25 03:34:40 字数 1108 浏览 3 评论 0原文

在PDI中,各种转换可能会将数据(在字段中)放入“结果”中,就像将KTR中的数据集复制到剪贴板一样,因此可以在父级作业或下游姐妹KTR中使用。

从结果步骤跳到将行复制到result步骤时,多个字段可以在上加入将行复制到结果 sptep,即使它们具有不同的字段名称,数据类型和字段数量。通常,如果来自不同传入的啤酒花的字段名称并不相同,但在这种情况下不是,通常会在设计时间抱怨。即使在运行时也没有抱怨。示例:

我可以猜测哪个KTR是使用复制到结果步骤的第一个ktr,则在另一个转换中,我可以使用另一个转换从结果中获取行步骤和包含get(fields.in,“ firstName”))的UDJC步骤以检索结果,这是人们所期望的。

以这种方式使用结果非常有用,但是在我的用例中可以发送任何喜欢的内容,因此,没有解决方案可以在设计时在任何地方键入“ firstName”,我相信根据我所看到的示例,元数据注入需要(?),但是元数据上的PDI文档对我来说,注射听起来像是一句话沙拉,所以不确定。

无论如何,我可以使用从结果步骤中获取行,然后是写入log步骤,无论我喜欢的任何地方都没有指定字段,并标记了打印标头复选框。在日志中打印每个字段名称(以及每个字段的行值),而我在任何地方都键入“名字”。

所有这些都是用于上下文的,但是核心问题是...是否可以将“结果标题”名称从结果或变量中获取,而不是仅将其打印到日志中?

似乎这应该很简单,但没有找到有关此的任何信息。

如果我要使用另一种方法,例如元数据注射,似乎是同样的原理,并且将适用同样的问题。也许我的问题的答案是“检测结果中的字段,就像您在任何流中检测到字段一样”,在这种情况下,我会问:'我如何检测到流中存在哪些字段,而又不知道它们可能是领先于什么。时间”?

In PDI, various transformations may put data (in fields) into the "Result", kind of like copying a dataset in a KTR to a clipboard, so it can be used in the parent job or a downstream sister KTR.

When a Get rows from result step hops to a Copy rows to result step, multiple fields can join on the Copy rows to result step even if they have different field names, data types, and quantity of fields. Usually Spoon complains at design time if field names from different incoming hops aren't identical, but not in that case. Even at runtime, there is no complaint. Example:

Example where exogenous rows can ghost newer rows

If I can guess which KTR was the very first in execution to use a Copy rows to result step, then in another transformation I can use another Get rows from result step and a UDJC step containing get(Fields.In, "FirstName") to retrieve that field which was in the Result, as one would expect.

Using the Result this way is very useful, but in my use case the incoming field names from Get rows from result such as "FirstName" cannot be predicted, having originated literally anywhere, even from a web service that can send whatever it likes, so no solution will work that requires me to type "FirstName" anywhere at design time, which I believe metadata injection requires (?) according to the examples of it I've seen, but the PDI documentation on metadata injection sounds like word salad to me so not sure.

Anyway, I can use a Get rows from result step followed by a Write to log step wherever I like with no fields specified and the Print headers checkbox marked. That prints each field name in the log (along with the row's values for each field) without me having typed "First Name" anywhere.

All of this is for context, but the core question is... Is it possible to get field header names from Result into a stream or variable instead of just printed to the log?

Seems like this should be quite simple, but have failed to find any information about this.

If I were to use another method like metadata injection, seems like the same principle and same question would apply. Maybe the answer to my question is "Detect fields in Result just like you detect fields in any stream", in which case I would be asking, "How do I detect what fields are present in a stream without knowing what they might be ahead of time"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文