synalog 2.4.1__tar.gz → 2.5.1__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.4.1 → synalog-2.5.1}/Cargo.lock +2 -2
- {synalog-2.4.1 → synalog-2.5.1}/Cargo.toml +1 -1
- {synalog-2.4.1 → synalog-2.5.1}/PKG-INFO +82 -4
- {synalog-2.4.1 → synalog-2.5.1}/README.md +75 -3
- {synalog-2.4.1 → synalog-2.5.1}/docs/cli.md +1 -1
- {synalog-2.4.1 → synalog-2.5.1}/docs/development.md +3 -1
- synalog-2.5.1/docs/engines.md +65 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/getting-started.md +1 -1
- {synalog-2.4.1 → synalog-2.5.1}/docs/index.md +1 -1
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/directives.md +1 -1
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/recursion.md +2 -2
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/syntax.md +4 -2
- {synalog-2.4.1 → synalog-2.5.1}/docs/python-api.md +17 -2
- {synalog-2.4.1 → synalog-2.5.1}/docs/verification.md +8 -5
- {synalog-2.4.1 → synalog-2.5.1}/pyproject.toml +9 -3
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/introspect.py +4 -1
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/project.py +15 -0
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/runners.py +211 -13
- synalog-2.5.1/python/synalog/writes.py +85 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/SKILL.md +2 -2
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/annotations.rs +151 -94
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/annotations_test.rs +4 -4
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/dialects.rs +624 -7
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/dialects_test.rs +76 -4
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/expr_translate.rs +349 -7
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/expr_translate_test.rs +18 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/functors.rs +35 -18
- synalog-2.5.1/src/compiler/home_guard.rs +536 -0
- synalog-2.5.1/src/compiler/home_guard_test.rs +116 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/mod.rs +3 -6
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/rule_translate.rs +30 -2
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/universe.rs +134 -15
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/universe_test.rs +45 -8
- {synalog-2.4.1 → synalog-2.5.1}/src/python.rs +32 -1
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/directives.rs +3 -28
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/stratification.rs +69 -62
- {synalog-2.4.1 → synalog-2.5.1}/uv.lock +271 -8
- {synalog-2.4.1 → synalog-2.5.1}/verified/Cargo.toml +1 -1
- synalog-2.5.1/verified/src/convergence.rs +362 -0
- synalog-2.5.1/verified/src/home.rs +212 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/lib.rs +6 -0
- synalog-2.4.1/docs/engines.md +0 -39
- {synalog-2.4.1 → synalog-2.5.1}/.gitignore +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/LICENSE +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/NOTICE +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/assertions.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/assets/synalog-dark.svg +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/assets/synalog-light.svg +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/assets/synalog_favicon.png +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark/results.json +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark/speedup_by_engine.png +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark/speedup_distribution.png +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark/summary.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark/summary.png +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark/time_comparison.png +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark/verify_by_engine.png +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/benchmark.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/differences-datalog.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/differences.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/aggregation.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/aggregation.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/directives.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/directives.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/functions.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/functions.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/functors.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/functors.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/getting_started.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/getting_started.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/knowledge_graphs.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/knowledge_graphs.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/recursion.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/recursion.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/run.py +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/concepts/customer.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/concepts/order_status.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/data/orders.csv +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/layer.toml +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/rules/customer_revenue.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/rules/orders_by_status.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/rules/top_customers.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop/tables/orders.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/shop.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke/concepts/device.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke/concepts/test_status.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke/data/smoke_tests.csv +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke/layer.toml +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke/rules/failures_by_device.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke/rules/runs_per_day.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke/tables/smoke_tests.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/smoke.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/syntax.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/syntax.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/temporal.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/temporal.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/temporal_graph.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/temporal_graph.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/verification.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/examples/verification.log +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/javascripts/playground.js +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/javascripts/summarize.js +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/javascripts/synalog-highlight.js +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/knowledge-graphs.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/aggregation.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/functions.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/functors.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/index.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/language/temporal.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/playground/vendor/codemirror.js +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/playground.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/stylesheets/extra.css +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/docs/why.md +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/img/synalog-dark.svg +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/img/synalog-light.svg +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/__init__.py +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/__main__.py +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/checking.py +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/cli.py +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/config.py +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/python/synalog/execution.py +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/concepts/department.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/concepts/person.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/concepts/works_in.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/data/departments.csv +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/data/employees.csv +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/layer.toml +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/rules/team_mate.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/tables/departments.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/company/tables/employees.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/org/concepts/all_managers.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/org/data/employees.csv +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/org/layer.toml +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/org/tables/employees.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/sales/concepts/region.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/sales/data/sales.csv +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/sales/layer.toml +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/sales/rules/monthly_sales.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/sales/rules/top_region.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/sales/rules/total_by_region.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/skills/synalog/examples/sales/tables/sales.l +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/assertion/mod.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/assertion/parse.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/assertion/report.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/assertion/translate.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/functors_test.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/rule_translate_test.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/builder.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/built_in.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/edge.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/expression.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/graph.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/inference.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/intersection.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/mod.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/compiler/type_inference/types.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/errors.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/lib.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/json.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/json_test.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/mod.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/names.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/parse.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/parse_test.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/rewrite.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/rewrite_test.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/span.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/span_test.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/traverse.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/parser/traverse_test.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/arity.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/assertions.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/cast.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/contradiction.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/dependencies.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/front_matter.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/functors.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/mod.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/orderby.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/positional.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/recursion.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/reserved.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/safety.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/sqlexpr.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/undefined.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/verifier/vars.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/src/wasm.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/arity.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/cast.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/contradiction.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/membership.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/page.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/plan.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/quote.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/recursion.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/safety.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/strata.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/verified/src/types.rs +0 -0
- {synalog-2.4.1 → synalog-2.5.1}/zensical.toml +0 -0
|
@@ -300,7 +300,7 @@ dependencies = [
|
|
|
300
300
|
|
|
301
301
|
[[package]]
|
|
302
302
|
name = "synalog"
|
|
303
|
-
version = "2.
|
|
303
|
+
version = "2.5.1"
|
|
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.5.1"
|
|
320
320
|
dependencies = [
|
|
321
321
|
"vstd",
|
|
322
322
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: synalog
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.1
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -22,13 +22,19 @@ Requires-Dist: trino ; extra == 'all-engines'
|
|
|
22
22
|
Requires-Dist: presto-python-client ; extra == 'all-engines'
|
|
23
23
|
Requires-Dist: databricks-sql-connector ; extra == 'all-engines'
|
|
24
24
|
Requires-Dist: google-cloud-bigquery ; extra == 'all-engines'
|
|
25
|
+
Requires-Dist: clickhouse-connect ; extra == 'all-engines'
|
|
26
|
+
Requires-Dist: pymysql ; extra == 'all-engines'
|
|
25
27
|
Requires-Dist: google-cloud-bigquery ; extra == 'bigquery'
|
|
28
|
+
Requires-Dist: clickhouse-connect ; extra == 'clickhouse'
|
|
26
29
|
Requires-Dist: databricks-sql-connector ; extra == 'databricks'
|
|
30
|
+
Requires-Dist: pymysql ; extra == 'mysql'
|
|
27
31
|
Requires-Dist: presto-python-client ; extra == 'presto'
|
|
28
32
|
Requires-Dist: trino ; extra == 'trino'
|
|
29
33
|
Provides-Extra: all-engines
|
|
30
34
|
Provides-Extra: bigquery
|
|
35
|
+
Provides-Extra: clickhouse
|
|
31
36
|
Provides-Extra: databricks
|
|
37
|
+
Provides-Extra: mysql
|
|
32
38
|
Provides-Extra: presto
|
|
33
39
|
Provides-Extra: trino
|
|
34
40
|
License-File: LICENSE
|
|
@@ -81,9 +87,10 @@ A raw table is just rows; an agent has to re-interpret what they *mean* on every
|
|
|
81
87
|
- **Dynamic, not static**: the layer evolves as the agent learns. New rules extend the vocabulary at runtime; the rule base itself becomes the agent's long-term memory over structured data.
|
|
82
88
|
- **Auditable reasoning**: every derived fact traces back through named rules, giving full lineage from answer to source tables.
|
|
83
89
|
- **Compile-time verification**: a formal verifier catches structural errors before any SQL touches a database, so a self-authored rule that parses but is unsound is rejected up front. See [Verification](https://synalinks.github.io/synalog/verification/).
|
|
90
|
+
- **Assertions in Lean, checked against the data**: state what a predicate must satisfy (a key, a reference, a bound, a total, transitivity) as a first-order statement written as a [Lean](https://lean-lang.org/) proposition, such as `∀ c r s, Revenue c r → Revenue c s → r = s`. Synalog compiles the search for counterexamples to SQL and runs it on the database: `run` refuses a program whose assertions are violated, and `verify` prints the rows that break them. The rule and its assertion state the same intent in two different notations, so a mistake made in one is unlikely to be repeated in the other. That makes assertions the contract an agent states first and writes its rules against. See [Assertions](#assertions).
|
|
84
91
|
- **A fast Rust engine**: check and compile sit inside the agent's inner loop (every generated rule is validated, every query compiled, often several times per step). The Rust core makes that loop cost milliseconds instead of seconds. See [Benchmark](https://synalinks.github.io/synalog/benchmark/).
|
|
85
92
|
|
|
86
|
-
Because SQL engines are better optimized than logic programming engines, Synalog compiles into *optimized SQL* that runs on **SQLite**, **DuckDB**, **BigQuery**, **PostgreSQL**, **Presto**, **Trino** and **
|
|
93
|
+
Because SQL engines are better optimized than logic programming engines, Synalog compiles into *optimized SQL* that runs on **SQLite**, **DuckDB**, **BigQuery**, **PostgreSQL**, **Presto**, **Trino**, **Databricks**, **ClickHouse** and **MySQL**: efficiently scaling to *petabytes of data*. See [Supported engines](https://synalinks.github.io/synalog/engines/).
|
|
87
94
|
|
|
88
95
|
Full documentation: **<https://synalinks.github.io/synalog/>**
|
|
89
96
|
|
|
@@ -142,9 +149,10 @@ Installing the package also installs a `synalog` command (also available as `pyt
|
|
|
142
149
|
synalog program.l print Predicate # print compiled SQL
|
|
143
150
|
synalog program.l run Predicate # execute and print a table
|
|
144
151
|
synalog program.l run Predicate --csv # execute and print CSV
|
|
152
|
+
synalog program.l verify # check the @Assert statements against the data
|
|
145
153
|
```
|
|
146
154
|
|
|
147
|
-
|
|
155
|
+
`print`, `run` and `verify` validate the whole program first and exit 1 with the verifier's errors if it is invalid, so verification always happens before any SQL is produced or executed. `run` also checks the program's [assertions](#assertions) against the database, and exits 1 with a few counterexamples if one is violated; `print` stays offline.
|
|
148
156
|
|
|
149
157
|
```
|
|
150
158
|
$ synalog program.l run EngineeringTeam
|
|
@@ -281,7 +289,25 @@ if errors:
|
|
|
281
289
|
print(e)
|
|
282
290
|
```
|
|
283
291
|
|
|
284
|
-
|
|
292
|
+
### `assertions(source, engine=None, import_root=None) -> list[dict]`
|
|
293
|
+
|
|
294
|
+
Every `@Assert` of the program and where it stands, in source order: `predicate`, `name`, `statement` and `status` (`pending`, `unchecked` or `unsupported`), among other keys.
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
for a in synalog.assertions(source):
|
|
298
|
+
print(f"{a['predicate']}.{a['name']}: {a['status']}")
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### `counterexamples(source, predicate, name, limit=None, offset=None, engine=None, import_root=None) -> str`
|
|
302
|
+
|
|
303
|
+
Compile the search for an assertion's counterexamples to SQL, to run anywhere. The assertion holds on a database when the query returns no row there.
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
sql = synalog.counterexamples(source, "Revenue", "known_customer", limit=5)
|
|
307
|
+
rows = duckdb.sql(sql).fetchall() # [] when the assertion holds
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
All of these functions accept an optional `engine` keyword that overrides the program's `@Engine` annotation (one of `sqlite`, `duckdb`, `bigquery`, `psql`, `presto`, `trino`, `databricks`, `clickhouse`, `mysql`; default `duckdb`) and an optional `import_root` keyword listing directories where `import` statements look up `.l` files (default: the current directory). They raise `ValueError` on syntax or compilation errors.
|
|
285
311
|
|
|
286
312
|
## Language overview
|
|
287
313
|
|
|
@@ -546,6 +572,52 @@ CurrentEmployment(person_id:, company_id:, role:) distinct :-
|
|
|
546
572
|
|
|
547
573
|
Node and edge patterns, temporal modeling, point-in-time queries and time-respecting traversals are covered in [Knowledge graphs](https://synalinks.github.io/synalog/knowledge-graphs/).
|
|
548
574
|
|
|
575
|
+
### Assertions
|
|
576
|
+
|
|
577
|
+
A rule says how to compute a predicate; an assertion says what the result must satisfy. `@Assert` takes the predicate, then one named property per argument, each a first-order statement written as a [Lean](https://lean-lang.org/) proposition. In a statement, predicates take their arguments by position, as in Lean: applied to all its columns, `Revenue c r` is a relation, true when that row exists; applied to all but the last, `Revenue c` is a function returning the last column.
|
|
578
|
+
|
|
579
|
+
```synalog
|
|
580
|
+
Order(order_id:, customer_id:, amount:, status:) :- orders(order_id:, customer_id:, amount:, status:);
|
|
581
|
+
Customer(customer_id:, country:) :- customers(customer_id:, country:);
|
|
582
|
+
|
|
583
|
+
@Assert(Revenue,
|
|
584
|
+
one_row_per_customer: "∀ c r s, Revenue c r → Revenue c s → r = s",
|
|
585
|
+
known_customer: "∀ c r, Revenue c r → ∃ k, Customer c k",
|
|
586
|
+
positive: "∀ c, Revenue c > 0");
|
|
587
|
+
@OrderBy(Revenue, "customer_id");
|
|
588
|
+
Revenue(customer_id:, revenue? += amount) distinct :-
|
|
589
|
+
Order(customer_id:, amount:, status: "delivered");
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
Synalog compiles each statement into a search for its counterexamples, runs it on the database like any predicate, and reports the rows that break it. Here the data holds an order from customer 12, who is not in `customers`:
|
|
593
|
+
|
|
594
|
+
```
|
|
595
|
+
$ synalog shop.l verify
|
|
596
|
+
✓ Revenue.one_row_per_customer holds
|
|
597
|
+
✗ Revenue.known_customer is violated: ∀ c r, Revenue c r → ∃ k, Customer c k
|
|
598
|
+
1 counterexample:
|
|
599
|
+
+----+----+
|
|
600
|
+
| c | r |
|
|
601
|
+
+----+----+
|
|
602
|
+
| 12 | 20 |
|
|
603
|
+
+----+----+
|
|
604
|
+
1 row
|
|
605
|
+
✓ Revenue.positive holds
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
`run` refuses the program until the rule or the assertion is fixed. Every symbol has an ASCII spelling (`forall`, `exists`, `->`, `/\`, `\/`, `not`, `<=`, `!=`), and `∑ x, t` (`sum x, t`) states totals, such as `∑ c, Share c = 1`.
|
|
609
|
+
|
|
610
|
+
| Property | Statement | Catches |
|
|
611
|
+
|---|---|---|
|
|
612
|
+
| A key | `∀ c r s, Revenue c r → Revenue c s → r = s` | a join that duplicates rows, a missing `distinct` |
|
|
613
|
+
| A reference | `∀ c r, Revenue c r → ∃ k, Customer c k` | orphan rows, a filter applied on one side only |
|
|
614
|
+
| A bound | `∀ c, 0 ≤ Share c ∧ Share c ≤ 1` | a wrong denominator, an integer division |
|
|
615
|
+
| A total | `∑ c, Share c = 1` | rows lost or counted twice |
|
|
616
|
+
| Transitivity | `∀ x y z, Ancestor x y → Ancestor y z → Ancestor x z` | a recursion that stops too early |
|
|
617
|
+
| A period | `∀ p t f u, MemberOf p t f u → f < u` | an interval closed before it opens |
|
|
618
|
+
|
|
619
|
+
An assertion is a check on the data it runs on, not a proof for all data: one that holds has no counterexample *there*. Run assertions on representative data. The statement language, what can be checked and the statuses are in [Assertions](https://synalinks.github.io/synalog/assertions/).
|
|
620
|
+
|
|
549
621
|
### Built-in functions
|
|
550
622
|
|
|
551
623
|
**String:** `Substr`, `Length`, `Upper`, `Lower`, `Split`, `Join`, `Like`, `Format`
|
|
@@ -571,6 +643,8 @@ Node and edge patterns, temporal modeling, point-in-time queries and time-respec
|
|
|
571
643
|
| Trino | `trino` | |
|
|
572
644
|
| Presto | `presto` | |
|
|
573
645
|
| Databricks | `databricks` | Double-quoted string literals |
|
|
646
|
+
| ClickHouse | `clickhouse` | 26.3 or later; a list is never null |
|
|
647
|
+
| MySQL | `mysql` | 8.4 or later; lists and records are JSON |
|
|
574
648
|
|
|
575
649
|
Each engine has its own SQL dialect for string literals, array syntax, GROUP BY style, record construction, regex matching, and standard library functions.
|
|
576
650
|
|
|
@@ -632,6 +706,10 @@ Synalog applies pagination at compile time via the `limit` and `offset` argument
|
|
|
632
706
|
|
|
633
707
|
Synalog embeds a formal verifier that catches structural errors before any SQL is generated. This prevents agents from producing programs that parse correctly but fail at execution time, a common failure mode when working with SQL directly.
|
|
634
708
|
|
|
709
|
+
### Assertions, new in Synalog
|
|
710
|
+
|
|
711
|
+
Neither Datalog nor Logica has them. `@Assert` states, as a Lean proposition, what a predicate must satisfy, and Synalog checks it against the data by searching for counterexamples. The verifier catches a rule that is malformed; an assertion catches a rule that is well-formed but computes the wrong thing. See [Assertions](#assertions).
|
|
712
|
+
|
|
635
713
|
## Building from source
|
|
636
714
|
|
|
637
715
|
The project uses [maturin](https://www.maturin.rs/) to build the Python wheel from the Rust crate.
|
|
@@ -39,9 +39,10 @@ A raw table is just rows; an agent has to re-interpret what they *mean* on every
|
|
|
39
39
|
- **Dynamic, not static**: the layer evolves as the agent learns. New rules extend the vocabulary at runtime; the rule base itself becomes the agent's long-term memory over structured data.
|
|
40
40
|
- **Auditable reasoning**: every derived fact traces back through named rules, giving full lineage from answer to source tables.
|
|
41
41
|
- **Compile-time verification**: a formal verifier catches structural errors before any SQL touches a database, so a self-authored rule that parses but is unsound is rejected up front. See [Verification](https://synalinks.github.io/synalog/verification/).
|
|
42
|
+
- **Assertions in Lean, checked against the data**: state what a predicate must satisfy (a key, a reference, a bound, a total, transitivity) as a first-order statement written as a [Lean](https://lean-lang.org/) proposition, such as `∀ c r s, Revenue c r → Revenue c s → r = s`. Synalog compiles the search for counterexamples to SQL and runs it on the database: `run` refuses a program whose assertions are violated, and `verify` prints the rows that break them. The rule and its assertion state the same intent in two different notations, so a mistake made in one is unlikely to be repeated in the other. That makes assertions the contract an agent states first and writes its rules against. See [Assertions](#assertions).
|
|
42
43
|
- **A fast Rust engine**: check and compile sit inside the agent's inner loop (every generated rule is validated, every query compiled, often several times per step). The Rust core makes that loop cost milliseconds instead of seconds. See [Benchmark](https://synalinks.github.io/synalog/benchmark/).
|
|
43
44
|
|
|
44
|
-
Because SQL engines are better optimized than logic programming engines, Synalog compiles into *optimized SQL* that runs on **SQLite**, **DuckDB**, **BigQuery**, **PostgreSQL**, **Presto**, **Trino** and **
|
|
45
|
+
Because SQL engines are better optimized than logic programming engines, Synalog compiles into *optimized SQL* that runs on **SQLite**, **DuckDB**, **BigQuery**, **PostgreSQL**, **Presto**, **Trino**, **Databricks**, **ClickHouse** and **MySQL**: efficiently scaling to *petabytes of data*. See [Supported engines](https://synalinks.github.io/synalog/engines/).
|
|
45
46
|
|
|
46
47
|
Full documentation: **<https://synalinks.github.io/synalog/>**
|
|
47
48
|
|
|
@@ -100,9 +101,10 @@ Installing the package also installs a `synalog` command (also available as `pyt
|
|
|
100
101
|
synalog program.l print Predicate # print compiled SQL
|
|
101
102
|
synalog program.l run Predicate # execute and print a table
|
|
102
103
|
synalog program.l run Predicate --csv # execute and print CSV
|
|
104
|
+
synalog program.l verify # check the @Assert statements against the data
|
|
103
105
|
```
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
`print`, `run` and `verify` validate the whole program first and exit 1 with the verifier's errors if it is invalid, so verification always happens before any SQL is produced or executed. `run` also checks the program's [assertions](#assertions) against the database, and exits 1 with a few counterexamples if one is violated; `print` stays offline.
|
|
106
108
|
|
|
107
109
|
```
|
|
108
110
|
$ synalog program.l run EngineeringTeam
|
|
@@ -239,7 +241,25 @@ if errors:
|
|
|
239
241
|
print(e)
|
|
240
242
|
```
|
|
241
243
|
|
|
242
|
-
|
|
244
|
+
### `assertions(source, engine=None, import_root=None) -> list[dict]`
|
|
245
|
+
|
|
246
|
+
Every `@Assert` of the program and where it stands, in source order: `predicate`, `name`, `statement` and `status` (`pending`, `unchecked` or `unsupported`), among other keys.
|
|
247
|
+
|
|
248
|
+
```python
|
|
249
|
+
for a in synalog.assertions(source):
|
|
250
|
+
print(f"{a['predicate']}.{a['name']}: {a['status']}")
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### `counterexamples(source, predicate, name, limit=None, offset=None, engine=None, import_root=None) -> str`
|
|
254
|
+
|
|
255
|
+
Compile the search for an assertion's counterexamples to SQL, to run anywhere. The assertion holds on a database when the query returns no row there.
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
sql = synalog.counterexamples(source, "Revenue", "known_customer", limit=5)
|
|
259
|
+
rows = duckdb.sql(sql).fetchall() # [] when the assertion holds
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
All of these functions accept an optional `engine` keyword that overrides the program's `@Engine` annotation (one of `sqlite`, `duckdb`, `bigquery`, `psql`, `presto`, `trino`, `databricks`, `clickhouse`, `mysql`; default `duckdb`) and an optional `import_root` keyword listing directories where `import` statements look up `.l` files (default: the current directory). They raise `ValueError` on syntax or compilation errors.
|
|
243
263
|
|
|
244
264
|
## Language overview
|
|
245
265
|
|
|
@@ -504,6 +524,52 @@ CurrentEmployment(person_id:, company_id:, role:) distinct :-
|
|
|
504
524
|
|
|
505
525
|
Node and edge patterns, temporal modeling, point-in-time queries and time-respecting traversals are covered in [Knowledge graphs](https://synalinks.github.io/synalog/knowledge-graphs/).
|
|
506
526
|
|
|
527
|
+
### Assertions
|
|
528
|
+
|
|
529
|
+
A rule says how to compute a predicate; an assertion says what the result must satisfy. `@Assert` takes the predicate, then one named property per argument, each a first-order statement written as a [Lean](https://lean-lang.org/) proposition. In a statement, predicates take their arguments by position, as in Lean: applied to all its columns, `Revenue c r` is a relation, true when that row exists; applied to all but the last, `Revenue c` is a function returning the last column.
|
|
530
|
+
|
|
531
|
+
```synalog
|
|
532
|
+
Order(order_id:, customer_id:, amount:, status:) :- orders(order_id:, customer_id:, amount:, status:);
|
|
533
|
+
Customer(customer_id:, country:) :- customers(customer_id:, country:);
|
|
534
|
+
|
|
535
|
+
@Assert(Revenue,
|
|
536
|
+
one_row_per_customer: "∀ c r s, Revenue c r → Revenue c s → r = s",
|
|
537
|
+
known_customer: "∀ c r, Revenue c r → ∃ k, Customer c k",
|
|
538
|
+
positive: "∀ c, Revenue c > 0");
|
|
539
|
+
@OrderBy(Revenue, "customer_id");
|
|
540
|
+
Revenue(customer_id:, revenue? += amount) distinct :-
|
|
541
|
+
Order(customer_id:, amount:, status: "delivered");
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Synalog compiles each statement into a search for its counterexamples, runs it on the database like any predicate, and reports the rows that break it. Here the data holds an order from customer 12, who is not in `customers`:
|
|
545
|
+
|
|
546
|
+
```
|
|
547
|
+
$ synalog shop.l verify
|
|
548
|
+
✓ Revenue.one_row_per_customer holds
|
|
549
|
+
✗ Revenue.known_customer is violated: ∀ c r, Revenue c r → ∃ k, Customer c k
|
|
550
|
+
1 counterexample:
|
|
551
|
+
+----+----+
|
|
552
|
+
| c | r |
|
|
553
|
+
+----+----+
|
|
554
|
+
| 12 | 20 |
|
|
555
|
+
+----+----+
|
|
556
|
+
1 row
|
|
557
|
+
✓ Revenue.positive holds
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
`run` refuses the program until the rule or the assertion is fixed. Every symbol has an ASCII spelling (`forall`, `exists`, `->`, `/\`, `\/`, `not`, `<=`, `!=`), and `∑ x, t` (`sum x, t`) states totals, such as `∑ c, Share c = 1`.
|
|
561
|
+
|
|
562
|
+
| Property | Statement | Catches |
|
|
563
|
+
|---|---|---|
|
|
564
|
+
| A key | `∀ c r s, Revenue c r → Revenue c s → r = s` | a join that duplicates rows, a missing `distinct` |
|
|
565
|
+
| A reference | `∀ c r, Revenue c r → ∃ k, Customer c k` | orphan rows, a filter applied on one side only |
|
|
566
|
+
| A bound | `∀ c, 0 ≤ Share c ∧ Share c ≤ 1` | a wrong denominator, an integer division |
|
|
567
|
+
| A total | `∑ c, Share c = 1` | rows lost or counted twice |
|
|
568
|
+
| Transitivity | `∀ x y z, Ancestor x y → Ancestor y z → Ancestor x z` | a recursion that stops too early |
|
|
569
|
+
| A period | `∀ p t f u, MemberOf p t f u → f < u` | an interval closed before it opens |
|
|
570
|
+
|
|
571
|
+
An assertion is a check on the data it runs on, not a proof for all data: one that holds has no counterexample *there*. Run assertions on representative data. The statement language, what can be checked and the statuses are in [Assertions](https://synalinks.github.io/synalog/assertions/).
|
|
572
|
+
|
|
507
573
|
### Built-in functions
|
|
508
574
|
|
|
509
575
|
**String:** `Substr`, `Length`, `Upper`, `Lower`, `Split`, `Join`, `Like`, `Format`
|
|
@@ -529,6 +595,8 @@ Node and edge patterns, temporal modeling, point-in-time queries and time-respec
|
|
|
529
595
|
| Trino | `trino` | |
|
|
530
596
|
| Presto | `presto` | |
|
|
531
597
|
| Databricks | `databricks` | Double-quoted string literals |
|
|
598
|
+
| ClickHouse | `clickhouse` | 26.3 or later; a list is never null |
|
|
599
|
+
| MySQL | `mysql` | 8.4 or later; lists and records are JSON |
|
|
532
600
|
|
|
533
601
|
Each engine has its own SQL dialect for string literals, array syntax, GROUP BY style, record construction, regex matching, and standard library functions.
|
|
534
602
|
|
|
@@ -590,6 +658,10 @@ Synalog applies pagination at compile time via the `limit` and `offset` argument
|
|
|
590
658
|
|
|
591
659
|
Synalog embeds a formal verifier that catches structural errors before any SQL is generated. This prevents agents from producing programs that parse correctly but fail at execution time, a common failure mode when working with SQL directly.
|
|
592
660
|
|
|
661
|
+
### Assertions, new in Synalog
|
|
662
|
+
|
|
663
|
+
Neither Datalog nor Logica has them. `@Assert` states, as a Lean proposition, what a predicate must satisfy, and Synalog checks it against the data by searching for counterexamples. The verifier catches a rule that is malformed; an assertion catches a rule that is well-formed but computes the wrong thing. See [Assertions](#assertions).
|
|
664
|
+
|
|
593
665
|
## Building from source
|
|
594
666
|
|
|
595
667
|
The project uses [maturin](https://www.maturin.rs/) to build the Python wheel from the Rust crate.
|
|
@@ -95,7 +95,7 @@ $ synalog totals.l run Total --load sales=sales.csv
|
|
|
95
95
|
2 rows
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
duckdb and the PostgreSQL driver ship with synalog. For the other engines (`bigquery`, `trino`, `presto`, `databricks`), install their driver (`pip install 'synalog[trino]'`, ...) or use `print` and run the SQL with your own client.
|
|
98
|
+
duckdb and the PostgreSQL driver ship with synalog. For the other engines (`bigquery`, `trino`, `presto`, `databricks`, `clickhouse`, `mysql`), install their driver (`pip install 'synalog[trino]'`, ...) or use `print` and run the SQL with your own client.
|
|
99
99
|
|
|
100
100
|
### Imports
|
|
101
101
|
|
|
@@ -58,7 +58,7 @@ shell/test.sh e2e # end-to-end tests against live SQL engines
|
|
|
58
58
|
shell/test.sh quick # unit + parser golden (no SQL compilation)
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
Python steps run through `uv run`, so the project virtualenv supplies pytest and the engine drivers. The `e2e` step builds the extension into the venv and starts the server engines (PostgreSQL, Trino, Presto,
|
|
61
|
+
Python steps run through `uv run`, so the project virtualenv supplies pytest and the engine drivers. The `e2e` step builds the extension into the venv and starts the server engines (PostgreSQL, Trino, Presto, a Spark Thrift Server standing in for Databricks, ClickHouse and MySQL) itself via Docker Compose. A test known to fail on an engine, by a limitation of the engine, is listed with its reason in `tests/e2e/known_failures.py`, as a strict xfail.
|
|
62
62
|
|
|
63
63
|
`SYNALOG_E2E_ENGINES` runs the end-to-end tests of some engines only, a comma list (`SYNALOG_E2E_ENGINES=psql,trino uv run pytest tests/e2e`); CI runs each engine in a job of its own this way, in parallel, starting only that engine's server. `SYNALOG_E2E_SHARD=2/3` runs the second third of the selected tests, split by fixture: CI splits Trino, Presto and Spark, whose every query pays a fixed cost, into three jobs each.
|
|
64
64
|
|
|
@@ -73,6 +73,8 @@ cd tests/parser_tests && python3 generate_expected_json.py
|
|
|
73
73
|
|
|
74
74
|
Requires `pip install logica`.
|
|
75
75
|
|
|
76
|
+
Upstream Logica has no ClickHouse or MySQL dialect: their goldens are synalog's own. `SYNALOG_BLESS=clickhouse,mysql cargo test --test compiler_tests` writes them (a comma list of engines, or `all`), then review the diff and run the e2e suite.
|
|
77
|
+
|
|
76
78
|
## Project structure
|
|
77
79
|
|
|
78
80
|
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Supported engines
|
|
2
|
+
|
|
3
|
+
Synalog compiles to nine SQL dialects. Select the target with the `@Engine` annotation in the program, or override it with the `engine` keyword of any [Python API](python-api.md) function.
|
|
4
|
+
|
|
5
|
+
| Engine | `@Engine` value | Notes |
|
|
6
|
+
|--------|-----------------|-------|
|
|
7
|
+
| DuckDB | `duckdb` | Default engine |
|
|
8
|
+
| SQLite | `sqlite` | |
|
|
9
|
+
| PostgreSQL | `psql` | |
|
|
10
|
+
| BigQuery | `bigquery` | |
|
|
11
|
+
| Trino | `trino` | |
|
|
12
|
+
| Presto | `presto` | |
|
|
13
|
+
| Databricks | `databricks` | Double-quoted string literals |
|
|
14
|
+
| ClickHouse | `clickhouse` | 26.3 or later; a list is never null |
|
|
15
|
+
| MySQL | `mysql` | 8.4 or later; lists and records are JSON |
|
|
16
|
+
|
|
17
|
+
```synalog
|
|
18
|
+
@Engine("psql");
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
# Or override per call:
|
|
23
|
+
sql = synalog.compile(source, "TopCustomers", engine="bigquery")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What differs per dialect
|
|
27
|
+
|
|
28
|
+
Each engine has its own SQL generation for:
|
|
29
|
+
|
|
30
|
+
- string literals and escaping,
|
|
31
|
+
- array syntax and array functions,
|
|
32
|
+
- `GROUP BY` style,
|
|
33
|
+
- record/struct construction,
|
|
34
|
+
- regex matching,
|
|
35
|
+
- standard library function names and arities.
|
|
36
|
+
|
|
37
|
+
Synalog handles these differences in the compiler, so the same program compiles for every engine. The portable subset of the language is the whole language, with one caveat: a few standard library functions have no equivalent on some engines (for example, Presto has no printf-style `Format` function). The compiler maps what it can; genuinely missing functions fail on the engine at execution time.
|
|
38
|
+
|
|
39
|
+
## ClickHouse
|
|
40
|
+
|
|
41
|
+
Synalog needs ClickHouse 26.3 (the LTS release) or later: earlier releases decorrelate too few subqueries for aggregating subqueries (`combine`). Each script opens with the session settings it needs (`join_use_nulls`, correlated subqueries, an aggregate of no rows being null, `cast_keep_nullable`, `transform_null_in`), so run its statements in one session, as `synalog … run` does. Records compile to named tuples, an unnesting to `ARRAY JOIN`, tables to `ENGINE = Memory`, and a recursion iterates through tables, as on Trino.
|
|
42
|
+
|
|
43
|
+
ClickHouse decorrelates a subquery into a join that drops a null key, `IS NOT DISTINCT FROM` included, so a negation tied to its rule by equalities (`~P(x)`, and the step of a semi-naive recursion) compiles to an uncorrelated membership instead: `(keys) NOT IN (SELECT ...)`, the keys compared as text so that a null key matches a null one where `is` says so. A negation of conditions only (`~IsNull(x)`) is their negation.
|
|
44
|
+
|
|
45
|
+
What ClickHouse cannot express:
|
|
46
|
+
|
|
47
|
+
- A list is never null (`Nullable(Array)` does not exist): a null list is an empty one, so its `Size` is 0 and a `List` of no rows is `[]`.
|
|
48
|
+
- A subquery correlated to the outer row other than by equalities (`combine += 1 :- T(v: w), w > v`) is not supported, and where ClickHouse runs one it can count wrongly; nor is one in an `ORDER BY` or in an aggregate's argument.
|
|
49
|
+
|
|
50
|
+
These are listed, with the tests they fail, in `tests/e2e/known_failures.py`.
|
|
51
|
+
|
|
52
|
+
## MySQL
|
|
53
|
+
|
|
54
|
+
Synalog needs MySQL 8.4 (the LTS release) or later: `EXCEPT`, `LATERAL` and `JSON_TABLE` are used throughout. Each script opens with the session settings it needs, so run its statements in one session, as `synalog … run` does:
|
|
55
|
+
|
|
56
|
+
- `sql_mode` `ANSI_QUOTES,PIPES_AS_CONCAT,NO_BACKSLASH_ESCAPES`: standard SQL, where `"` quotes an identifier, `||` concatenates and a backslash is a character of a string.
|
|
57
|
+
- `derived_condition_pushdown=off`: MySQL pushes a condition into a derived table by reprinting it with backslash escapes, which ends a literal holding a quote (`'a''b'`) early under `NO_BACKSLASH_ESCAPES`.
|
|
58
|
+
- `utf8mb4_0900_bin`, a collation of no padding: texts compare by their characters, case and trailing spaces included, as on every engine. A column of your own tables keeps its collation in a comparison (a case-insensitive one compares so).
|
|
59
|
+
- `group_concat_max_len`: an ordered aggregate (`Set`, `Array`, `ArgMax`) joins its values in a text longer than the default 1 KiB.
|
|
60
|
+
|
|
61
|
+
MySQL has no arrays nor records: a list compiles to a JSON array, a record to a JSON object, and a value read out of one is cast to the type the compiler infers for it. An unnesting is `JSON_TABLE` in a `LATERAL` derived table, an ordered aggregate `GROUP_CONCAT` of the values' JSON. `Median` is not available.
|
|
62
|
+
|
|
63
|
+
## Scaling
|
|
64
|
+
|
|
65
|
+
Because the heavy lifting is done by the SQL engine, Synalog inherits its performance characteristics: in-process analytics with DuckDB, embedded with SQLite, warehouse-scale with BigQuery, Trino, Presto, Databricks, ClickHouse or MySQL, efficiently scaling to petabytes of data.
|
|
@@ -195,7 +195,7 @@ The target SQL dialect is set with the `@Engine` annotation in the program, or o
|
|
|
195
195
|
sql = synalog.compile(source, "EngineeringTeam", engine="psql")
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
Valid engines: `sqlite`, `duckdb` (default), `bigquery`, `psql`, `presto`, `trino`, `databricks`. See [Supported engines](engines.md).
|
|
198
|
+
Valid engines: `sqlite`, `duckdb` (default), `bigquery`, `psql`, `presto`, `trino`, `databricks`, `clickhouse`, `mysql`. See [Supported engines](engines.md).
|
|
199
199
|
|
|
200
200
|
## Complete example
|
|
201
201
|
|
|
@@ -22,7 +22,7 @@ A raw table is just rows; an agent has to re-interpret what they *mean* on every
|
|
|
22
22
|
- **Auditable reasoning**: every derived fact traces back through named rules, giving full lineage from answer to source tables.
|
|
23
23
|
- **Compile-time verification**: a formal verifier catches structural errors before any SQL touches a database, so a self-authored rule that parses but is unsound is rejected up front. See [Verification](verification.md).
|
|
24
24
|
|
|
25
|
-
Because SQL engines are better optimized than logic programming engines, Synalog compiles into *optimized SQL* that runs on **SQLite**, **DuckDB**, **BigQuery**, **PostgreSQL**, **Presto**, **Trino** and **
|
|
25
|
+
Because SQL engines are better optimized than logic programming engines, Synalog compiles into *optimized SQL* that runs on **SQLite**, **DuckDB**, **BigQuery**, **PostgreSQL**, **Presto**, **Trino**, **Databricks**, **ClickHouse** and **MySQL**, efficiently scaling to *petabytes of data*. See [Supported engines](engines.md).
|
|
26
26
|
|
|
27
27
|
## At a glance
|
|
28
28
|
|
|
@@ -57,7 +57,7 @@ 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 (`CustomerRevenue`); a predicate named after an SQL keyword gets `_table` added (`Order_table`), since `Order` does not parse as a table name.
|
|
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 [plan](../python-api.md#plan) makes it its run's own: a temporary table on PostgreSQL, and on the engines whose schema other sessions see, a name ending with a tag unique to the run; a predicate named after an SQL keyword gets `_table` added (`Order_table`), since `Order` does not parse as a table name.
|
|
61
61
|
|
|
62
62
|
## `@Engine`
|
|
63
63
|
|
|
@@ -63,9 +63,9 @@ On DuckDB, SQLite and PostgreSQL, a recursion of one `distinct` predicate, witho
|
|
|
63
63
|
|
|
64
64
|
Other recursions, and every recursion on BigQuery, are unrolled into a single query up to 20 steps; past 20 steps, or with `@Recursive(P, -1)`, they are computed into tables, step by step. On Presto, Databricks and Trino every recursion is computed into tables (their recursive queries take `UNION ALL` only, whose rows multiply with the paths to them): the planners of Presto and Spark take time exponential in the number of unrolled steps (20 steps took minutes to plan on Presto, 12 on Spark), and Trino copies an unrolled recursion into every query that reads it, past its limit of stages when a query reads it several times. A table per step costs one short query each.
|
|
65
65
|
|
|
66
|
-
- **Until it converges.** When Synalog runs a predicate (`synalog ... run`, [`synalog.execute`](../python-api.md#execute)), it stops a recursion as soon as a step changes nothing. A recursion costs the steps its data needs: `@Recursive(AncestorOf, 100)` over a hierarchy 6 levels deep takes 6 steps, and `@Recursive(P, -1)` recurses until nothing changes, on every engine.
|
|
66
|
+
- **Until it converges.** When Synalog runs a predicate (`synalog ... run`, [`synalog.execute`](../python-api.md#execute)), it stops a recursion as soon as a step changes nothing. A recursion that is not `distinct` holds a multiset: a step that finds a row again changes how many times it occurs, so the recursion has converged only when every row occurs as many times as after the step before. A recursion costs the steps its data needs: `@Recursive(AncestorOf, 100)` over a hierarchy 6 levels deep takes 6 steps, and `@Recursive(P, -1)` recurses until nothing changes, on every engine. Over a cycle in the data, a recursion that is not `distinct` adds copies of rows at every step and never converges, so Synalog refuses `@Recursive(P, -1)` for it: make it `distinct`, or give it a depth.
|
|
67
67
|
- **One step, the new rows.** A recursion of one `distinct` predicate, without aggregation, whose rules reference it at most once (the transitive closures above) is evaluated semi-naively: each step derives rows only from the rows the previous step added, so a step costs what changed, not the whole relation. Other recursions (an aggregate such as `Min=` in the recursion, mutual recursion, a rule joining the recursion with itself) recompute the relation at every step.
|
|
68
|
-
- **No tables left behind.** The tables a run computes in Synalog's own
|
|
68
|
+
- **No tables left behind.** The tables a run computes in Synalog's own schema (`synalog_home`) are dropped once its rows are read. They are the run's own: temporary tables on PostgreSQL, an in-memory database of the session's on DuckDB and SQLite, and on Trino, Presto, Databricks and BigQuery tables whose names end with a tag unique to the run, so runs at once never share them.
|
|
69
69
|
- **A script.** [`synalog.compile`](../python-api.md#compile) returns one SQL script. A recursive query stops by itself; a recursion computed into tables cannot, so the script writes every step out, up to the declared depth, and refuses one too deep to write out. Run those with Synalog.
|
|
70
70
|
|
|
71
71
|
## Safety
|
|
@@ -45,7 +45,7 @@ Quote(a: 'say "hi"', b: """say "hi" there""", c: 'it\'s');
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
!!! danger "Never compare against null with `!=`"
|
|
48
|
-
`x != null` is silently broken (it follows SQL three-valued logic and never matches). Always use `x is null` / `x is not null
|
|
48
|
+
`x != null` is silently broken (it follows SQL three-valued logic and never matches). Always use `x is null` / `x is not null`; to compare two values with nulls matching, `x is y` / `x is not y` (see [Null handling](#null-handling)).
|
|
49
49
|
|
|
50
50
|
## Logical operators
|
|
51
51
|
|
|
@@ -98,7 +98,9 @@ HasEmail(user_id:, email:) :- Users(user_id:, email:), email is not null;
|
|
|
98
98
|
UserDisplay(user_id:, name:) :- Users(user_id:, full_name:), name == Coalesce(full_name, "Anonymous");
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Nulls follow SQL: a null equals nothing, another null included. A join on a column finds no row where the key is null (`A(k:), B(k:)` with both `k` null), neither does a negation (`~B(k:)` holds), and `x == x` does not hold where `x` is null.
|
|
102
|
+
|
|
103
|
+
To compare two values as values, nulls included, use `is` and `is not`: `x is y` holds where both are null or both are equal, and `x is not y` is its negation. Null keys meet with `A(k:), B(k: j), k is j`, and a negation finds a null key with `~(B(k: j), j is k)`. It compiles to `IS NOT DISTINCT FROM` (`IS` on SQLite, `<=>` on Databricks); SQL's `=` remains faster where a null need not match, since an engine can use an index for it.
|
|
102
104
|
|
|
103
105
|
## Conditionals
|
|
104
106
|
|
|
@@ -156,6 +156,7 @@ columns, rows = synalog.execute(source, "TopCustomers", limit=20)
|
|
|
156
156
|
- `pattern` keeps the rows where some column matches it, as [`search`](#search); `limit`/`offset` paginate as in `compile`.
|
|
157
157
|
- `assertion` returns the counterexamples of the assertion of that name of `predicate` instead of its rows.
|
|
158
158
|
- `loads` is a sequence of `(table, path)` pairs: csv/tsv/json/jsonl/parquet files loaded as tables first (duckdb and sqlite).
|
|
159
|
+
- On PostgreSQL the plan runs in one `REPEATABLE READ` transaction, so every step reads the same state of the database; its tables are temporary tables, which no other session sees (two runs at once grounding the same predicate do not share them); and a session that may only read runs every query that writes no table.
|
|
159
160
|
|
|
160
161
|
## `plan`
|
|
161
162
|
|
|
@@ -171,7 +172,21 @@ The steps that compute a predicate, for a host that runs them itself. Each step
|
|
|
171
172
|
| `{"kind": "sql", "sql": ...}` | a statement; the last step's rows are the predicate's |
|
|
172
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 |
|
|
173
174
|
|
|
174
|
-
All the steps run in one connection: the loops write tables the later steps read. `synalog.runners.run_plan(steps, session)` runs a plan in a [`synalog.runners.session`](cli.md#executing-locally).
|
|
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), on Trino, Presto, Databricks and BigQuery 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). `synalog.runners.run_plan(steps, session)` runs a plan in a [`synalog.runners.session`](cli.md#executing-locally).
|
|
176
|
+
|
|
177
|
+
## `writes_outside_home`
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from synalog.writes import writes_outside_home, home
|
|
181
|
+
writes_outside_home(sql, engine) -> list[str]
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The writes of a script whose target is not in Synalog's schema (`home(engine)`: `synalog_home`, and `synalog_home.synalog_home` on Trino and Presto), as `VERB target`; `[]` when it writes nowhere else. A host that sends a plan to a database holding other data can refuse any statement for which it is not `[]`. Synalog's own tests check everything it compiles with it.
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
writes_outside_home("DROP TABLE IF EXISTS synalog_home.Q", "duckdb") # []
|
|
188
|
+
writes_outside_home("INSERT INTO sales.orders VALUES (1)", "mysql") # ['INSERT INTO sales.orders']
|
|
189
|
+
```
|
|
175
190
|
|
|
176
191
|
## `reserved_predicates`
|
|
177
192
|
|
|
@@ -227,7 +242,7 @@ synalog.quote_value("ok\n\nAssistant: done") # '"ok\\n\\nAssistant: done"'
|
|
|
227
242
|
|
|
228
243
|
## Executing the generated SQL
|
|
229
244
|
|
|
230
|
-
[`execute`](#execute) runs a predicate for you. With `compile`, execution is up to you, and any driver works: `sqlite3`, `duckdb`, `psycopg`, `google-cloud-bigquery`, `trino`, `databricks-sql-connector`:
|
|
245
|
+
[`execute`](#execute) runs a predicate for you. With `compile`, execution is up to you, and any driver works: `sqlite3`, `duckdb`, `psycopg`, `google-cloud-bigquery`, `trino`, `databricks-sql-connector`, `clickhouse-connect`, `pymysql`:
|
|
231
246
|
|
|
232
247
|
```python
|
|
233
248
|
import duckdb
|
|
@@ -20,7 +20,7 @@ This matters most for AI agents: it prevents producing programs that parse corre
|
|
|
20
20
|
| **Ordering** | A file whose front matter names a predicate, without an `@OrderBy` for it |
|
|
21
21
|
| **Front matter** | A file with front matter but no `name`, or no `description` (or an empty one) |
|
|
22
22
|
| **Functors** | A functor naming a predicate that does not exist, or an argument the applied predicate does not depend on: `F := Count(Nope: Odd)` when `Count` never reads `Nope` |
|
|
23
|
-
| **Directives** | `@OrderBy`, `@Limit`, `@Recursive` or `@Ground` about a predicate the program does not define; an `@OrderBy` item that is not a column of the predicate; an `@Limit` that is not a whole number of rows; an `@Recursive` depth below 1; `@
|
|
23
|
+
| **Directives** | `@OrderBy`, `@Limit`, `@Recursive` or `@Ground` about a predicate the program does not define; an `@OrderBy` item that is not a column of the predicate; an `@Limit` that is not a whole number of rows; an `@Recursive` depth below 1; `@Ground` with `copy_to_file`: a program writes no file; `FlagValue("name")` of a flag no `@DefineFlag` defines |
|
|
24
24
|
| **Assertions** | An `@Assert` statement that does not parse or contradicts the program, an assertion stated twice |
|
|
25
25
|
| **Tables** | A database table read anywhere but in its declaration, the rule whose body is that table alone (`Orders(id:) :- orders(id:);`): `~orders(id:)`, or a join or a filter on `orders(...)`, is refused; the rest of the program reads the predicate that declares it |
|
|
26
26
|
| **Undefined function** | A call of a function neither defined in the program nor built in (`Substrr(s, 1, 2)`), with the closest name when one is near |
|
|
@@ -67,12 +67,14 @@ A program's text reaches SQL only as values or as checked names, so no string ca
|
|
|
67
67
|
|
|
68
68
|
- every string (a fact, a pattern for `Like` or `search`, a `Format`) is a literal in the engine's own escapes; on Databricks and BigQuery, whose literals take backslash escapes, a quote of the value is written `\u0022`, so a literal holds no quote but its own two, and whatever splits a script into statements finds its end;
|
|
69
69
|
- on PostgreSQL, a string with a backslash is an `E'...'` literal, read the same whatever `standard_conforming_strings` says;
|
|
70
|
-
- names (predicates, columns, fields) are identifiers, quoted when they are keywords; `@OrderBy` takes columns, `@Limit` a number
|
|
70
|
+
- names (predicates, columns, fields) are identifiers, quoted when they are keywords; `@OrderBy` takes columns, `@Limit` a number: anything else is refused;
|
|
71
71
|
- `Cast(expr, "TYPE")` pastes `TYPE` into the query unquoted; only a plain type name (`TEXT`, `DECIMAL(38, 2)`, `ARRAY<INT64>`) is accepted, nothing that could end the cast or add a statement;
|
|
72
72
|
- `SqlExpr`, raw SQL, is refused in a program, and so is a table name that is not one: a table the program reads is a dotted path of names, or one in backticks whose parts may hold any letter, spaces and ``-'&#@+%:()`` (`` `my-project.sales.Ventes (2024)` ``), each part quoted for the engine — never what could end the quoting (`"`, a backtick, `\`), make a path or a URL (`/`, `*`, `?`) or name a variable (`$`); on Databricks, where Spark reads `format.path` as a file (`text.secret`), a two-part name whose first part is a file format (`text`, `csv`, `json`, `parquet`, ...) is refused: such a table is named with its catalog;
|
|
73
73
|
- `${...}` in a string is text, also on Databricks, whose Spark substitutes `${var}` in a statement's text before parsing it (`${env:HOME}`): there a dollar in a string is written `\u0024`, and a name holds none; a flag is read with `FlagValue("name")`, which gives its value as a string;
|
|
74
|
-
- a program reaches no file, process or service: there is no `ReadFile`, `WriteFile` or `Intelligence`, no
|
|
75
|
-
- a
|
|
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
|
+
- 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
|
+
|
|
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.
|
|
76
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
|
|
|
@@ -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`).
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "synalog"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.5.1"
|
|
8
8
|
description = "Logic programming for AI agents: Datalog-family language compiling to optimized SQL"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -52,12 +52,16 @@ trino = ["trino"]
|
|
|
52
52
|
presto = ["presto-python-client"]
|
|
53
53
|
databricks = ["databricks-sql-connector"]
|
|
54
54
|
bigquery = ["google-cloud-bigquery"]
|
|
55
|
+
clickhouse = ["clickhouse-connect"]
|
|
56
|
+
mysql = ["pymysql"]
|
|
55
57
|
# Every engine driver at once.
|
|
56
58
|
all-engines = [
|
|
57
59
|
"trino",
|
|
58
60
|
"presto-python-client",
|
|
59
61
|
"databricks-sql-connector",
|
|
60
62
|
"google-cloud-bigquery",
|
|
63
|
+
"clickhouse-connect",
|
|
64
|
+
"pymysql",
|
|
61
65
|
]
|
|
62
66
|
|
|
63
67
|
[dependency-groups]
|
|
@@ -65,9 +69,9 @@ all-engines = [
|
|
|
65
69
|
# provides the sqlite runtime UDFs), benchmarks (logica, matplotlib), docs
|
|
66
70
|
# (zensical builds the site, duckdb runs the examples). The remote-engine
|
|
67
71
|
# drivers let the e2e suite reach the docker-compose servers instead of
|
|
68
|
-
# skipping them: psycopg→PostgreSQL, trino→Trino, presto→Presto,
|
|
72
|
+
# skipping them: psycopg→PostgreSQL, trino→Trino, presto→Presto,
|
|
69
73
|
# pyhive+thrift→the Spark Thrift Server (the open-source Databricks stand-in,
|
|
70
|
-
# reached over NOSASL).
|
|
74
|
+
# reached over NOSASL), clickhouse-connect→ClickHouse, and pymysql→MySQL.
|
|
71
75
|
dev = [
|
|
72
76
|
"pytest",
|
|
73
77
|
"pytest-xdist",
|
|
@@ -80,6 +84,8 @@ dev = [
|
|
|
80
84
|
"presto-python-client",
|
|
81
85
|
"pyhive",
|
|
82
86
|
"thrift",
|
|
87
|
+
"clickhouse-connect>=1.12.0",
|
|
88
|
+
"pymysql>=1.2.3",
|
|
83
89
|
]
|
|
84
90
|
|
|
85
91
|
[tool.maturin]
|