Decision table
DecisionTable
Bases: Node
Matches named inputs against rows of rules and returns the outputs of the matching rows.
Inputs arrive under the input column names. Each rule holds one condition cell per input column
(see compile_condition for the grammar) and one literal cell per output column, read as the
column type; an empty output cell is None. Rules are compiled once, when the node is created,
so a malformed cell fails then rather than on a run.
Hit policies: first returns the first matching rule in table order, unique allows at most one
match and fails the run on overlap, collect takes every match and folds each output column with
the aggregation: list keeps the values, count is the number of matches, and sum, min, max
fold a numeric column (or an Any column whose output cells are all numbers, judged over the table so
a run's shape never depends on which rows matched) and otherwise keep the list. No match yields None
for a folded column and an empty list for a collected one. The output always
carries matched_rules, the {id, name} of the rules that fired, in table order; a rule switched
off never fires.
Source code in dynamiq/nodes/operators/decision_table.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
execute(input_data, config=None, **kwargs)
Evaluates the rules against the input and returns the outputs of the matching rules.
Source code in dynamiq/nodes/operators/decision_table.py
329 330 331 332 333 334 335 336 337 338 339 340 | |
to_dict(include_secure_params=True, for_tracing=False, **kwargs)
Converts the instance to a dictionary.
A trace keeps the first rules and the total: the rules that fired are in the output, and a large table would otherwise be copied into every run it takes part in.
Source code in dynamiq/nodes/operators/decision_table.py
278 279 280 281 282 283 284 285 286 287 288 289 | |
cell_text(cell)
A cell as the text the grid shows: YAML may hold a number or a boolean where the UI holds text.
Source code in dynamiq/nodes/operators/decision_table.py
57 58 59 60 61 62 63 | |
coerce_value(value, column_type)
The incoming value read as the column type. None means it cannot be, and only an empty cell matches.
Source code in dynamiq/nodes/operators/decision_table.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
compile_condition(text, column_type, where)
Turns one condition cell into a predicate over the coerced input value.
The grammar is the one the editor validates: empty or * matches anything; a literal means equals;
>= 620, < 0.8, != VA compare; [620..680] is a range, [ inclusive and ( exclusive per
side; a comma-separated list means any of, and != FHA, VA none of. A value the column cannot
read (None) matches only an empty cell, so a missing input never satisfies a condition, != included.
Source code in dynamiq/nodes/operators/decision_table.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
parse_literal(text)
A quoted value stays text, so "700" is not a number; true and false are booleans.
Source code in dynamiq/nodes/operators/decision_table.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
read_literal(text, column_type, where)
A cell literal read as the column type; a literal the column cannot hold is a configuration error.
Source code in dynamiq/nodes/operators/decision_table.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
split_alternatives(text)
Splits on the commas outside quotes, so "a, b", c is two alternatives.
A quote opens an alternative only at its start, so an apostrophe inside a word (O'Brien, Smith)
is text and the comma after it still splits.
Source code in dynamiq/nodes/operators/decision_table.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |