我有一个 3 维度和 5 规则的SQL模型。
我希望规则按以下顺序执行:
rule1[1,any,1]
rule2[1,any,1]
rule3[1,any,1]
rule4[1,any,1]
rule5[1,any,1]
,
rule1[1,any,2]
rule2[1,any,2]
rule3[1,any,2]
rule4[1,any,2]
rule5[1,any,2]
...
rule1[1,any,n]
rule2[1,any,n]
rule3[1,any,n]
rule4[1,any,n]
rule5[1,any,n]
,
rule1[2,any,1]
rule2[2,any,1]
rule3[2,any,1]
rule4[2,any,1]
rule5[2,any,1]
,
rule1[2,any,2]
rule2[2,any,2]
rule3[2,any,2]
rule4[2,any,2]
rule5[2,any,2]
....
rule1[2,any,m]
rule2[2,any,m]
rule3[2,any,m]
rule4[2,any,m]
rule5[2,any,m]
. . . and so on . . .
我希望模型能够处理包含(dim1,dim2,dim3)各种组合的表。
例如,
(1,dog,1), (1,dog,2), (1,dog,3)
所有都存在于某个表格中,但是
(1,dog,4), (2,dog,any)
不要。
但是如果我有一天决定给它提供一个DID包含(1,狗,4)或(2,狗,1)等的表格,我希望模型仍然有用。
我们如何编程模型以适应不同的(dim1,dim2,dim3)组合?
答案 0 :(得分:0)
我最终做了:
rules
iterate(360)
(
rule1[1+floor(iteration_number/20),any,1+mod(iteration_number,24)],
rule2[1+floor(iteration_number/20),any,1+mod(iteration_number,24)],
rule3[1+floor(iteration_number/20),any,1+mod(iteration_number,24)],
rule4[1+floor(iteration_number/20),any,1+mod(iteration_number,24)],
rule5[1+floor(iteration_number/20),any,1+mod(iteration_number,24)]
)
这是有效的,因为我知道dim1总是小于18而dim3总是小于15,所以floor和mod函数给出了所需的规则执行顺序。