data-flow-control 0.2.3__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/Cargo.lock +3 -3
  2. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/Cargo.toml +1 -1
  3. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/PKG-INFO +1 -1
  4. data_flow_control-0.3.0/passant-core/src/catalog/constraint_subquery.rs +217 -0
  5. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/catalog.rs +10 -1
  6. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy.rs +19 -6
  7. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_store/compiled.rs +1 -0
  8. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/resolution_registry.rs +5 -0
  9. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/limit.rs +4 -2
  10. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/mod.rs +31 -6
  11. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/actions.rs +9 -5
  12. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/policy_expr.rs +5 -0
  13. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/resolution.rs +48 -30
  14. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/select.rs +1 -1
  15. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/write_path.rs +23 -8
  16. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/src/bindings/planner.rs +7 -0
  17. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/pyproject.toml +1 -1
  18. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/__init__.py +3 -1
  19. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/_rust.py +1 -1
  20. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/duckdb.py +39 -4
  21. data_flow_control-0.3.0/python/data_flow_control/adapters/duckdb_policy_binding.py +263 -0
  22. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/connection.py +94 -21
  23. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/errors.py +19 -1
  24. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/call_tool_with_dataflow.py +84 -49
  25. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/database.py +0 -1
  26. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/sql_validation.py +6 -0
  27. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/planner.py +7 -0
  28. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/policy.py +17 -0
  29. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/tools/retry.py +32 -20
  30. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/LICENSE +0 -0
  31. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/Cargo.toml +0 -0
  32. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/benches/rewrite_perf.rs +0 -0
  33. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/aggregate_registry.rs +0 -0
  34. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/catalog/dimension.rs +0 -0
  35. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/diagnostics.rs +0 -0
  36. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/explain.rs +0 -0
  37. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/full_push.rs +0 -0
  38. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/identifiers.rs +0 -0
  39. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/intern.rs +0 -0
  40. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/ir.rs +0 -0
  41. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/lib.rs +0 -0
  42. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/optimizer.rs +0 -0
  43. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/parser.rs +0 -0
  44. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/partial_push.rs +0 -0
  45. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/planner.rs +0 -0
  46. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_compile.rs +0 -0
  47. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_index.rs +0 -0
  48. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_parser.rs +0 -0
  49. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_pgn.pest +0 -0
  50. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_store/branch.rs +0 -0
  51. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_store/delete.rs +0 -0
  52. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_store/indexes.rs +0 -0
  53. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_store/memory.rs +0 -0
  54. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/policy_store/mod.rs +0 -0
  55. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/query_analysis.rs +0 -0
  56. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/resolution_placement.rs +0 -0
  57. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewrite_stats.rs +0 -0
  58. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewrite_strategy.rs +0 -0
  59. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/aggregates.rs +0 -0
  60. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/columns.rs +0 -0
  61. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/constraint_preprocess.rs +0 -0
  62. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/derived_policy.rs +0 -0
  63. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/dimensions.rs +0 -0
  64. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/exists.rs +0 -0
  65. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/expr.rs +0 -0
  66. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/helpers.rs +0 -0
  67. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/insert_output_policy.rs +0 -0
  68. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/grouped_projection.rs +0 -0
  69. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/terminal_distinct.rs +0 -0
  70. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/terminal_except.rs +0 -0
  71. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/terminal_intersect.rs +0 -0
  72. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage.rs +0 -0
  73. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/output_scope.rs +0 -0
  74. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/applicability.rs +0 -0
  75. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/dominance.rs +0 -0
  76. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/mod.rs +0 -0
  77. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/scope_plan.rs +0 -0
  78. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/write_plan.rs +0 -0
  79. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/projection.rs +0 -0
  80. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/scope.rs +0 -0
  81. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/sink_columns.rs +0 -0
  82. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/rewriter/types.rs +0 -0
  83. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/semiring.rs +0 -0
  84. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/source_set_index.rs +0 -0
  85. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/source_sets/analysis.rs +0 -0
  86. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/source_sets/annotations.rs +0 -0
  87. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/source_sets/branch.rs +0 -0
  88. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/source_sets/mod.rs +0 -0
  89. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/source_sets/rewrites.rs +0 -0
  90. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/source_sets/split.rs +0 -0
  91. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/ast_stats.rs +0 -0
  92. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/builders.rs +0 -0
  93. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/columns.rs +0 -0
  94. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/dialect.rs +0 -0
  95. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/expr.rs +0 -0
  96. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/expr_key.rs +0 -0
  97. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/mod.rs +0 -0
  98. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/parse.rs +0 -0
  99. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/sql/render.rs +0 -0
  100. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/statement_tables.rs +0 -0
  101. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/src/threshold.rs +0 -0
  102. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/common/duckdb.rs +0 -0
  103. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/common/mod.rs +0 -0
  104. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/conformance.rs +0 -0
  105. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/main.rs +0 -0
  106. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/partial_push.rs +0 -0
  107. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/pgn.rs +0 -0
  108. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/pgn_unique.rs +0 -0
  109. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/policy_storage.rs +0 -0
  110. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/rewrite_api_parity.rs +0 -0
  111. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/semiring.rs +0 -0
  112. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/source_sets.rs +0 -0
  113. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/symmetric_self_join.rs +0 -0
  114. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/threshold.rs +0 -0
  115. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/completion/unique_not_unique.rs +0 -0
  116. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/dialect.rs +0 -0
  117. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/execution/insert.rs +0 -0
  118. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/execution/kill.rs +0 -0
  119. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/execution/main.rs +0 -0
  120. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/execution/oracle.rs +0 -0
  121. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/execution/remove.rs +0 -0
  122. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/execution/update.rs +0 -0
  123. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/expected/duckdb/remove_scan.sql +0 -0
  124. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/expected/postgres/remove_scan.sql +0 -0
  125. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/expected/sqlite/remove_scan.sql +0 -0
  126. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/explain_strategy.rs +0 -0
  127. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/column_propagation.rs +0 -0
  128. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/dimensions.rs +0 -0
  129. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/exists_join.rs +0 -0
  130. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/having_where.rs +0 -0
  131. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/identifiers.rs +0 -0
  132. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/insert_shapes.rs +0 -0
  133. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/main.rs +0 -0
  134. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/multi_source.rs +0 -0
  135. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/operators.rs +0 -0
  136. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/query_shapes.rs +0 -0
  137. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/gaps/scalar_subquery.rs +0 -0
  138. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/indexed_candidate_differential.rs +0 -0
  139. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/insert_values_body.rs +0 -0
  140. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/kill_null_guard_regression.rs +0 -0
  141. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/paper_examples.rs +0 -0
  142. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/parser.rs +0 -0
  143. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/planner.rs +0 -0
  144. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/policy.rs +0 -0
  145. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/policy_dialect.rs +0 -0
  146. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/policy_store_memory.rs +0 -0
  147. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/derived_policy.rs +0 -0
  148. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/in_semijoin.rs +0 -0
  149. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/insert.rs +0 -0
  150. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/joins.rs +0 -0
  151. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/main.rs +0 -0
  152. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/meal_deduction.rs +0 -0
  153. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/output.rs +0 -0
  154. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/recursive.rs +0 -0
  155. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/scan.rs +0 -0
  156. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite/update.rs +0 -0
  157. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite_candidate_regression.rs +0 -0
  158. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite_fast_paths.rs +0 -0
  159. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite_large_registry.rs +0 -0
  160. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/rewrite_stats_timings.rs +0 -0
  161. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/scan_ready_expr.rs +0 -0
  162. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/source_set_split_no_parse.rs +0 -0
  163. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/sql_builders.rs +0 -0
  164. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/sql_columns.rs +0 -0
  165. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-core/tests/ui_resolution.rs +0 -0
  166. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/Cargo.toml +0 -0
  167. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/src/bindings/catalog.rs +0 -0
  168. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/src/bindings/errors.rs +0 -0
  169. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/src/bindings/mod.rs +0 -0
  170. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/src/bindings/policy.rs +0 -0
  171. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/src/bindings/stats.rs +0 -0
  172. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/passant-py/src/lib.rs +0 -0
  173. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/__init__.py +0 -0
  174. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/_retry.py +0 -0
  175. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/base.py +0 -0
  176. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/clickhouse.py +0 -0
  177. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/datafusion.py +0 -0
  178. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/kill.py +0 -0
  179. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/pg_catalog.py +0 -0
  180. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/postgres.py +0 -0
  181. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/registry.py +0 -0
  182. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/sqlite.py +0 -0
  183. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/adapters/umbra.py +0 -0
  184. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/aggregate_introspection.py +0 -0
  185. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/catalog.py +0 -0
  186. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/dialect.py +0 -0
  187. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/__init__.py +0 -0
  188. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/agent.py +0 -0
  189. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/middleware.py +0 -0
  190. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/schema.py +0 -0
  191. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/tool_spec.py +0 -0
  192. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/langchain/wrapper.py +0 -0
  193. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/options.py +0 -0
  194. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/tools/__init__.py +0 -0
  195. {data_flow_control-0.2.3 → data_flow_control-0.3.0}/python/data_flow_control/ui.py +0 -0
