data-flow-control 0.2.4__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.4 → data_flow_control-0.3.0}/Cargo.lock +3 -3
  2. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/Cargo.toml +1 -1
  3. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/PKG-INFO +1 -1
  4. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy.rs +19 -6
  5. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_store/compiled.rs +1 -0
  6. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/resolution_registry.rs +5 -0
  7. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/limit.rs +4 -2
  8. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/actions.rs +9 -5
  9. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/policy_expr.rs +5 -0
  10. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/resolution.rs +48 -30
  11. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/select.rs +1 -1
  12. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/write_path.rs +23 -8
  13. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/pyproject.toml +1 -1
  14. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/__init__.py +3 -1
  15. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/_rust.py +1 -1
  16. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/duckdb.py +39 -4
  17. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/connection.py +59 -18
  18. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/errors.py +19 -1
  19. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/call_tool_with_dataflow.py +84 -49
  20. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/database.py +0 -1
  21. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/sql_validation.py +6 -0
  22. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/planner.py +3 -0
  23. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/policy.py +17 -0
  24. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/tools/retry.py +32 -20
  25. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/LICENSE +0 -0
  26. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/Cargo.toml +0 -0
  27. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/benches/rewrite_perf.rs +0 -0
  28. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/aggregate_registry.rs +0 -0
  29. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/catalog/constraint_subquery.rs +0 -0
  30. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/catalog/dimension.rs +0 -0
  31. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/catalog.rs +0 -0
  32. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/diagnostics.rs +0 -0
  33. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/explain.rs +0 -0
  34. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/full_push.rs +0 -0
  35. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/identifiers.rs +0 -0
  36. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/intern.rs +0 -0
  37. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/ir.rs +0 -0
  38. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/lib.rs +0 -0
  39. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/optimizer.rs +0 -0
  40. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/parser.rs +0 -0
  41. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/partial_push.rs +0 -0
  42. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/planner.rs +0 -0
  43. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_compile.rs +0 -0
  44. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_index.rs +0 -0
  45. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_parser.rs +0 -0
  46. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_pgn.pest +0 -0
  47. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_store/branch.rs +0 -0
  48. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_store/delete.rs +0 -0
  49. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_store/indexes.rs +0 -0
  50. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_store/memory.rs +0 -0
  51. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/policy_store/mod.rs +0 -0
  52. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/query_analysis.rs +0 -0
  53. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/resolution_placement.rs +0 -0
  54. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewrite_stats.rs +0 -0
  55. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewrite_strategy.rs +0 -0
  56. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/aggregates.rs +0 -0
  57. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/columns.rs +0 -0
  58. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/constraint_preprocess.rs +0 -0
  59. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/derived_policy.rs +0 -0
  60. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/dimensions.rs +0 -0
  61. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/exists.rs +0 -0
  62. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/expr.rs +0 -0
  63. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/helpers.rs +0 -0
  64. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/insert_output_policy.rs +0 -0
  65. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/grouped_projection.rs +0 -0
  66. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/terminal_distinct.rs +0 -0
  67. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/terminal_except.rs +0 -0
  68. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage/terminal_intersect.rs +0 -0
  69. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/joint_lineage.rs +0 -0
  70. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/mod.rs +0 -0
  71. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/output_scope.rs +0 -0
  72. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/applicability.rs +0 -0
  73. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/dominance.rs +0 -0
  74. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/mod.rs +0 -0
  75. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/scope_plan.rs +0 -0
  76. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/plan/write_plan.rs +0 -0
  77. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/projection.rs +0 -0
  78. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/scope.rs +0 -0
  79. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/sink_columns.rs +0 -0
  80. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/rewriter/types.rs +0 -0
  81. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/semiring.rs +0 -0
  82. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/source_set_index.rs +0 -0
  83. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/source_sets/analysis.rs +0 -0
  84. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/source_sets/annotations.rs +0 -0
  85. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/source_sets/branch.rs +0 -0
  86. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/source_sets/mod.rs +0 -0
  87. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/source_sets/rewrites.rs +0 -0
  88. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/source_sets/split.rs +0 -0
  89. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/ast_stats.rs +0 -0
  90. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/builders.rs +0 -0
  91. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/columns.rs +0 -0
  92. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/dialect.rs +0 -0
  93. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/expr.rs +0 -0
  94. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/expr_key.rs +0 -0
  95. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/mod.rs +0 -0
  96. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/parse.rs +0 -0
  97. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/sql/render.rs +0 -0
  98. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/statement_tables.rs +0 -0
  99. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/src/threshold.rs +0 -0
  100. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/common/duckdb.rs +0 -0
  101. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/common/mod.rs +0 -0
  102. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/conformance.rs +0 -0
  103. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/main.rs +0 -0
  104. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/partial_push.rs +0 -0
  105. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/pgn.rs +0 -0
  106. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/pgn_unique.rs +0 -0
  107. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/policy_storage.rs +0 -0
  108. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/rewrite_api_parity.rs +0 -0
  109. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/semiring.rs +0 -0
  110. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/source_sets.rs +0 -0
  111. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/symmetric_self_join.rs +0 -0
  112. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/threshold.rs +0 -0
  113. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/completion/unique_not_unique.rs +0 -0
  114. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/dialect.rs +0 -0
  115. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/execution/insert.rs +0 -0
  116. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/execution/kill.rs +0 -0
  117. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/execution/main.rs +0 -0
  118. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/execution/oracle.rs +0 -0
  119. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/execution/remove.rs +0 -0
  120. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/execution/update.rs +0 -0
  121. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/expected/duckdb/remove_scan.sql +0 -0
  122. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/expected/postgres/remove_scan.sql +0 -0
  123. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/expected/sqlite/remove_scan.sql +0 -0
  124. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/explain_strategy.rs +0 -0
  125. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/column_propagation.rs +0 -0
  126. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/dimensions.rs +0 -0
  127. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/exists_join.rs +0 -0
  128. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/having_where.rs +0 -0
  129. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/identifiers.rs +0 -0
  130. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/insert_shapes.rs +0 -0
  131. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/main.rs +0 -0
  132. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/multi_source.rs +0 -0
  133. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/operators.rs +0 -0
  134. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/query_shapes.rs +0 -0
  135. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/gaps/scalar_subquery.rs +0 -0
  136. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/indexed_candidate_differential.rs +0 -0
  137. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/insert_values_body.rs +0 -0
  138. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/kill_null_guard_regression.rs +0 -0
  139. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/paper_examples.rs +0 -0
  140. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/parser.rs +0 -0
  141. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/planner.rs +0 -0
  142. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/policy.rs +0 -0
  143. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/policy_dialect.rs +0 -0
  144. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/policy_store_memory.rs +0 -0
  145. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/derived_policy.rs +0 -0
  146. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/in_semijoin.rs +0 -0
  147. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/insert.rs +0 -0
  148. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/joins.rs +0 -0
  149. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/main.rs +0 -0
  150. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/meal_deduction.rs +0 -0
  151. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/output.rs +0 -0
  152. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/recursive.rs +0 -0
  153. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/scan.rs +0 -0
  154. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite/update.rs +0 -0
  155. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite_candidate_regression.rs +0 -0
  156. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite_fast_paths.rs +0 -0
  157. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite_large_registry.rs +0 -0
  158. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/rewrite_stats_timings.rs +0 -0
  159. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/scan_ready_expr.rs +0 -0
  160. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/source_set_split_no_parse.rs +0 -0
  161. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/sql_builders.rs +0 -0
  162. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/sql_columns.rs +0 -0
  163. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-core/tests/ui_resolution.rs +0 -0
  164. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/Cargo.toml +0 -0
  165. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/src/bindings/catalog.rs +0 -0
  166. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/src/bindings/errors.rs +0 -0
  167. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/src/bindings/mod.rs +0 -0
  168. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/src/bindings/planner.rs +0 -0
  169. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/src/bindings/policy.rs +0 -0
  170. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/src/bindings/stats.rs +0 -0
  171. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/passant-py/src/lib.rs +0 -0
  172. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/__init__.py +0 -0
  173. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/_retry.py +0 -0
  174. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/base.py +0 -0
  175. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/clickhouse.py +0 -0
  176. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/datafusion.py +0 -0
  177. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/duckdb_policy_binding.py +0 -0
  178. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/kill.py +0 -0
  179. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/pg_catalog.py +0 -0
  180. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/postgres.py +0 -0
  181. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/registry.py +0 -0
  182. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/sqlite.py +0 -0
  183. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/adapters/umbra.py +0 -0
  184. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/aggregate_introspection.py +0 -0
  185. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/catalog.py +0 -0
  186. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/dialect.py +0 -0
  187. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/__init__.py +0 -0
  188. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/agent.py +0 -0
  189. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/middleware.py +0 -0
  190. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/schema.py +0 -0
  191. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/tool_spec.py +0 -0
  192. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/langchain/wrapper.py +0 -0
  193. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/options.py +0 -0
  194. {data_flow_control-0.2.4 → data_flow_control-0.3.0}/python/data_flow_control/tools/__init__.py +0 -0
  195. {data_flow_control-0.2.4 → 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.4"
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.4"
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.4"
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.4"
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.4
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
@@ -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,
@@ -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)
@@ -181,7 +181,7 @@ impl PassantRewriter {
181
181
  self.store.compiled(index).is_some_and(|compiled| {
182
182
  matches!(
183
183
  compiled.policy.resolution(),
184
- crate::policy::Resolution::Retry(_)
184
+ crate::policy::Resolution::Retry(_) | crate::policy::Resolution::Notify(_)
185
185
  ) && super::policy_expr::compiled_policy_applicability(
186
186
  compiled,
187
187
  &policy_tables,
@@ -70,20 +70,35 @@ impl PassantRewriter {
70
70
  }
71
71
  _ => crate::statement_tables::statement_table_keys(statement),
72
72
  };
73
- let has_retry = self.store.policy_indices().into_iter().any(|index| {
74
- self.store.compiled(index).is_some_and(|compiled| {
75
- matches!(
76
- compiled.policy.resolution(),
77
- crate::policy::Resolution::Retry(_)
78
- ) && super::policy_expr::compiled_policy_applicability(
73
+ use crate::policy::Resolution;
74
+ let mut has_retry = false;
75
+ let mut has_notify = false;
76
+ for index in self.store.policy_indices() {
77
+ let Some(compiled) = self.store.compiled(index) else {
78
+ continue;
79
+ };
80
+ let resolution = compiled.policy.resolution();
81
+ if matches!(resolution, Resolution::Retry(_) | Resolution::Notify(_))
82
+ && super::policy_expr::compiled_policy_applicability(
79
83
  compiled,
80
84
  &statement_sources,
81
85
  statement_sink.as_ref(),
82
86
  true,
83
87
  )
84
88
  .is_some()
85
- })
86
- });
89
+ {
90
+ has_retry |= matches!(resolution, Resolution::Retry(_));
91
+ has_notify |= matches!(resolution, Resolution::Notify(_));
92
+ }
93
+ }
94
+ if has_notify
95
+ && (self.parse_dialect != crate::sql::SqlDialect::DuckDb
96
+ || !matches!(statement, Statement::Insert(insert) if insert.source.as_ref().is_some_and(|query| matches!(query.body.as_ref(), sqlparser::ast::SetExpr::Select(_)))))
97
+ {
98
+ return Err(RewriteError::unsupported_statement(
99
+ "native NOTIFY requires DuckDB INSERT SELECT",
100
+ ));
101
+ }
87
102
  if has_retry && !matches!(statement, Statement::Query(_) | Statement::Insert(_)) {
88
103
  return Err(RewriteError::unsupported_statement(
89
104
  "native RETRY currently requires SELECT or INSERT SELECT",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "data-flow-control"
3
- version = "0.2.4"
3
+ version = "0.3.0"
4
4
  description = "Rust-backed Data Flow Control rewrite engine"
5
5
  license = "MIT"
6
6
  license-files = ["LICENSE"]
@@ -1,7 +1,7 @@
1
1
  from ._passant import PassantRewriteError
2
2
  from .connection import dfc
3
3
  from .dialect import Dialect
4
- from .errors import RetryFailure, RetryViolation
4
+ from .errors import ExecutionOutcome, PolicyMessage, RetryFailure, RetryViolation
5
5
  from .options import RewriteOptions, UiUpdateMode
6
6
  from .policy import Policy, Resolution
7
7
  from .ui import UiViolationEvent
@@ -10,6 +10,8 @@ __all__ = [
10
10
  "Dialect",
11
11
  "PassantRewriteError",
12
12
  "Policy",
13
+ "PolicyMessage",
14
+ "ExecutionOutcome",
13
15
  "Resolution",
14
16
  "RetryFailure",
15
17
  "RetryViolation",
@@ -68,7 +68,7 @@ def resolution_to_python_py(value: str) -> str:
68
68
 
69
69
  def resolution_to_python(value) -> str:
70
70
  if isinstance(value, str):
71
- if value.startswith("{") or value.lstrip().upper().startswith("RETRY"):
71
+ if value.startswith("{") or value.lstrip().upper().startswith(("RETRY", "NOTIFY")):
72
72
  return resolution_to_python_py(value)
73
73
  return value.upper()
74
74
  if isinstance(value, dict):
@@ -52,16 +52,23 @@ class DuckDBAdapter:
52
52
  return self._conn
53
53
 
54
54
  def execute(self, sql: str, params: Any = None):
55
+ result, _ = self._execute(sql, params, collect_notices=False)
56
+ return result
57
+
58
+ def _execute_collecting_notices(self, sql: str, params: Any = None):
59
+ return self._execute(sql, params, collect_notices=True)
60
+
61
+ def _execute(self, sql: str, params: Any, *, collect_notices: bool):
55
62
  state = _retry_registrations.get(self._conn)
56
63
  if state is not None:
57
64
  if not state["lock"].acquire(blocking=False):
58
65
  raise RuntimeError("Overlapping executions on a RETRY connection are not supported")
59
66
  state["failure"] = None
60
67
  state["active"] = True
68
+ state["notices"] = set() if collect_notices else None
61
69
  try:
62
- if params is None:
63
- return self._conn.execute(sql)
64
- return self._conn.execute(sql, params)
70
+ result = self._conn.execute(sql) if params is None else self._conn.execute(sql, params)
71
+ return result, tuple(sorted(state["notices"] or ())) if state else ()
65
72
  except duckdb.Error as exc:
66
73
  failure = state["failure"] if state is not None else None
67
74
  if failure is not None:
@@ -71,6 +78,7 @@ class DuckDBAdapter:
71
78
  if state is not None:
72
79
  state["failure"] = None
73
80
  state["active"] = False
81
+ state["notices"] = None
74
82
  state["lock"].release()
75
83
 
76
84
  def quote_identifier(self, name: str) -> str:
@@ -107,7 +115,7 @@ class DuckDBAdapter:
107
115
  with _retry_registration_lock:
108
116
  if self._conn in _retry_registrations:
109
117
  return
110
- state = {"failure": None, "active": False, "lock": Lock()}
118
+ state = {"failure": None, "notices": None, "active": False, "lock": Lock()}
111
119
 
112
120
  def retry_many(policy_ids: str) -> bool:
113
121
  if not state["active"]:
@@ -131,6 +139,33 @@ class DuckDBAdapter:
131
139
  )
132
140
  _retry_registrations[self._conn] = state
133
141
 
142
+ def register_notify_function(self) -> None:
143
+ with _retry_registration_lock:
144
+ state = _retry_registrations[self._conn]
145
+ if state.get("notify_registered"):
146
+ return
147
+
148
+ def notify_many(policy_ids: str) -> bool:
149
+ if not state["active"] or state["notices"] is None:
150
+ raise RuntimeError("Native NOTIFY requires Connection.execute()")
151
+ parts = policy_ids.split(",") if isinstance(policy_ids, str) else []
152
+ if not parts or any(
153
+ not part or not part.isascii() or not part.isdigit() for part in parts
154
+ ):
155
+ raise RuntimeError("Invalid native NOTIFY policy identity list")
156
+ state["notices"].update(int(part) for part in parts)
157
+ return True
158
+
159
+ self._conn.create_function(
160
+ "passant_notify_many",
161
+ notify_many,
162
+ ["VARCHAR"],
163
+ "BOOLEAN",
164
+ side_effects=True,
165
+ null_handling="special",
166
+ )
167
+ state["notify_registered"] = True
168
+
134
169
  def register_resolution_function(
135
170
  self,
136
171
  name: str,
@@ -10,7 +10,13 @@ from .adapters.base import Adapter
10
10
  from .adapters.datafusion import DataFusionAdapter
11
11
  from .adapters.duckdb import DuckDBAdapter
12
12
  from .adapters.registry import create_adapter, sniff_dialect
13
- from .errors import RetryFailure, RetryViolation, _NativeRetrySignal
13
+ from .errors import (
14
+ ExecutionOutcome,
15
+ PolicyMessage,
16
+ RetryFailure,
17
+ RetryViolation,
18
+ _NativeRetrySignal,
19
+ )
14
20
  from .options import RewriteOptions, UiUpdateMode
15
21
  from .planner import Planner
16
22
  from .policy import Policy, Resolution
@@ -319,6 +325,10 @@ class Connection:
319
325
  f"Resolution RETRY is not supported for dialect {self.adapter.dialect!r}: "
320
326
  f"missing capability retry_resolution{detail}"
321
327
  )
328
+ elif policy.on_fail == Resolution.NOTIFY:
329
+ if not isinstance(self.adapter, DuckDBAdapter):
330
+ raise ValueError("Resolution NOTIFY is only supported by the DuckDB adapter")
331
+ self.adapter.register_notify_function()
322
332
  elif policy.on_fail == Resolution.UDF:
323
333
  if not self.adapter.capabilities.tuple_udf:
324
334
  raise ValueError(
@@ -491,41 +501,72 @@ class Connection:
491
501
  "extension before execute()."
492
502
  )
493
503
 
494
- def execute(self, query: str, *, params=None, options: RewriteOptions | None = None):
504
+ def execute(
505
+ self, query: str, *, params=None, options: RewriteOptions | None = None
506
+ ) -> ExecutionOutcome:
507
+ """Execute one SQL statement and return its policy outcome.
508
+
509
+ On RETRY the statement is aborted and there is no SQL result. On success
510
+ the original backend result is returned; NOTIFY messages are pending
511
+ until the host has verified the corresponding tool's success.
512
+ """
513
+ return self._execute(query, params, options, collect_notices=True)
514
+
515
+ def _execute(self, query, params, options, *, collect_notices) -> ExecutionOutcome:
495
516
  if self._ui_stream_endpoint is not None:
496
517
  self.reset_ui_stream()
497
518
  if self._statement_may_change_schema(query):
498
519
  self._invalidate_catalog_cache()
499
- return self.adapter.execute(query, params)
520
+ return ExecutionOutcome("allowed", self.adapter.execute(query, params))
500
521
  rewritten = self.transform_query(query, options=options)
501
522
  executable = strip_passant_comment(rewritten)
502
523
  self._ensure_ui_stream_extension_for_execute(executable)
503
524
  try:
504
- result = self.adapter.execute(executable, params)
525
+ if collect_notices and isinstance(self.adapter, DuckDBAdapter):
526
+ result, notice_ids = self.adapter._execute_collecting_notices(executable, params)
527
+ else:
528
+ result, notice_ids = self.adapter.execute(executable, params), ()
505
529
  except _NativeRetrySignal as exc:
506
- failures = []
507
- for index, _ in exc.failures:
508
- policy = self.planner.policy_by_index(index)
509
- if policy is None or policy.on_fail is not Resolution.RETRY:
510
- raise RuntimeError(
511
- f"Native RETRY identified unknown/non-RETRY policy {index}"
512
- ) from exc
513
- failures.append(RetryFailure(index, policy.retry_message, policy))
514
- raise RetryViolation(failures) from exc
530
+ messages = self._policy_messages((index for index, _ in exc.failures), Resolution.RETRY)
531
+ return ExecutionOutcome("retry", None, messages)
515
532
  if self._statement_may_change_schema(query):
516
533
  self._invalidate_catalog_cache()
517
534
  followup = self.planner.last_ui_followup_sql()
518
535
  if followup:
519
536
  self.adapter.execute(followup, params)
520
- return result
537
+ return ExecutionOutcome(
538
+ "allowed", result, self._policy_messages(notice_ids, Resolution.NOTIFY)
539
+ )
540
+
541
+ def _policy_messages(self, indices, resolution: Resolution) -> tuple[PolicyMessage, ...]:
542
+ messages = []
543
+ for index in sorted(set(indices)):
544
+ policy = self.planner.policy_by_index(index)
545
+ if policy is None or policy.on_fail is not resolution:
546
+ raise RuntimeError(
547
+ f"Native {resolution.value} identified unknown/non-{resolution.value} policy {index}"
548
+ )
549
+ message = (
550
+ policy.retry_message if resolution is Resolution.RETRY else policy.notify_message
551
+ )
552
+ messages.append(PolicyMessage(index, message, policy))
553
+ return tuple(messages)
554
+
555
+ def _fetch_result(self, query, params, options):
556
+ # These helpers return only rows. Decline NOTIFY at the SQL boundary
557
+ # instead of executing an insert and silently dropping its pending message.
558
+ outcome = self._execute(query, params, options, collect_notices=False)
559
+ if outcome.status == "retry":
560
+ raise RetryViolation(
561
+ RetryFailure(m.policy_index, m.message, m.policy) for m in outcome.messages
562
+ )
563
+ return outcome.sql_result
521
564
 
522
565
  def fetchall(self, query: str, *, params=None, options: RewriteOptions | None = None):
523
- result = self.execute(query, params=params, options=options)
524
- return result.fetchall()
566
+ return self._fetch_result(query, params, options).fetchall()
525
567
 
526
568
  def fetchone(self, query: str, *, params=None, options: RewriteOptions | None = None):
527
- result = self.execute(query, params=params, options=options)
528
- return result.fetchone()
569
+ return self._fetch_result(query, params, options).fetchone()
529
570
 
530
571
  def close(self) -> None:
531
572
  self.adapter.close()