The Paillave.EtlNet.SqlServer extension does not provide a dedicated lookup operator. Instead, use the core ETL.NET Lookup operator combined with a stream retrieved via CrossApplySqlServerQuery.
Warning: Memory Usage
Lookup waits for the entire target stream to complete and stores it in memory. For large datasets, use LeftJoin instead.
Optimized Join Pattern
To use LeftJoin efficiently with billions of rows, ensure both streams are sorted on the pivot key. You can use EnsureSorted to verify sorting without re-sorting, and EnsureKeyed to verify the target stream is sorted and contains no duplicates.
Note: If a stream is already sorted, do not call a sort operator; use EnsureSorted to validate it.
// Optimized pattern using LeftJoin and sorting validation
var authorStream = contextStream
.CrossApplySqlServerQuery("get authors", o => o
.FromQuery("select a.* from dbo.Author as a order by a.Id")
.WithMapping(i => new
{
Id = i.ToNumberColumn<int>("Id"),
Name = i.ToColumn("Name"),
Reputation = i.ToNumberColumn<int>("Reputation")
}))
.EnsureKeyed("ensure authors are sorted by Id with no duplicate", i => i.Id);
postStream
.EnsureSorted("ensure posts are sorted by AuthorId", i => i.AuthorId)
.LeftJoin("get related author", authorStream,
l => l.AuthorId,
r => r.Id,
(l, r) => new { Post = l, Author = r })
.Do("show value on console", i => Console.WriteLine($"{i.Post.Title} ({i.Author.Name})"));