synalog 2.5.0__tar.gz → 2.6.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.
- {synalog-2.5.0 → synalog-2.6.0}/Cargo.lock +2 -2
- {synalog-2.5.0 → synalog-2.6.0}/Cargo.toml +1 -1
- {synalog-2.5.0 → synalog-2.6.0}/PKG-INFO +1 -1
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/directives.md +3 -1
- {synalog-2.5.0 → synalog-2.6.0}/docs/python-api.md +1 -1
- {synalog-2.5.0 → synalog-2.6.0}/docs/verification.md +4 -1
- {synalog-2.5.0 → synalog-2.6.0}/pyproject.toml +1 -1
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/runners.py +19 -7
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/annotations.rs +49 -20
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/dialects.rs +7 -0
- synalog-2.6.0/src/compiler/home_guard.rs +549 -0
- synalog-2.6.0/src/compiler/home_guard_test.rs +118 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/mod.rs +1 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/universe.rs +48 -6
- {synalog-2.5.0 → synalog-2.6.0}/uv.lock +1 -1
- {synalog-2.5.0 → synalog-2.6.0}/verified/Cargo.toml +1 -1
- synalog-2.6.0/verified/src/home.rs +212 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/lib.rs +3 -0
- {synalog-2.5.0 → synalog-2.6.0}/.gitignore +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/LICENSE +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/NOTICE +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/README.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/assertions.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/assets/synalog-dark.svg +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/assets/synalog-light.svg +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/assets/synalog_favicon.png +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark/results.json +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark/speedup_by_engine.png +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark/speedup_distribution.png +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark/summary.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark/summary.png +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark/time_comparison.png +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark/verify_by_engine.png +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/benchmark.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/cli.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/development.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/differences-datalog.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/differences.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/engines.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/aggregation.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/aggregation.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/directives.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/directives.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/functions.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/functions.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/functors.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/functors.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/getting_started.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/getting_started.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/knowledge_graphs.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/knowledge_graphs.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/recursion.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/recursion.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/run.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/concepts/customer.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/concepts/order_status.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/data/orders.csv +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/layer.toml +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/rules/customer_revenue.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/rules/orders_by_status.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/rules/top_customers.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop/tables/orders.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/shop.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke/concepts/device.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke/concepts/test_status.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke/data/smoke_tests.csv +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke/layer.toml +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke/rules/failures_by_device.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke/rules/runs_per_day.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke/tables/smoke_tests.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/smoke.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/syntax.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/syntax.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/temporal.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/temporal.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/temporal_graph.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/temporal_graph.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/verification.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/examples/verification.log +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/getting-started.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/index.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/javascripts/playground.js +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/javascripts/summarize.js +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/javascripts/synalog-highlight.js +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/knowledge-graphs.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/aggregation.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/functions.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/functors.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/index.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/recursion.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/syntax.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/language/temporal.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/playground/vendor/codemirror.js +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/playground.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/stylesheets/extra.css +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/docs/why.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/img/synalog-dark.svg +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/img/synalog-light.svg +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/__init__.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/__main__.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/checking.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/cli.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/config.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/execution.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/introspect.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/project.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/python/synalog/writes.py +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/SKILL.md +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/concepts/department.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/concepts/person.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/concepts/works_in.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/data/departments.csv +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/data/employees.csv +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/layer.toml +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/rules/team_mate.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/tables/departments.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/company/tables/employees.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/org/concepts/all_managers.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/org/data/employees.csv +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/org/layer.toml +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/org/tables/employees.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/sales/concepts/region.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/sales/data/sales.csv +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/sales/layer.toml +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/sales/rules/monthly_sales.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/sales/rules/top_region.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/sales/rules/total_by_region.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/skills/synalog/examples/sales/tables/sales.l +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/assertion/mod.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/assertion/parse.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/assertion/report.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/assertion/translate.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/annotations_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/dialects_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/expr_translate.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/expr_translate_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/functors.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/functors_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/rule_translate.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/rule_translate_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/builder.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/built_in.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/edge.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/expression.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/graph.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/inference.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/intersection.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/mod.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/type_inference/types.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/compiler/universe_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/errors.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/lib.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/json.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/json_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/mod.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/names.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/parse.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/parse_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/rewrite.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/rewrite_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/span.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/span_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/traverse.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/parser/traverse_test.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/python.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/arity.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/assertions.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/cast.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/contradiction.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/dependencies.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/directives.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/front_matter.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/functors.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/mod.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/orderby.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/positional.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/recursion.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/reserved.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/safety.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/sqlexpr.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/stratification.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/undefined.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/verifier/vars.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/src/wasm.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/arity.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/cast.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/contradiction.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/convergence.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/membership.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/page.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/plan.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/quote.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/recursion.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/safety.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/strata.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/verified/src/types.rs +0 -0
- {synalog-2.5.0 → synalog-2.6.0}/zensical.toml +0 -0
|
@@ -300,7 +300,7 @@ dependencies = [
|
|
|
300
300
|
|
|
301
301
|
[[package]]
|
|
302
302
|
name = "synalog"
|
|
303
|
-
version = "2.
|
|
303
|
+
version = "2.6.0"
|
|
304
304
|
dependencies = [
|
|
305
305
|
"anyhow",
|
|
306
306
|
"indexmap",
|
|
@@ -316,7 +316,7 @@ dependencies = [
|
|
|
316
316
|
|
|
317
317
|
[[package]]
|
|
318
318
|
name = "synalog-verified"
|
|
319
|
-
version = "2.
|
|
319
|
+
version = "2.6.0"
|
|
320
320
|
dependencies = [
|
|
321
321
|
"vstd",
|
|
322
322
|
]
|
|
@@ -57,7 +57,9 @@ Forces a predicate to be materialized before its dependents are evaluated, usefu
|
|
|
57
57
|
@Ground(CustomerRevenue);
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
The table is named after the predicate, in Synalog's schema, `synalog_home` on every engine (`synalog_home.CustomerRevenue`; on Trino and Presto in a catalog of the same name, `synalog_home.synalog_home.CustomerRevenue`, so the customer's catalog can be read-only to Synalog's user). A
|
|
60
|
+
The table is named after the predicate, in Synalog's schema, `synalog_home` on every engine (`synalog_home.CustomerRevenue`; on Trino and Presto in a catalog of the same name, `synalog_home.synalog_home.CustomerRevenue`, so the customer's catalog can be read-only to Synalog's user). A predicate named after an SQL keyword gets `_table` added (`Order_table`), since `Order` does not parse as a table name.
|
|
61
|
+
|
|
62
|
+
As in Logica, the table is built in place under that name, dropped and created again by every run that needs it, from the data as it is then, and it stays after the run: it holds the predicate's rows of the last run, which other programs and tools can read. Runs at once that ground the same predicate build the same table, so one can read rows the other built, or fail. On PostgreSQL the table is dropped alone, never `CASCADE`: a view of yours built on it fails the drop and is not dropped with it. On ClickHouse it is a `MergeTree`, which a restart keeps; on SQLite, whose `synalog_home` is an in-memory database, it lasts as long as the connection. The tables synalog grounds itself (a recursion's steps, a predicate read twice) are a [plan](../python-api.md#plan)'s own (temporary tables on PostgreSQL, a name ending with a tag unique to the run elsewhere), dropped when it ends.
|
|
61
63
|
|
|
62
64
|
## `@Engine`
|
|
63
65
|
|
|
@@ -172,7 +172,7 @@ The steps that compute a predicate, for a host that runs them itself. Each step
|
|
|
172
172
|
| `{"kind": "sql", "sql": ...}` | a statement; the last step's rows are the predicate's |
|
|
173
173
|
| `{"kind": "loop", "body": [...], "repetitions": n, "changed": ...}` | a recursion: run `changed`, a query returning one number; while it is not 0, run the `body` statements, `n` times at most |
|
|
174
174
|
|
|
175
|
-
All the steps run in one connection: the loops write tables the later steps read. They are the plan's own, so plans running at once never share them: on PostgreSQL the connection's temporary tables (`pg_temp`; run the steps in one transaction for them to read one snapshot),
|
|
175
|
+
All the steps run in one connection: the loops write tables the later steps read. They are the plan's own, so plans running at once never share them: on PostgreSQL the connection's temporary tables (`pg_temp`; run the steps in one transaction for them to read one snapshot), elsewhere tables whose names end with a tag unique to the plan (`synalog_home.Q_r…`, `synalog_home.synalog_home.Q_r…` on Trino and Presto). A host drops those tables when the plan ends; a table of the program's own [`@Ground`](language/directives.md#ground), named after its predicate with no tag, stays. `synalog.runners.run_plan(steps, session)` runs a plan in a [`synalog.runners.session`](cli.md#executing-locally).
|
|
176
176
|
|
|
177
177
|
## `writes_outside_home`
|
|
178
178
|
|
|
@@ -74,6 +74,8 @@ A program's text reaches SQL only as values or as checked names, so no string ca
|
|
|
74
74
|
- a program reaches no file, process or service: there is no `ReadFile`, `WriteFile` or `Intelligence`, no `copy_to_file`, and a table name opens none: once the files given to `execute` are loaded, its DuckDB session reads no file, installs no extension and takes no Python variable for a table (`secret.csv`, `"secret"."parquet"`), which DuckDB otherwise does (`tests/cli/test_file_access.py`);
|
|
75
75
|
- a program writes in `synalog_home` only, on every engine (on Trino and Presto, in a catalog of the same name: `synalog_home.synalog_home`): its tables (also when `@Ground` names one), and the types and sequence the PostgreSQL and DuckDB sessions need. There is no directive to write elsewhere (`@Dataset` and `@AttachDatabase` are not directives), so a program cannot create, drop or replace anything outside it.
|
|
76
76
|
|
|
77
|
+
Before a plan leaves the compiler, every statement of it is read again as the engine reads it, and the plan is refused unless they write in `synalog_home` only: a bug in the compiler that named a table elsewhere is a compile error (`synalog refused to return SQL that would write outside synalog_home`), never a statement sent to a database. The reading accepts the statements the compiler writes, and nothing else: a query, `SET` (not of a role or a password), `CREATE` or `DROP` of a table, type or sequence, `INSERT INTO`, the making of `synalog_home`, PostgreSQL's `DO` blocks of its setup and SQLite's attaching of its in-memory `synalog_home`. It refuses any other statement (`UPDATE`, `DELETE`, `ALTER`, `GRANT`, `COPY`, `CALL`, dynamic SQL), a write inside a query (`SELECT ... INTO`, `WITH d AS (DELETE ...)`), a table stored elsewhere though named in `synalog_home` (`LOCATION`, a ClickHouse `ENGINE` but `Memory`), and text an engine might read otherwise than it does: an unclosed literal or comment, a comment nested in one, MySQL's `/*!` and `--` before no space, a `#`, Spark's `${`, BigQuery's raw and triple-quoted strings. The decision over what it reads is proved (see [Proved algorithms](#proved-algorithms)); `src/compiler/home_guard.rs` reads the statements for it.
|
|
78
|
+
|
|
77
79
|
`tests/programs/injection` holds the attempts this is checked against, on every engine. The quoting of strings and identifiers is also proved (see [Proved algorithms](#proved-algorithms)): for any text, the engine's lexer reads it back exactly and ends the literal at its closing quote.
|
|
78
80
|
|
|
79
81
|
### Contradictions
|
|
@@ -102,7 +104,7 @@ TopCustomers(customer_id:) :- customer_id in Range(3);
|
|
|
102
104
|
|
|
103
105
|
## Proved algorithms
|
|
104
106
|
|
|
105
|
-
The algorithms behind the stratification and recursion checks, the compiler's choice of how to unfold a mutual recursion, the order a compiled program's tables run in, the contradiction warning, pagination, quoting
|
|
107
|
+
The algorithms behind the stratification and recursion checks, the compiler's choice of how to unfold a mutual recursion, the order a compiled program's tables run in, the contradiction warning, pagination, quoting, the `Cast` type-name check and the check that a plan writes in `synalog_home` only are written in [Verus](https://github.com/verus-lang/verus): each algorithm carries a specification that Verus proves it meets, for every input:
|
|
106
108
|
|
|
107
109
|
| Algorithm | Proved |
|
|
108
110
|
|-----------|--------|
|
|
@@ -115,6 +117,7 @@ The algorithms behind the stratification and recursion checks, the compiler's ch
|
|
|
115
117
|
| **Contradictions** | A rule reported as contradictory has no values satisfying its comparisons: the warning is never wrong |
|
|
116
118
|
| **Pagination** | A page keeps exactly the rows asked for (`limit` rows after `offset`, no more than `@Limit`), whatever the numbers, and never writes one a `BIGINT` cannot hold |
|
|
117
119
|
| **Cast type** | A `Cast`/`TryCast` type name the validator accepts holds no character that could end the `CAST(...)` or start a statement after it, and keeps its brackets balanced, so it stays inside the cast |
|
|
120
|
+
| **Writes in `synalog_home` only** | The statements of a plan are returned exactly when none is one the compiler never writes and every write names a table directly in `synalog_home` (`synalog_home.synalog_home` on Trino and Presto; PostgreSQL's session tables in `pg_temp`), every schema made being `synalog_home` itself: a name with a part too few or too many, or no name at all, is refused |
|
|
118
121
|
| **Quoting** | A string or an identifier quoted for any engine is read back by the engine's lexer exactly, ending at its closing quote whatever SQL follows: doubled quotes (`'it''s'`), backslash escapes (BigQuery, Spark), PostgreSQL's `E'...'` read alike whatever `standard_conforming_strings` says; on BigQuery and Spark a string holds no quote but its own two, and on Spark no `$` |
|
|
119
122
|
|
|
120
123
|
The type inference's intersection of two types runs too often to convert its types for a proved version: Verus proves a reference intersection the greatest common refinement of two types (it refines both, every type refining both refines it, and when there is none no type refines both), and a test checks the type inference agrees with it on 20,000 random pairs of types (`cargo test --test type_intersection`).
|
|
@@ -877,16 +877,19 @@ _LIST_TABLES = {
|
|
|
877
877
|
|
|
878
878
|
|
|
879
879
|
def sweep_stale_tables(steps: list[dict], s: Session, engine: str, now: float | None = None) -> list[str]:
|
|
880
|
-
"""Drop the tables killed runs left in the schemas this plan
|
|
881
|
-
tables
|
|
880
|
+
"""Drop the tables killed runs left in the schemas this plan writes its
|
|
881
|
+
tables in (a grounded table that stays included, PostgreSQL's temporary
|
|
882
|
+
ones not), older than ``STALE_AFTER_SECONDS``; the tables dropped.
|
|
882
883
|
|
|
883
884
|
A run drops its own tables when it ends (``_drop_working_tables``); a run
|
|
884
885
|
killed first cannot. Best effort: a table it cannot list or drop stays,
|
|
885
886
|
and the plan runs regardless."""
|
|
886
887
|
if engine not in _LIST_TABLES:
|
|
887
888
|
return []
|
|
888
|
-
texts = [
|
|
889
|
-
schemas = {
|
|
889
|
+
texts = [t for step in steps for t in _texts(step)]
|
|
890
|
+
schemas = {
|
|
891
|
+
t.rsplit(".", 1)[0] for text in texts for t in _WORKING_TABLE.findall(text) if not t.lower().startswith("pg_temp.")
|
|
892
|
+
}
|
|
890
893
|
query, column = _LIST_TABLES[engine]
|
|
891
894
|
deadline = (time.time() if now is None else now) - STALE_AFTER_SECONDS
|
|
892
895
|
dropped = []
|
|
@@ -906,11 +909,20 @@ def sweep_stale_tables(steps: list[dict], s: Session, engine: str, now: float |
|
|
|
906
909
|
return dropped
|
|
907
910
|
|
|
908
911
|
|
|
912
|
+
def _texts(step: dict) -> list[str]:
|
|
913
|
+
"""The SQL of a step: its statements, a loop's body."""
|
|
914
|
+
return [step.get("sql", ""), *step.get("body", [])]
|
|
915
|
+
|
|
916
|
+
|
|
909
917
|
def _drop_working_tables(steps: list[dict], s: Session) -> None:
|
|
910
|
-
"""Drop the tables the run
|
|
911
|
-
nothing behind (on Presto's memory connector they filled the
|
|
912
|
-
|
|
918
|
+
"""Drop the tables the run computed with in synalog's schemas, so a run
|
|
919
|
+
leaves nothing behind (on Presto's memory connector they filled the
|
|
920
|
+
heap): its own, named with its tag or PostgreSQL's temporary ones. A
|
|
921
|
+
table of the program's own `@Ground`, named after its predicate, stays."""
|
|
922
|
+
texts = [t for step in steps for t in _texts(step)]
|
|
913
923
|
for table in dict.fromkeys(t for text in texts for t in _WORKING_TABLE.findall(text)):
|
|
924
|
+
if not (_TAGGED_TABLE.match(table) or table.lower().startswith("pg_temp.")):
|
|
925
|
+
continue
|
|
914
926
|
try:
|
|
915
927
|
s.run(f"DROP TABLE IF EXISTS {table}")
|
|
916
928
|
except Exception: # noqa: BLE001 - best effort: the rows are already read
|
|
@@ -45,12 +45,20 @@ pub struct Annotations {
|
|
|
45
45
|
/// whose schema every session shares (Trino, Presto, Databricks,
|
|
46
46
|
/// BigQuery): concurrent runs then compute into tables of their own.
|
|
47
47
|
pub run_tag: Option<String>,
|
|
48
|
+
/// The predicates the program's own `@Ground` grounds, not those the
|
|
49
|
+
/// compiler grounds itself (a recursion's steps, a predicate read
|
|
50
|
+
/// twice): their tables are built in place, under their names, and stay
|
|
51
|
+
/// in synalog_home after a run (`published_table`).
|
|
52
|
+
pub own_grounds: HashSet<String>,
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
#[derive(Debug, Clone)]
|
|
51
56
|
pub struct Ground {
|
|
52
57
|
pub table_name: String,
|
|
53
58
|
pub overwrite: bool,
|
|
59
|
+
/// A table of the program's own `@Ground`, built in place under its
|
|
60
|
+
/// name and staying in synalog_home after the run (`published_table`).
|
|
61
|
+
pub stays: bool,
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
/// Extract a string value from a Synalog expression literal.
|
|
@@ -358,6 +366,7 @@ impl Annotations {
|
|
|
358
366
|
engine_options,
|
|
359
367
|
session_tables: false,
|
|
360
368
|
run_tag: None,
|
|
369
|
+
own_grounds: HashSet::new(),
|
|
361
370
|
})
|
|
362
371
|
}
|
|
363
372
|
|
|
@@ -458,6 +467,33 @@ impl Annotations {
|
|
|
458
467
|
}
|
|
459
468
|
}
|
|
460
469
|
|
|
470
|
+
/// The table a grounded predicate of the program's own `@Ground` is
|
|
471
|
+
/// built in, and stays in after a run, as in Logica: named after the predicate, the table
|
|
472
|
+
/// `@Ground` names, or the table of the grounded predicate it names, in
|
|
473
|
+
/// synalog_home itself (on Trino and Presto in its catalog; on
|
|
474
|
+
/// PostgreSQL never the session's `pg_temp`), with no run's tag. None
|
|
475
|
+
/// for a predicate the program does not ground.
|
|
476
|
+
pub fn published_table(&self, pred_name: &str) -> Option<String> {
|
|
477
|
+
if !self.own_grounds.contains(pred_name) {
|
|
478
|
+
return None;
|
|
479
|
+
}
|
|
480
|
+
let raw = self.annotations.get(pred_name)?.get("ground")?.as_str().to_string();
|
|
481
|
+
let named = if raw == pred_name {
|
|
482
|
+
raw
|
|
483
|
+
} else {
|
|
484
|
+
match self.annotations.get(&raw).and_then(|ann| ann.get("ground")) {
|
|
485
|
+
Some(other) => other.as_str().to_string(),
|
|
486
|
+
None => raw,
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
let name = if crate::compiler::dialects::is_sql_keyword(&named) { format!("{named}_table") } else { named };
|
|
490
|
+
let home = home_schema();
|
|
491
|
+
Some(match self.engine.as_str() {
|
|
492
|
+
"trino" | "presto" => format!("{home}.{home}.{name}"),
|
|
493
|
+
_ => format!("{home}.{name}"),
|
|
494
|
+
})
|
|
495
|
+
}
|
|
496
|
+
|
|
461
497
|
/// The databases to attach: SQLite keeps grounded tables in an
|
|
462
498
|
/// in-memory database named as the home schema.
|
|
463
499
|
pub fn attached_databases(&self) -> Vec<(String, String)> {
|
|
@@ -626,7 +662,8 @@ impl Annotations {
|
|
|
626
662
|
/// database of the session's, PostgreSQL into its temporary tables.
|
|
627
663
|
fn shared_schema_tag(&self) -> Option<&str> {
|
|
628
664
|
match self.engine.as_str() {
|
|
629
|
-
|
|
665
|
+
// PostgreSQL's are the session's temporary tables.
|
|
666
|
+
"psql" => None,
|
|
630
667
|
_ if self.session_tables => self.run_tag.as_deref(),
|
|
631
668
|
_ => None,
|
|
632
669
|
}
|
|
@@ -637,27 +674,16 @@ impl Annotations {
|
|
|
637
674
|
let v = a.get("ground")?;
|
|
638
675
|
let raw = v.as_str().to_string();
|
|
639
676
|
|
|
640
|
-
//
|
|
641
|
-
//
|
|
642
|
-
//
|
|
677
|
+
// Named after the predicate, after the table another grounded
|
|
678
|
+
// predicate named here is stored in, or as given: in Synalog's
|
|
679
|
+
// dataset each time, so grounding never drops or replaces a table
|
|
680
|
+
// elsewhere.
|
|
643
681
|
let table_name = if raw == pred_name {
|
|
644
682
|
self.default_table(&raw)
|
|
645
683
|
} else {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
.
|
|
649
|
-
.and_then(|ann| ann.get("ground"))
|
|
650
|
-
{
|
|
651
|
-
let other_raw = other_ground.as_str().to_string();
|
|
652
|
-
if other_raw == raw {
|
|
653
|
-
self.default_table(&other_raw)
|
|
654
|
-
} else {
|
|
655
|
-
other_raw
|
|
656
|
-
}
|
|
657
|
-
} else {
|
|
658
|
-
// A table named in @Ground lives in Synalog's dataset too:
|
|
659
|
-
// grounding never drops or replaces a table elsewhere.
|
|
660
|
-
self.default_table(&raw)
|
|
684
|
+
match self.annotations.get(&raw).and_then(|ann| ann.get("ground")) {
|
|
685
|
+
Some(other) => self.default_table(other.as_str()),
|
|
686
|
+
None => self.default_table(&raw),
|
|
661
687
|
}
|
|
662
688
|
};
|
|
663
689
|
|
|
@@ -669,7 +695,10 @@ impl Annotations {
|
|
|
669
695
|
})
|
|
670
696
|
.unwrap_or(true);
|
|
671
697
|
|
|
672
|
-
|
|
698
|
+
// The program's own: built in place under its name, where it stays.
|
|
699
|
+
let stays = self.own_grounds.contains(pred_name);
|
|
700
|
+
let table_name = self.published_table(pred_name).unwrap_or(table_name);
|
|
701
|
+
Some(Ground { table_name, overwrite, stays })
|
|
673
702
|
}
|
|
674
703
|
|
|
675
704
|
/// Get ORDER BY columns for a predicate, if any.
|
|
@@ -405,6 +405,12 @@ pub trait Dialect {
|
|
|
405
405
|
""
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
/// The options of a grounded table that stays after a run: as another,
|
|
409
|
+
/// but one that lasts (ClickHouse's `Memory` is lost when it restarts).
|
|
410
|
+
fn lasting_table_options(&self) -> &'static str {
|
|
411
|
+
self.create_table_options()
|
|
412
|
+
}
|
|
413
|
+
|
|
408
414
|
/// Whether a subquery counting the rows of the outer row reads null
|
|
409
415
|
/// where it counts none (ClickHouse decorrelates it into a join, whose
|
|
410
416
|
/// missing side is null): such a count is then read as 0.
|
|
@@ -1703,6 +1709,7 @@ impl Dialect for ClickHouseDialect {
|
|
|
1703
1709
|
fn bind_value(&self) -> &'static str { "arrayElement(arrayMap(synalog_v -> {body}, [{0}]), 1)" }
|
|
1704
1710
|
fn string_cast(&self, expr: &str) -> String { format!("CAST({} AS String)", expr) }
|
|
1705
1711
|
fn create_table_options(&self) -> &'static str { " ENGINE = Memory" }
|
|
1712
|
+
fn lasting_table_options(&self) -> &'static str { " ENGINE = MergeTree ORDER BY tuple()" }
|
|
1706
1713
|
fn greatest_skips_nulls(&self) -> bool { true }
|
|
1707
1714
|
fn correlated_count_may_be_null(&self) -> bool { true }
|
|
1708
1715
|
fn negation_by_membership(&self) -> bool { true }
|