有没有使用Go执行2个PCollection的左联接的简单方法? 我看到SQL联接只在Java中可用.
package main
import (
"context"
"flag"
"github.com/apache/beam/sdks/v2/go/pkg/beam"
"github.com/apache/beam/sdks/v2/go/pkg/beam/log"
"github.com/apache/beam/sdks/v2/go/pkg/beam/x/beamx"
)
type customer struct {
CustID int
FName string
}
type order struct {
OrderID int
Amount int
Cust_ID int
}
func main() {
flag.Parse()
beam.Init()
ctx := context.Background()
p := beam.NewPipeline()
s := p.Root()
var custList = []customer{
{1, "Bob"},
{2, "Adam"},
{3, "John"},
{4, "Ben"},
{5, "Jose"},
{6, "Bryan"},
{7, "Kim"},
{8, "Tim"},
}
var orderList = []order{
{123, 100, 1},
{125, 30, 3},
{128, 50, 7},
}
custPCol := beam.CreateList(s, custList)
orderPCol := beam.CreateList(s, orderList)
// Left Join custPcol with orderPCol
// Expected Result
// CustID | FName |OrderID| Amount
// 1 | Bob | 123 | 100
// 2 | Adam | |
// 3 | John | 125 | 100
// 4 | Ben | |
// 5 | Jose | |
// 6 | Bryan | |
// 7 | Kim | 125 | 100
// 8 | Tim | |
if err := beamx.Run(ctx, p); err != nil {
log.Exitf(ctx, "Failed to execute job: %v", err)
}
}
我想加入这2个PCollect并执行进一步的操作.我看到了关于CoGroupByKey的文档,但无法将其转换为普通SQL连接所能做的格式.
对此有何建议?