Reputation: 3696
Lets say we have a target table TargetTable
and we have N different source tables such as SourceTable1, SourceTable2,...,SourceTableN
. Now let there be an update policy defined against TargetTable such that every source table feeds to the target table through this update policy. And the common query is a fixed function called TargetTable_loader()
. So the output of .show table TargetTable policy update
command will look as follows:-
[
{
"IsEnabled": true,
"Source": "SourceTable1",
"Query": "TargetTable_loader()",
"IsTransactional": true,
"PropagateIngestionProperties": false
},
{
"IsEnabled": true,
"Source": "SourceTable2",
"Query": "TargetTable_loader()",
"IsTransactional": true,
"PropagateIngestionProperties": false
},
.
.
.
.
{
"IsEnabled": true,
"Source": "SourceTableN",
"Query": "TargetTable_loader()",
"IsTransactional": true,
"PropagateIngestionProperties": false
}
]
Now, I have the following two questions about this situation.
Since it's a common function for all the (Source,Target) pairs , is there a way for the function to refer to the input table using some generic variable? Because if the function refers to a specific table name , it won't be generic any more. And at the same time if I had to create N different functions that each will refer to a different source table , it will be redundant. Is there a way to parameterize this function with input table name? Something like this:-
.create-or-alter function TargetTable_loader(InputTable:string) { InputTable | ..... }
Secondly , if I have such a common function for mapping all the source tables to the target tables as shown in the initial example -- and say data is being continuously ingested into all the source tables using streaming , what will happen if I abruptly update definition of the common function ? Of course I will ensure that even the new function definition will be valid. But my question is rather focused on whether sudden update of the function , which is being used as query for these N update policies , will affect execution of update policy causing failures merely due the fact that it was abrupt update.
Upvotes: 1
Views: 378
Reputation: 5298
Answers:
table(tableName)
:.create-or-alter function MyFunction(TableName: string) {
table(TableName)
| ...
}
Upvotes: 2