Hello Bexy,
I finally found some time to write the script.
Here you see three source tables filling the same (one) target table:
.create table SourceTableA (PK:string, A1:string, A2:int)
.create table SourceTableB (PK:string, B1:string, B2:int)
.create table SourceTableC (PK:string, C1:string)
.alter table SourceTableA policy streamingingestion enable
.alter table SourceTableB policy streamingingestion enable
.alter table SourceTableC policy streamingingestion enable
.create table Target (PK:string, A1:string, A2:int, B1:string, B2:int, C1:string, extraAcolumn1:int, extraAcolumn2:string, extraBcolumn:int, extraCcolumn:string)
.create function SourceAToTarget()
{
SourceTableA
| project PK , A1 , A2
| extend B1 = '', B2 = toint(1) , C1 = '', extraAcolumn1 = toint(1), extraAcolumn2 = '', extraBcolumn = toint(1), extraCcolumn = ''
}
.create function SourceBToTarget()
{
SourceTableB
| project PK, B1 , B2
| extend A1 = '', A2 = toint(1)
| extend C1 = '', extraAcolumn1 = toint(1), extraAcolumn2 = '', extraBcolumn = toint(1), extraCcolumn = ''
| project-reorder PK, A1, A2, B1, B2
}
.create function SourceCToTarget()
{
SourceTableC
| project PK , C1
| extend A1 = '', A2 = toint(1), B1 = '', B2 = toint(1), extraAcolumn1 = toint(1), extraAcolumn2 = '', extraBcolumn = toint(1), extraCcolumn = ''
| project-reorder PK, A1, A2, B1, B2, C1
}
.alter table Target policy update @'[{"Source": "SourceTableA", "Query": "SourceAToTarget", "IsEnabled" : true, "IsTransactional": true },{"Source": "SourceTableB", "Query": "SourceBToTarget", "IsEnabled" : true, "IsTransactional": true },{"Source": "SourceTableC", "Query": "SourceCToTarget", "IsEnabled" : true, "IsTransactional": true }]'
.show table Target policy update
.ingest inline into table ["SourceTableA"] <|
"pk1a","a1",1
"pk2a","a2",2
SourceTableA
Target
.ingest inline into table ["SourceTableB"] <|
"pk1b","bl",3
"pk2b","b2",4
SourceTableB
Target
.ingest inline into table ["SourceTableC"] <|
"pk1c","c1"
"pk2c","c2"
SourceTableC
Target
First, check out '.alter table Target policy update', it expects an array of policies:
Finally, the order and type of the columns outputted by the queries are specific:
Now you know how to combine multiple update policies.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.