我最近刚刚开始将Rhino-Etl用于非常简单的ETL过程,并取得了巨大的成功。我现在有一个稍微复杂的场景要处理,我没有发现ConventionInputCommandOperation的行为方式与我预期的一样。
我做了一个非常简单的例子来说明我想要做的事情。基本上,我涉及两个系统,直到我第一次查询系统1,我才知道我想从系统2得到什么。我认为在另一个InputOperation之后立即注册一个InputOperation的行为就像一个循环。这样,操作1中的每一行都将提供给操作2。下面的代码失败,并显示“无法执行操作DetailReader:必须声明标量变量@PlanetAbbrv”。所以我的问题是,当输入操作依赖于之前的输入操作时,您打算如何处理这种情况?
谢谢,布赖恩
using System;
using Rhino.Etl.Core;
using Rhino.Etl.Core.ConventionOperations;
namespace ETLTest
{
class Program
{
static void Main()
{
new MainProcess().Execute();
Console.ReadLine();
}
}
public class MainProcess : EtlProcess
{
protected override void Initialize()
{
Register(new MainReader());
Register(new DetailReader());
}
protected override void PostProcessing()
{
foreach (var exception in GetAllErrors())
{
throw exception;
}
}
}
public class MainReader : ConventionInputCommandOperation
{
public MainReader() : base("Galactic1")
{
Command = @"select * from Planet";
}
}
public class DetailReader : ConventionInputCommandOperation
{
public DetailReader() : base("Galactic2")
{
Command = @"select * from Delivery where DeliveryPlanetAbbrv = @PlanetAbbrv";
}
}
}发布于 2014-01-03 23:46:22
您需要让DetailReader选择所有行(去掉where操作)。然后使用JoinOperation将详细信息与主要信息进行匹配。
Register(new JoinPlanets()
.Right(new MainReader())
.Left(new DetailReader()));
public class JoinPlanets: JoinOperation
{
protected override Row MergeRows(Row leftRow, Row rightRow)
{
Row row = leftRow.Clone();
foreach (var column in leftRow.Columns)
row[column] = leftRow[column];
return row;
}
protected override void SetupJoinConditions()
{
FullOuterJoin.Left("PlanetAbbrv")
.Right("DeliveryPlanetAbbrv");
}
}https://stackoverflow.com/questions/20055307
复制相似问题