@@ -1593,7 +1593,7 @@ dependencies = [
1593
1593
 
1594
1594
  [[package]]
1595
1595
  name = "passant-cli"
1596
- version = "0.2.3"
1596
+ version = "0.3.0"
1597
1597
  dependencies = [
1598
1598
  "anyhow",
1599
1599
  "assert_cmd",
@@ -1605,7 +1605,7 @@ dependencies = [
1605
1605
 
1606
1606
  [[package]]
1607
1607
  name = "passant-core"
1608
- version = "0.2.3"
1608
+ version = "0.3.0"
1609
1609
  dependencies = [
1610
1610
  "anyhow",
1611
1611
  "criterion",
@@ -1623,7 +1623,7 @@ dependencies = [
1623
1623
 
1624
1624
  [[package]]
1625
1625
  name = "passant-py"
1626
- version = "0.2.3"
1626
+ version = "0.3.0"
1627
1627
  dependencies = [
1628
1628
  "passant-core",
1629
1629
  "pyo3",
@@ -3,7 +3,7 @@ members = ["passant-core", "passant-py"]
3
3
  resolver = "2"
4
4
 
5
5
  [workspace.package]
6
- version = "0.2.3"
6
+ version = "0.3.0"
7
7
  edition = "2024"
8
8
  license = "MIT"
9
9
  authors = ["Charlie Summers"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: data-flow-control
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Requires-Dist: duckdb>=1.3.0
5
5
  Requires-Dist: numpy>=1.24.4
6
6
  Requires-Dist: sqlglot==28.3.0
@@ -0,0 +1,217 @@
1
+ //! Registration-time physical relation checks for SQL subqueries in CONSTRAINT.
2
+
3
+ use std::{collections::HashSet, ops::ControlFlow, ptr};
4
+
5
+ use sqlparser::ast::{Expr, ObjectName, Query, TableFactor, Visit, Visitor};
6
+
7
+ use super::TableCatalog;
8
+ use crate::{
9
+ diagnostics::{ErrorKind, RewriteError},
10
+ identifiers::TableKey,
11
+ };
12
+
13
+ #[derive(Default)]
14
+ struct QueryScope {
15
+ visible_ctes: HashSet<TableKey>,
16
+ // A nonrecursive WITH item enters scope only after its defining query.
17
+ pending_ctes: Vec<(*const Query, TableKey)>,
18
+ }
19
+
20
+ pub(super) fn validate(
21
+ catalog: &TableCatalog,
22
+ expr: &Expr,
23
+ constraint: &str,
24
+ ) -> Result<(), RewriteError> {
25
+ struct Relations<'a> {
26
+ catalog: &'a TableCatalog,
27
+ constraint: &'a str,
28
+ queries: Vec<QueryScope>,
29
+ }
30
+
31
+ impl Visitor for Relations<'_> {
32
+ type Break = RewriteError;
33
+
34
+ fn pre_visit_query(&mut self, query: &Query) -> ControlFlow<Self::Break> {
35
+ let mut scope = QueryScope::default();
36
+ if let Some(with) = &query.with {
37
+ for cte in &with.cte_tables {
38
+ let name = TableKey::new(&cte.alias.name.to_string());
39
+ if with.recursive {
40
+ scope.visible_ctes.insert(name);
41
+ } else {
42
+ scope
43
+ .pending_ctes
44
+ .push((ptr::from_ref(cte.query.as_ref()), name));
45
+ }
46
+ }
47
+ }
48
+ self.queries.push(scope);
49
+ ControlFlow::Continue(())
50
+ }
51
+
52
+ fn post_visit_query(&mut self, query: &Query) -> ControlFlow<Self::Break> {
53
+ self.queries.pop();
54
+ if let Some(parent) = self.queries.last_mut()
55
+ && let Some((_, name)) = parent
56
+ .pending_ctes
57
+ .iter()
58
+ .find(|(definition, _)| ptr::eq(*definition, query))
59
+ {
60
+ parent.visible_ctes.insert(name.clone());
61
+ }
62
+ ControlFlow::Continue(())
63
+ }
64
+
65
+ fn pre_visit_table_factor(&mut self, factor: &TableFactor) -> ControlFlow<Self::Break> {
66
+ // Derived tables, aliases and table functions are not physical
67
+ // catalog entries. The visitor still traverses their children.
68
+ let TableFactor::Table {
69
+ name, args: None, ..
70
+ } = factor
71
+ else {
72
+ return ControlFlow::Continue(());
73
+ };
74
+ let name_str = name.to_string();
75
+ let key = TableKey::new(&name_str);
76
+ let is_cte = name.0.len() == 1
77
+ && self
78
+ .queries
79
+ .iter()
80
+ .rev()
81
+ .any(|scope| scope.visible_ctes.contains(&key));
82
+ if self.queries.is_empty() || is_cte || table_exists(self.catalog, name, &name_str) {
83
+ return ControlFlow::Continue(());
84
+ }
85
+ ControlFlow::Break(RewriteError::catalog_with_context(
86
+ ErrorKind::UnknownTable,
87
+ format!(
88
+ "CONSTRAINT subquery table '{name_str}' does not exist in the explicit catalog"
89
+ ),
90
+ Some(name_str),
91
+ None,
92
+ Some(self.constraint.to_string()),
93
+ Some("catalog_validation"),
94
+ ))
95
+ }
96
+ }
97
+
98
+ match expr.visit(&mut Relations {
99
+ catalog,
100
+ constraint,
101
+ queries: Vec::new(),
102
+ }) {
103
+ ControlFlow::Continue(()) => Ok(()),
104
+ ControlFlow::Break(err) => Err(err),
105
+ }
106
+ }
107
+
108
+ // The catalog may store default-schema tables without their schema prefix.
109
+ fn table_exists(catalog: &TableCatalog, name: &ObjectName, display: &str) -> bool {
110
+ if catalog.table_exists(display) {
111
+ return true;
112
+ }
113
+ match name.0.as_slice() {
114
+ [_] => catalog
115
+ .search_path
116
+ .iter()
117
+ .any(|schema| catalog.table_exists(&format!("{schema}.{display}"))),
118
+ [schema, table] => {
119
+ let schema = TableKey::new(&schema.to_string());
120
+ catalog.default_schema.as_ref() == Some(&schema)
121
+ && catalog.table_exists(&table.to_string())
122
+ }
123
+ _ => false,
124
+ }
125
+ }
126
+
127
+ #[cfg(test)]
128
+ mod tests {
129
+ use super::*;
130
+ use crate::{catalog::CatalogSnapshot, rewriter::PassantRewriter};
131
+
132
+ fn register(constraint: &str) -> Result<(), RewriteError> {
133
+ let mut catalog = TableCatalog::from_snapshot(CatalogSnapshot {
134
+ default_schema: Some("main".into()),
135
+ search_path: vec!["tenant".into(), "main".into()],
136
+ ..CatalogSnapshot::default()
137
+ });
138
+ catalog.register_table("target", vec!["id".into()]);
139
+ catalog.register_table("lookup_correct", vec!["id".into()]);
140
+ catalog.register_table("extra_lookup", vec!["id".into()]);
141
+ catalog.register_table("tenant.path_lookup", vec!["id".into()]);
142
+ let mut rewriter = PassantRewriter::with_catalog(catalog);
143
+ rewriter.register_policy_text(&format!(
144
+ "SINK target AS t DIMENSION lookup_correct AS d CONSTRAINT {constraint} ON FAIL RETRY('blocked')"
145
+ ))
146
+ }
147
+
148
+ #[test]
149
+ fn rejects_missing_subquery_relations_with_a_valid_dimension() {
150
+ let cases = [
151
+ (
152
+ "EXISTS (SELECT 1 FROM lookup_typo AS d WHERE d.id = t.id)",
153
+ "lookup_typo",
154
+ ),
155
+ (
156
+ "(SELECT MAX(x.id) FROM lookup_typo AS x) > 0",
157
+ "lookup_typo",
158
+ ),
159
+ ("t.id IN (SELECT x.id FROM lookup_typo AS x)", "lookup_typo"),
160
+ (
161
+ "EXISTS (SELECT 1 FROM lookup_correct AS x WHERE EXISTS (SELECT 1 FROM lookup_typo AS x))",
162
+ "lookup_typo",
163
+ ),
164
+ (
165
+ "EXISTS (WITH x AS (SELECT id FROM lookup_typo) SELECT 1 FROM x)",
166
+ "lookup_typo",
167
+ ),
168
+ (
169
+ "EXISTS (WITH x AS (SELECT id FROM later), later AS (SELECT 1 AS id) SELECT 1 FROM x)",
170
+ "later",
171
+ ),
172
+ (
173
+ "EXISTS (WITH x AS (SELECT 1) SELECT 1 FROM missing_schema.x)",
174
+ "missing_schema.x",
175
+ ),
176
+ (
177
+ "EXISTS (SELECT 1 FROM missing_schema.lookup_correct)",
178
+ "missing_schema.lookup_correct",
179
+ ),
180
+ (
181
+ "EXISTS (SELECT 1 FROM (WITH x AS (SELECT 1) SELECT 1 FROM x) AS q JOIN x ON TRUE)",
182
+ "x",
183
+ ),
184
+ ];
185
+ for (constraint, table) in cases {
186
+ let error = register(constraint).expect_err(constraint);
187
+ assert_eq!(error.kind(), ErrorKind::UnknownTable, "{constraint}");
188
+ let RewriteError::Catalog(details) = error else {
189
+ panic!("expected catalog diagnostic");
190
+ };
191
+ assert_eq!(details.table.as_deref(), Some(table), "{constraint}");
192
+ assert_eq!(details.constraint.as_deref(), Some(constraint));
193
+ assert_eq!(
194
+ details.validation_phase.as_deref(),
195
+ Some("catalog_validation")
196
+ );
197
+ }
198
+ }
199
+
200
+ #[test]
201
+ fn accepts_physical_relations_ctes_and_correlated_aliases() {
202
+ let cases = [
203
+ "EXISTS (SELECT 1 FROM lookup_correct AS d WHERE d.id = t.id)",
204
+ "EXISTS (SELECT 1 FROM extra_lookup AS t WHERE t.id = 9)",
205
+ "EXISTS (SELECT 1 FROM main.lookup_correct AS d WHERE d.id = t.id)",
206
+ "EXISTS (SELECT 1 FROM path_lookup AS p WHERE p.id = t.id)",
207
+ "EXISTS (SELECT 1 FROM unnest([t.id]) AS t(id) WHERE t.id = 1)",
208
+ "EXISTS (SELECT 1 FROM (SELECT t.id AS id) AS t WHERE t.id = 1)",
209
+ "EXISTS (WITH x AS (SELECT id FROM lookup_correct), y AS (SELECT id FROM x) SELECT 1 FROM y WHERE EXISTS (SELECT 1 FROM x WHERE x.id = t.id))",
210
+ "EXISTS (WITH RECURSIVE x(id) AS (SELECT 1 UNION ALL SELECT x.id + 1 FROM x WHERE x.id < 2) SELECT 1 FROM x)",
211
+ "(SELECT t.id) > 0",
212
+ ];
213
+ for constraint in cases {
214
+ register(constraint).unwrap_or_else(|error| panic!("{constraint}: {error}"));
215
+ }
216
+ }
217
+ }
@@ -16,6 +16,7 @@ use crate::policy::{PolicyIr, Resolution};
16
16
  use crate::policy_compile::{
17
17
  ParsedPolicyConstraint, parse_policy_constraint, parse_policy_constraint_with_registry,
18
18
  };
19
+ mod constraint_subquery;
19
20
  mod dimension;
20
21
 
21
22
  /// Catalog facts supplied at policy registration time (from any adapter snapshot).
@@ -25,6 +26,8 @@ pub struct TableCatalog {
25
26
  column_types: HashMap<(TableKey, String), String>,
26
27
  unique_columns: HashSet<(TableKey, String)>,
27
28
  table_row_counts: HashMap<TableKey, u64>,
29
+ default_schema: Option<TableKey>,
30
+ search_path: Vec<String>,
28
31
  loaded: bool,
29
32
  }
30
33
 
@@ -70,7 +73,11 @@ impl TableCatalog {
70
73
  }
71
74
 
72
75
  pub fn from_snapshot(snapshot: CatalogSnapshot) -> Self {
73
- let mut catalog = Self::new();
76
+ let mut catalog = Self {
77
+ default_schema: snapshot.default_schema.as_deref().map(TableKey::new),
78
+ search_path: snapshot.search_path,
79
+ ..Self::default()
80
+ };
74
81
  for (table, info) in snapshot.tables {
75
82
  catalog.register_table(table.clone(), info.columns.clone());
76
83
  for (column, sql_type) in info.types {
@@ -401,6 +408,8 @@ fn validate_pgn_policy_parsed(
401
408
  dimension_columns.insert(TableKey::new(alias), columns);
402
409
  }
403
410
 
411
+ constraint_subquery::validate(catalog, expr, &constraint)?;
412
+
404
413
  let source_names = sources
405
414
  .iter()
406
415
  .map(|source| TableKey::new(source))
@@ -10,6 +10,7 @@ pub enum Resolution {
10
10
  Remove,
11
11
  Kill,
12
12
  Retry(String),
13
+ Notify(String),
13
14
  Udf(String),
14
15
  RelationUdf(String),
15
16
  Ui,
@@ -25,8 +26,9 @@ impl Resolution {
25
26
  if upper == "KILL" {
26
27
  return Ok(Self::Kill);
27
28
  }
28
- if upper.starts_with("RETRY") {
29
- let rest = trimmed[5..].trim();
29
+ if upper.starts_with("RETRY") || upper.starts_with("NOTIFY") {
30
+ let notify = upper.starts_with("NOTIFY");
31
+ let rest = trimmed[if notify { 6 } else { 5 }..].trim();
30
32
  let literal = rest
31
33
  .strip_prefix('(')
32
34
  .and_then(|s| s.strip_suffix(')'))
@@ -44,7 +46,11 @@ impl Resolution {
44
46
  }
45
47
  message.push(ch);
46
48
  }
47
- return Ok(Self::Retry(message));
49
+ return Ok(if notify {
50
+ Self::Notify(message)
51
+ } else {
52
+ Self::Retry(message)
53
+ });
48
54
  }
49
55
  if upper == "UI" {
50
56
  return Ok(Self::Ui);
@@ -77,6 +83,7 @@ impl Resolution {
77
83
  Self::Remove => "REMOVE".to_string(),
78
84
  Self::Kill => "KILL".to_string(),
79
85
  Self::Retry(message) => format!("RETRY('{}')", message.replace('\'', "''")),
86
+ Self::Notify(message) => format!("NOTIFY('{}')", message.replace('\'', "''")),
80
87
  Self::Udf(name) => format!("UDF {name}"),
81
88
  Self::RelationUdf(name) => format!("RELATION UDF {name}"),
82
89
  Self::Ui => "UI".to_string(),
@@ -84,7 +91,10 @@ impl Resolution {
84
91
  }
85
92
 
86
93
  pub fn is_tuple_resolution(&self) -> bool {
87
- matches!(self, Self::Kill | Self::Retry(_) | Self::Udf(_))
94
+ matches!(
95
+ self,
96
+ Self::Kill | Self::Retry(_) | Self::Notify(_) | Self::Udf(_)
97
+ )
88
98
  }
89
99
 
90
100
  pub fn is_relation_resolution(&self) -> bool {
@@ -297,7 +307,10 @@ pub fn parse_policy_text(text: &str) -> Result<PolicyIr, PolicyParseError> {
297
307
  queries: HashMap::new(),
298
308
  });
299
309
  let constraint = raw.constraint;
300
- let resolution = raw.on_fail;
310
+ let resolution = Resolution::parse(&raw.on_fail)?;
311
+ if matches!(resolution, Resolution::Notify(_)) && sink.is_none() {
312
+ return Err(PolicyParseError::MissingClause("SINK for NOTIFY"));
313
+ }
301
314
  let description = raw.description.and_then(blank_to_none);
302
315
 
303
316
  let parsed_sources = parse_sources(&sources)?;
@@ -314,7 +327,7 @@ pub fn parse_policy_text(text: &str) -> Result<PolicyIr, PolicyParseError> {
314
327
  sink_alias,
315
328
  source_aliases: parsed_sources.aliases,
316
329
  constraint,
317
- on_fail: Resolution::parse(&resolution)?,
330
+ on_fail: resolution,
318
331
  description,
319
332
  })
320
333
  }
@@ -57,6 +57,7 @@ pub(crate) fn is_enforcement_resolution(resolution: Resolution) -> bool {
57
57
  Resolution::Remove
58
58
  | Resolution::Kill
59
59
  | Resolution::Retry(_)
60
+ | Resolution::Notify(_)
60
61
  | Resolution::Udf(_)
61
62
  | Resolution::RelationUdf(_)
62
63
  | Resolution::Ui
@@ -8,6 +8,7 @@ pub enum ResolutionPrecedence {
8
8
  Kill,
9
9
  Remove,
10
10
  Retry,
11
+ Notify,
11
12
  Udf,
12
13
  }
13
14
 
@@ -71,6 +72,10 @@ impl ResolutionRegistry {
71
72
  splittable: false,
72
73
  precedence: Some(P::Retry),
73
74
  },
75
+ Resolution::Notify(_) => ResolutionProperties {
76
+ splittable: false,
77
+ precedence: Some(P::Notify),
78
+ },
74
79
  Resolution::Udf(name) | Resolution::RelationUdf(name) => ResolutionProperties {
75
80
  splittable: self
76
81
  .definitions
@@ -276,10 +276,11 @@ fn rewrite_action_filter_for_outer(
276
276
  propagated: &mut HashMap<String, (Expr, String)>,
277
277
  ) -> PolicyResolutionAction {
278
278
  match action {
279
- PolicyResolutionAction::Retry {
279
+ PolicyResolutionAction::Message {
280
280
  filter,
281
281
  policy_index,
282
- } => PolicyResolutionAction::Retry {
282
+ notify,
283
+ } => PolicyResolutionAction::Message {
283
284
  filter: rewrite_filter_for_outer(
284
285
  filter,
285
286
  projected_names,
@@ -288,6 +289,7 @@ fn rewrite_action_filter_for_outer(
288
289
  propagated,
289
290
  ),
290
291
  policy_index,
292
+ notify,
291
293
  },
292
294
  PolicyResolutionAction::Filter {
293
295
  filter,
@@ -150,16 +150,41 @@ impl PassantRewriter {
150
150
  self.register_policy(policy)
151
151
  }
152
152
 
153
+ fn validate_registration(
154
+ &self,
155
+ policy: &PolicyIr,
156
+ ) -> Result<crate::policy_compile::ParsedPolicyConstraint, RewriteError> {
157
+ let parsed = crate::policy_compile::parse_policy_constraint_with_registry(
158
+ policy.constraint(),
159
+ &self.aggregate_registry,
160
+ )?;
161
+ self.catalog
162
+ .validate_pgn_policy_parsed(policy, &parsed, &self.aggregate_registry)?;
163
+ Ok(parsed)
164
+ }
165
+
166
+ /// Check a batch without adding policies; return constraint SQL and top-level aggregate flags.
167
+ pub fn registration_binding_inputs(
168
+ &self,
169
+ policies: &[PolicyIr],
170
+ ) -> Result<Vec<(String, bool)>, RewriteError> {
171
+ policies
172
+ .iter()
173
+ .map(|policy| {
174
+ let parsed = self.validate_registration(policy)?;
175
+ let aggregate = self
176
+ .aggregate_registry
177
+ .expr_contains_aggregate(&parsed.expr);
178
+ Ok((parsed.sql, aggregate))
179
+ })
180
+ .collect()
181
+ }
182
+
153
183
  /// Validate the entire batch before allocating stable policy identities.
154
184
  pub fn register_policies(&mut self, policies: Vec<PolicyIr>) -> Result<(), RewriteError> {
155
185
  let mut validated = Vec::with_capacity(policies.len());
156
186
  for policy in policies {
157
- let parsed = crate::policy_compile::parse_policy_constraint_with_registry(
158
- policy.constraint(),
159
- &self.aggregate_registry,
160
- )?;
161
- self.catalog
162
- .validate_pgn_policy_parsed(&policy, &parsed, &self.aggregate_registry)?;
187
+ let parsed = self.validate_registration(&policy)?;
163
188
  validated.push((policy, parsed));
164
189
  }
165
190
  let registry = self.aggregate_registry.clone();
@@ -29,9 +29,10 @@ use super::applicability::{ScopePlanDiagnostics, resolve_scope_policies};
29
29
  #[derive(Debug, Clone)]
30
30
  #[allow(clippy::large_enum_variant)]
31
31
  pub(crate) enum PolicyResolutionAction {
32
- Retry {
32
+ Message {
33
33
  filter: Expr,
34
34
  policy_index: usize,
35
+ notify: bool,
35
36
  },
36
37
  Filter {
37
38
  filter: Expr,
@@ -65,9 +66,10 @@ pub(crate) fn action_for_resolution(
65
66
  policy_index: usize,
66
67
  ) -> Result<PolicyResolutionAction, crate::diagnostics::RewriteError> {
67
68
  match on_fail {
68
- Resolution::Retry(_) => Ok(PolicyResolutionAction::Retry {
69
+ Resolution::Retry(_) | Resolution::Notify(_) => Ok(PolicyResolutionAction::Message {
69
70
  filter,
70
71
  policy_index,
72
+ notify: matches!(on_fail, Resolution::Notify(_)),
71
73
  }),
72
74
  Resolution::Remove => Ok(PolicyResolutionAction::Filter {
73
75
  filter,
@@ -202,7 +204,7 @@ pub(crate) fn build_policy_resolution_actions(
202
204
  expr = and_expr(guard, expr);
203
205
  }
204
206
  let mut action = action_for_resolution(expr, on_fail, description.clone(), policy, index)?;
205
- if let PolicyResolutionAction::Retry { policy_index, .. } = &mut action {
207
+ if let PolicyResolutionAction::Message { policy_index, .. } = &mut action {
206
208
  *policy_index = store.original_policy_index(index).unwrap_or(index);
207
209
  }
208
210
  actions.push(action);
@@ -275,7 +277,7 @@ pub(crate) fn apply_policy_resolution_actions(
275
277
  {
276
278
  1
277
279
  }
278
- PolicyResolutionAction::Retry { .. } => 2,
280
+ PolicyResolutionAction::Message { .. } => 2,
279
281
  PolicyResolutionAction::TupleUdf { .. } => 3,
280
282
  PolicyResolutionAction::RelationUdf { .. } => 4,
281
283
  PolicyResolutionAction::Ui { .. } => 5,
@@ -295,7 +297,9 @@ pub(crate) fn apply_policy_resolution_actions(
295
297
 
296
298
  for action in actions {
297
299
  match action {
298
- PolicyResolutionAction::Retry { .. } => unreachable!("retry routed to joint stage"),
300
+ PolicyResolutionAction::Message { .. } => {
301
+ unreachable!("message resolution routed to joint stage")
302
+ }
299
303
  PolicyResolutionAction::Filter { filter, .. } => {
300
304
  add_filter(select, filter.clone(), is_aggregation)?;
301
305
  }
@@ -921,6 +921,11 @@ pub(crate) fn apply_update_resolution(
921
921
  ui_followup: &crate::rewriter::types::UiFollowupCell,
922
922
  ) -> Result<(), RewriteError> {
923
923
  match on_fail {
924
+ Resolution::Notify(_) => {
925
+ return Err(RewriteError::unsupported_statement(
926
+ "native NOTIFY requires DuckDB INSERT SELECT",
927
+ ));
928
+ }
924
929
  Resolution::Retry(_) => {
925
930
  return Err(RewriteError::unsupported_statement(
926
931
  "RETRY resolution on UPDATE requires a statement-wide resolution stage and is not supported yet",
@@ -189,9 +189,10 @@ fn wrap_select_with_retry(
189
189
  let actions = policies
190
190
  .into_iter()
191
191
  .map(
192
- |(policy_index, filter)| super::plan::PolicyResolutionAction::Retry {
192
+ |(policy_index, filter)| super::plan::PolicyResolutionAction::Message {
193
193
  policy_index,
194
194
  filter,
195
+ notify: false,
195
196
  },
196
197
  )
197
198
  .collect::<Vec<_>>();
@@ -246,7 +247,7 @@ pub(crate) fn wrap_select_with_resolution_stages(
246
247
  A::Filter { filter, .. }
247
248
  | A::TupleUdf { filter, .. }
248
249
  | A::RelationUdf { filter, .. }
249
- | A::Retry { filter, .. }
250
+ | A::Message { filter, .. }
250
251
  | A::Ui { filter, .. } => filter,
251
252
  };
252
253
  sql.push(' ');
@@ -270,6 +271,7 @@ pub(crate) fn wrap_select_with_resolution_stages(
270
271
  let mut kill = Vec::new();
271
272
  let mut remove = Vec::new();
272
273
  let mut retries = std::collections::BTreeMap::<usize, Vec<String>>::new();
274
+ let mut notices = std::collections::BTreeMap::<usize, Vec<String>>::new();
273
275
  let mut udfs: Vec<(bool, String, Vec<String>)> = Vec::new();
274
276
  for action in actions {
275
277
  let (filter, kind) = match action {
@@ -277,7 +279,7 @@ pub(crate) fn wrap_select_with_resolution_stages(
277
279
  A::TupleUdf {
278
280
  filter, udf_name, ..
279
281
  } if udf_name.eq_ignore_ascii_case(PASSANT_KILL_UDF) => (filter, 1),
280
- A::Retry { filter, .. } => (filter, 2),
282
+ A::Message { filter, .. } => (filter, 2),
281
283
  A::TupleUdf { filter, .. } => (filter, 3),
282
284
  A::RelationUdf { filter, .. } => (filter, 4),
283
285
  A::Ui { .. } => {
@@ -292,8 +294,14 @@ pub(crate) fn wrap_select_with_resolution_stages(
292
294
  0 => remove.push(pass),
293
295
  1 => kill.push(pass),
294
296
  2 => {
295
- if let A::Retry { policy_index, .. } = action {
296
- retries.entry(*policy_index).or_default().push(pass);
297
+ if let A::Message {
298
+ policy_index,
299
+ notify,
300
+ ..
301
+ } = action
302
+ {
303
+ let messages = if *notify { &mut notices } else { &mut retries };
304
+ messages.entry(*policy_index).or_default().push(pass);
297
305
  }
298
306
  }
299
307
  _ => {
@@ -345,43 +353,53 @@ pub(crate) fn wrap_select_with_resolution_stages(
345
353
  .chain(&remove)
346
354
  .map(|name| Expr::IsTrue(Box::new(col(name))))
347
355
  .collect());
348
- let retry_parts = retries
349
- .iter()
350
- .map(|(index, columns)| {
351
- let pass = all(columns.iter().map(|name| col(name)).collect());
356
+ let message_guard = |policies: &std::collections::BTreeMap<usize, Vec<String>>,
357
+ function: &str| {
358
+ let parts = policies
359
+ .iter()
360
+ .map(|(index, columns)| {
361
+ let pass = all(columns.iter().map(|name| col(name)).collect());
362
+ case_when(
363
+ any(and_expr(
364
+ survivors.clone(),
365
+ Expr::IsNotTrue(Box::new(Expr::Nested(Box::new(pass)))),
366
+ )),
367
+ string_literal(&index.to_string()),
368
+ null_literal(),
369
+ )
370
+ })
371
+ .collect::<Vec<_>>();
372
+ let mut concat_args = vec![string_literal(",")];
373
+ concat_args.extend(parts);
374
+ let payload = function_call("concat_ws", concat_args);
375
+ if policies.is_empty() {
376
+ bool_literal(true)
377
+ } else {
352
378
  case_when(
353
- any(and_expr(
354
- survivors.clone(),
355
- Expr::IsNotTrue(Box::new(Expr::Nested(Box::new(pass)))),
356
- )),
357
- string_literal(&index.to_string()),
358
- null_literal(),
379
+ binary_comparison(payload.clone(), BinaryOperator::NotEq, string_literal("")),
380
+ function_call(function, vec![payload]),
381
+ bool_literal(true),
359
382
  )
360
- })
361
- .collect::<Vec<_>>();
362
- let mut concat_args = vec![string_literal(",")];
363
- concat_args.extend(retry_parts);
364
- let payload = function_call("concat_ws", concat_args);
365
- let retry_guard = if retries.is_empty() {
366
- bool_literal(true)
383
+ }
384
+ };
385
+ let retry_guard = message_guard(&retries, "passant_retry_many");
386
+ let notice_guard = message_guard(&notices, "passant_notify_many");
387
+ let retry_then_notice = if notices.is_empty() {
388
+ retry_guard
367
389
  } else {
368
- case_when(
369
- binary_comparison(payload.clone(), BinaryOperator::NotEq, string_literal("")),
370
- function_call("passant_retry_many", vec![payload]),
371
- bool_literal(true),
372
- )
390
+ case_when(retry_guard, notice_guard, bool_literal(false))
373
391
  };
374
- let guard = if kill.is_empty() && retries.is_empty() {
392
+ let guard = if kill.is_empty() && retries.is_empty() && notices.is_empty() {
375
393
  bool_literal(true)
376
394
  } else {
377
395
  let aggregate = if kill.is_empty() {
378
- retry_guard
396
+ retry_then_notice
379
397
  } else {
380
398
  let pass = all(kill.iter().map(|name| col(name)).collect());
381
399
  case_when(
382
400
  any(not(pass)),
383
401
  function_call(PASSANT_KILL_UDF, vec![]),
384
- retry_guard,
402
+ retry_then_notice,
385
403
  )
386
404
  };
387
405
  scalar_subquery(aggregate, &input)