relationalai 0.12.13__py3-none-any.whl → 0.13.0.dev0__py3-none-any.whl
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.
- relationalai/__init__.py +1 -209
- relationalai/config/__init__.py +56 -0
- relationalai/config/config.py +289 -0
- relationalai/config/config_fields.py +86 -0
- relationalai/config/connections/__init__.py +46 -0
- relationalai/config/connections/base.py +23 -0
- relationalai/config/connections/duckdb.py +29 -0
- relationalai/config/connections/snowflake.py +243 -0
- relationalai/config/external/__init__.py +17 -0
- relationalai/config/external/dbt_converter.py +101 -0
- relationalai/config/external/dbt_models.py +93 -0
- relationalai/config/external/snowflake_converter.py +41 -0
- relationalai/config/external/snowflake_models.py +85 -0
- relationalai/config/external/utils.py +19 -0
- relationalai/semantics/__init__.py +146 -22
- relationalai/semantics/backends/lqp/annotations.py +11 -0
- relationalai/semantics/backends/sql/sql_compiler.py +327 -0
- relationalai/semantics/frontend/base.py +1707 -0
- relationalai/semantics/frontend/core.py +179 -0
- relationalai/semantics/frontend/front_compiler.py +1313 -0
- relationalai/semantics/frontend/pprint.py +408 -0
- relationalai/semantics/metamodel/__init__.py +6 -40
- relationalai/semantics/metamodel/builtins.py +205 -769
- relationalai/semantics/metamodel/metamodel.py +437 -0
- relationalai/semantics/metamodel/metamodel_analyzer.py +519 -0
- relationalai/semantics/metamodel/pprint.py +412 -0
- relationalai/semantics/metamodel/rewriter.py +266 -0
- relationalai/semantics/metamodel/typer.py +1378 -0
- relationalai/semantics/std/__init__.py +60 -40
- relationalai/semantics/std/aggregates.py +149 -0
- relationalai/semantics/std/common.py +44 -0
- relationalai/semantics/std/constraints.py +37 -43
- relationalai/semantics/std/datetime.py +246 -135
- relationalai/semantics/std/decimals.py +45 -52
- relationalai/semantics/std/floats.py +13 -5
- relationalai/semantics/std/integers.py +26 -11
- relationalai/semantics/std/math.py +183 -112
- relationalai/semantics/std/numbers.py +86 -0
- relationalai/semantics/std/re.py +80 -62
- relationalai/semantics/std/strings.py +117 -60
- relationalai/shims/executor.py +147 -0
- relationalai/shims/helpers.py +126 -0
- relationalai/shims/hoister.py +221 -0
- relationalai/shims/mm2v0.py +1290 -0
- relationalai/tools/cli/__init__.py +6 -0
- relationalai/tools/cli/cli.py +90 -0
- relationalai/tools/cli/components/__init__.py +5 -0
- relationalai/tools/cli/components/progress_reader.py +1524 -0
- relationalai/tools/cli/components/utils.py +58 -0
- relationalai/tools/cli/config_template.py +45 -0
- relationalai/tools/cli/dev.py +19 -0
- relationalai/tools/debugger.py +289 -183
- relationalai/tools/typer_debugger.py +93 -0
- relationalai/util/dataclasses.py +43 -0
- relationalai/util/docutils.py +40 -0
- relationalai/util/error.py +199 -0
- relationalai/util/format.py +48 -106
- relationalai/util/naming.py +145 -0
- relationalai/util/python.py +35 -0
- relationalai/util/runtime.py +156 -0
- relationalai/util/schema.py +197 -0
- relationalai/util/source.py +185 -0
- relationalai/util/structures.py +163 -0
- relationalai/util/tracing.py +261 -0
- relationalai-0.13.0.dev0.dist-info/METADATA +46 -0
- relationalai-0.13.0.dev0.dist-info/RECORD +488 -0
- relationalai-0.13.0.dev0.dist-info/WHEEL +5 -0
- relationalai-0.13.0.dev0.dist-info/entry_points.txt +3 -0
- relationalai-0.13.0.dev0.dist-info/top_level.txt +2 -0
- v0/relationalai/__init__.py +216 -0
- v0/relationalai/clients/azure.py +477 -0
- v0/relationalai/clients/client.py +912 -0
- v0/relationalai/clients/config.py +673 -0
- v0/relationalai/clients/direct_access_client.py +118 -0
- v0/relationalai/clients/hash_util.py +31 -0
- v0/relationalai/clients/local.py +571 -0
- v0/relationalai/clients/profile_polling.py +73 -0
- v0/relationalai/clients/result_helpers.py +420 -0
- v0/relationalai/clients/snowflake.py +3869 -0
- v0/relationalai/clients/types.py +113 -0
- v0/relationalai/clients/use_index_poller.py +980 -0
- v0/relationalai/clients/util.py +356 -0
- v0/relationalai/debugging.py +389 -0
- v0/relationalai/dsl.py +1749 -0
- v0/relationalai/early_access/builder/__init__.py +30 -0
- v0/relationalai/early_access/builder/builder/__init__.py +35 -0
- v0/relationalai/early_access/builder/snowflake/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/__init__.py +25 -0
- v0/relationalai/early_access/builder/std/decimals/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/integers/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/math/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/strings/__init__.py +14 -0
- v0/relationalai/early_access/devtools/__init__.py +12 -0
- v0/relationalai/early_access/devtools/benchmark_lqp/__init__.py +12 -0
- v0/relationalai/early_access/devtools/extract_lqp/__init__.py +12 -0
- v0/relationalai/early_access/dsl/adapters/orm/adapter_qb.py +427 -0
- v0/relationalai/early_access/dsl/adapters/orm/parser.py +636 -0
- v0/relationalai/early_access/dsl/adapters/owl/adapter.py +176 -0
- v0/relationalai/early_access/dsl/adapters/owl/parser.py +160 -0
- v0/relationalai/early_access/dsl/bindings/common.py +402 -0
- v0/relationalai/early_access/dsl/bindings/csv.py +170 -0
- v0/relationalai/early_access/dsl/bindings/legacy/binding_models.py +143 -0
- v0/relationalai/early_access/dsl/bindings/snowflake.py +64 -0
- v0/relationalai/early_access/dsl/codegen/binder.py +411 -0
- v0/relationalai/early_access/dsl/codegen/common.py +79 -0
- v0/relationalai/early_access/dsl/codegen/helpers.py +23 -0
- v0/relationalai/early_access/dsl/codegen/relations.py +700 -0
- v0/relationalai/early_access/dsl/codegen/weaver.py +417 -0
- v0/relationalai/early_access/dsl/core/builders/__init__.py +47 -0
- v0/relationalai/early_access/dsl/core/builders/logic.py +19 -0
- v0/relationalai/early_access/dsl/core/builders/scalar_constraint.py +11 -0
- v0/relationalai/early_access/dsl/core/constraints/predicate/atomic.py +455 -0
- v0/relationalai/early_access/dsl/core/constraints/predicate/universal.py +73 -0
- v0/relationalai/early_access/dsl/core/constraints/scalar.py +310 -0
- v0/relationalai/early_access/dsl/core/context.py +13 -0
- v0/relationalai/early_access/dsl/core/cset.py +132 -0
- v0/relationalai/early_access/dsl/core/exprs/__init__.py +116 -0
- v0/relationalai/early_access/dsl/core/exprs/relational.py +18 -0
- v0/relationalai/early_access/dsl/core/exprs/scalar.py +412 -0
- v0/relationalai/early_access/dsl/core/instances.py +44 -0
- v0/relationalai/early_access/dsl/core/logic/__init__.py +193 -0
- v0/relationalai/early_access/dsl/core/logic/aggregation.py +98 -0
- v0/relationalai/early_access/dsl/core/logic/exists.py +223 -0
- v0/relationalai/early_access/dsl/core/logic/helper.py +163 -0
- v0/relationalai/early_access/dsl/core/namespaces.py +32 -0
- v0/relationalai/early_access/dsl/core/relations.py +276 -0
- v0/relationalai/early_access/dsl/core/rules.py +112 -0
- v0/relationalai/early_access/dsl/core/std/__init__.py +45 -0
- v0/relationalai/early_access/dsl/core/temporal/recall.py +6 -0
- v0/relationalai/early_access/dsl/core/types/__init__.py +270 -0
- v0/relationalai/early_access/dsl/core/types/concepts.py +128 -0
- v0/relationalai/early_access/dsl/core/types/constrained/__init__.py +267 -0
- v0/relationalai/early_access/dsl/core/types/constrained/nominal.py +143 -0
- v0/relationalai/early_access/dsl/core/types/constrained/subtype.py +124 -0
- v0/relationalai/early_access/dsl/core/types/standard.py +92 -0
- v0/relationalai/early_access/dsl/core/types/unconstrained.py +50 -0
- v0/relationalai/early_access/dsl/core/types/variables.py +203 -0
- v0/relationalai/early_access/dsl/ir/compiler.py +318 -0
- v0/relationalai/early_access/dsl/ir/executor.py +260 -0
- v0/relationalai/early_access/dsl/ontologies/constraints.py +88 -0
- v0/relationalai/early_access/dsl/ontologies/export.py +30 -0
- v0/relationalai/early_access/dsl/ontologies/models.py +453 -0
- v0/relationalai/early_access/dsl/ontologies/python_printer.py +303 -0
- v0/relationalai/early_access/dsl/ontologies/readings.py +60 -0
- v0/relationalai/early_access/dsl/ontologies/relationships.py +322 -0
- v0/relationalai/early_access/dsl/ontologies/roles.py +87 -0
- v0/relationalai/early_access/dsl/ontologies/subtyping.py +55 -0
- v0/relationalai/early_access/dsl/orm/constraints.py +438 -0
- v0/relationalai/early_access/dsl/orm/measures/dimensions.py +200 -0
- v0/relationalai/early_access/dsl/orm/measures/initializer.py +16 -0
- v0/relationalai/early_access/dsl/orm/measures/measure_rules.py +275 -0
- v0/relationalai/early_access/dsl/orm/measures/measures.py +299 -0
- v0/relationalai/early_access/dsl/orm/measures/role_exprs.py +268 -0
- v0/relationalai/early_access/dsl/orm/models.py +256 -0
- v0/relationalai/early_access/dsl/orm/object_oriented_printer.py +344 -0
- v0/relationalai/early_access/dsl/orm/printer.py +469 -0
- v0/relationalai/early_access/dsl/orm/reasoners.py +480 -0
- v0/relationalai/early_access/dsl/orm/relations.py +19 -0
- v0/relationalai/early_access/dsl/orm/relationships.py +251 -0
- v0/relationalai/early_access/dsl/orm/types.py +42 -0
- v0/relationalai/early_access/dsl/orm/utils.py +79 -0
- v0/relationalai/early_access/dsl/orm/verb.py +204 -0
- v0/relationalai/early_access/dsl/physical_metadata/tables.py +133 -0
- v0/relationalai/early_access/dsl/relations.py +170 -0
- v0/relationalai/early_access/dsl/rulesets.py +69 -0
- v0/relationalai/early_access/dsl/schemas/__init__.py +450 -0
- v0/relationalai/early_access/dsl/schemas/builder.py +48 -0
- v0/relationalai/early_access/dsl/schemas/comp_names.py +51 -0
- v0/relationalai/early_access/dsl/schemas/components.py +203 -0
- v0/relationalai/early_access/dsl/schemas/contexts.py +156 -0
- v0/relationalai/early_access/dsl/schemas/exprs.py +89 -0
- v0/relationalai/early_access/dsl/schemas/fragments.py +464 -0
- v0/relationalai/early_access/dsl/serialization.py +79 -0
- v0/relationalai/early_access/dsl/serialize/exporter.py +163 -0
- v0/relationalai/early_access/dsl/snow/api.py +104 -0
- v0/relationalai/early_access/dsl/snow/common.py +76 -0
- v0/relationalai/early_access/dsl/state_mgmt/__init__.py +129 -0
- v0/relationalai/early_access/dsl/state_mgmt/state_charts.py +125 -0
- v0/relationalai/early_access/dsl/state_mgmt/transitions.py +130 -0
- v0/relationalai/early_access/dsl/types/__init__.py +40 -0
- v0/relationalai/early_access/dsl/types/concepts.py +12 -0
- v0/relationalai/early_access/dsl/types/entities.py +135 -0
- v0/relationalai/early_access/dsl/types/values.py +17 -0
- v0/relationalai/early_access/dsl/utils.py +102 -0
- v0/relationalai/early_access/graphs/__init__.py +13 -0
- v0/relationalai/early_access/lqp/__init__.py +12 -0
- v0/relationalai/early_access/lqp/compiler/__init__.py +12 -0
- v0/relationalai/early_access/lqp/constructors/__init__.py +18 -0
- v0/relationalai/early_access/lqp/executor/__init__.py +12 -0
- v0/relationalai/early_access/lqp/ir/__init__.py +12 -0
- v0/relationalai/early_access/lqp/passes/__init__.py +12 -0
- v0/relationalai/early_access/lqp/pragmas/__init__.py +12 -0
- v0/relationalai/early_access/lqp/primitives/__init__.py +12 -0
- v0/relationalai/early_access/lqp/types/__init__.py +12 -0
- v0/relationalai/early_access/lqp/utils/__init__.py +12 -0
- v0/relationalai/early_access/lqp/validators/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/__init__.py +58 -0
- v0/relationalai/early_access/metamodel/builtins/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/compiler/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/dependency/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/factory/__init__.py +17 -0
- v0/relationalai/early_access/metamodel/helpers/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/ir/__init__.py +14 -0
- v0/relationalai/early_access/metamodel/rewrite/__init__.py +7 -0
- v0/relationalai/early_access/metamodel/typer/__init__.py +3 -0
- v0/relationalai/early_access/metamodel/typer/typer/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/types/__init__.py +15 -0
- v0/relationalai/early_access/metamodel/util/__init__.py +15 -0
- v0/relationalai/early_access/metamodel/visitor/__init__.py +12 -0
- v0/relationalai/early_access/rel/__init__.py +12 -0
- v0/relationalai/early_access/rel/executor/__init__.py +12 -0
- v0/relationalai/early_access/rel/rel_utils/__init__.py +12 -0
- v0/relationalai/early_access/rel/rewrite/__init__.py +7 -0
- v0/relationalai/early_access/solvers/__init__.py +19 -0
- v0/relationalai/early_access/sql/__init__.py +11 -0
- v0/relationalai/early_access/sql/executor/__init__.py +3 -0
- v0/relationalai/early_access/sql/rewrite/__init__.py +3 -0
- v0/relationalai/early_access/tests/logging/__init__.py +12 -0
- v0/relationalai/early_access/tests/test_snapshot_base/__init__.py +12 -0
- v0/relationalai/early_access/tests/utils/__init__.py +12 -0
- v0/relationalai/environments/__init__.py +35 -0
- v0/relationalai/environments/base.py +381 -0
- v0/relationalai/environments/colab.py +14 -0
- v0/relationalai/environments/generic.py +71 -0
- v0/relationalai/environments/ipython.py +68 -0
- v0/relationalai/environments/jupyter.py +9 -0
- v0/relationalai/environments/snowbook.py +169 -0
- v0/relationalai/errors.py +2455 -0
- v0/relationalai/experimental/SF.py +38 -0
- v0/relationalai/experimental/inspect.py +47 -0
- v0/relationalai/experimental/pathfinder/__init__.py +158 -0
- v0/relationalai/experimental/pathfinder/api.py +160 -0
- v0/relationalai/experimental/pathfinder/automaton.py +584 -0
- v0/relationalai/experimental/pathfinder/bridge.py +226 -0
- v0/relationalai/experimental/pathfinder/compiler.py +416 -0
- v0/relationalai/experimental/pathfinder/datalog.py +214 -0
- v0/relationalai/experimental/pathfinder/diagnostics.py +56 -0
- v0/relationalai/experimental/pathfinder/filter.py +236 -0
- v0/relationalai/experimental/pathfinder/glushkov.py +439 -0
- v0/relationalai/experimental/pathfinder/options.py +265 -0
- v0/relationalai/experimental/pathfinder/rpq.py +344 -0
- v0/relationalai/experimental/pathfinder/transition.py +200 -0
- v0/relationalai/experimental/pathfinder/utils.py +26 -0
- v0/relationalai/experimental/paths/api.py +143 -0
- v0/relationalai/experimental/paths/benchmarks/grid_graph.py +37 -0
- v0/relationalai/experimental/paths/examples/basic_example.py +40 -0
- v0/relationalai/experimental/paths/examples/minimal_engine_warmup.py +3 -0
- v0/relationalai/experimental/paths/examples/movie_example.py +77 -0
- v0/relationalai/experimental/paths/examples/paths_benchmark.py +115 -0
- v0/relationalai/experimental/paths/examples/paths_example.py +116 -0
- v0/relationalai/experimental/paths/examples/pattern_to_automaton.py +28 -0
- v0/relationalai/experimental/paths/find_paths_via_automaton.py +85 -0
- v0/relationalai/experimental/paths/graph.py +185 -0
- v0/relationalai/experimental/paths/path_algorithms/find_paths.py +280 -0
- v0/relationalai/experimental/paths/path_algorithms/one_sided_ball_repetition.py +26 -0
- v0/relationalai/experimental/paths/path_algorithms/one_sided_ball_upto.py +111 -0
- v0/relationalai/experimental/paths/path_algorithms/single.py +59 -0
- v0/relationalai/experimental/paths/path_algorithms/two_sided_balls_repetition.py +39 -0
- v0/relationalai/experimental/paths/path_algorithms/two_sided_balls_upto.py +103 -0
- v0/relationalai/experimental/paths/path_algorithms/usp-old.py +130 -0
- v0/relationalai/experimental/paths/path_algorithms/usp-tuple.py +183 -0
- v0/relationalai/experimental/paths/path_algorithms/usp.py +150 -0
- v0/relationalai/experimental/paths/product_graph.py +93 -0
- v0/relationalai/experimental/paths/rpq/automaton.py +584 -0
- v0/relationalai/experimental/paths/rpq/diagnostics.py +56 -0
- v0/relationalai/experimental/paths/rpq/rpq.py +378 -0
- v0/relationalai/experimental/paths/tests/tests_limit_sp_max_length.py +90 -0
- v0/relationalai/experimental/paths/tests/tests_limit_sp_multiple.py +119 -0
- v0/relationalai/experimental/paths/tests/tests_limit_sp_single.py +104 -0
- v0/relationalai/experimental/paths/tests/tests_limit_walks_multiple.py +113 -0
- v0/relationalai/experimental/paths/tests/tests_limit_walks_single.py +149 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_multiple.py +70 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_single.py +64 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_upto_multiple.py +115 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_upto_single.py +75 -0
- v0/relationalai/experimental/paths/tests/tests_single_paths.py +152 -0
- v0/relationalai/experimental/paths/tests/tests_single_walks.py +208 -0
- v0/relationalai/experimental/paths/tests/tests_single_walks_undirected.py +297 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_multiple.py +107 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_single.py +76 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_upto_multiple.py +76 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_upto_single.py +110 -0
- v0/relationalai/experimental/paths/tests/tests_usp_nsp_multiple.py +229 -0
- v0/relationalai/experimental/paths/tests/tests_usp_nsp_single.py +108 -0
- v0/relationalai/experimental/paths/tree_agg.py +168 -0
- v0/relationalai/experimental/paths/utilities/iterators.py +27 -0
- v0/relationalai/experimental/paths/utilities/prefix_sum.py +91 -0
- v0/relationalai/experimental/solvers.py +1087 -0
- v0/relationalai/loaders/__init__.py +0 -0
- v0/relationalai/loaders/csv.py +195 -0
- v0/relationalai/loaders/loader.py +177 -0
- v0/relationalai/loaders/types.py +23 -0
- v0/relationalai/rel_emitter.py +373 -0
- v0/relationalai/rel_utils.py +185 -0
- v0/relationalai/semantics/__init__.py +29 -0
- v0/relationalai/semantics/devtools/benchmark_lqp.py +536 -0
- v0/relationalai/semantics/devtools/compilation_manager.py +294 -0
- v0/relationalai/semantics/devtools/extract_lqp.py +110 -0
- v0/relationalai/semantics/internal/internal.py +3785 -0
- v0/relationalai/semantics/internal/snowflake.py +324 -0
- v0/relationalai/semantics/lqp/builtins.py +16 -0
- v0/relationalai/semantics/lqp/compiler.py +22 -0
- v0/relationalai/semantics/lqp/constructors.py +68 -0
- v0/relationalai/semantics/lqp/executor.py +469 -0
- v0/relationalai/semantics/lqp/intrinsics.py +24 -0
- v0/relationalai/semantics/lqp/model2lqp.py +839 -0
- v0/relationalai/semantics/lqp/passes.py +680 -0
- v0/relationalai/semantics/lqp/primitives.py +252 -0
- v0/relationalai/semantics/lqp/result_helpers.py +202 -0
- v0/relationalai/semantics/lqp/rewrite/annotate_constraints.py +57 -0
- v0/relationalai/semantics/lqp/rewrite/cdc.py +216 -0
- v0/relationalai/semantics/lqp/rewrite/extract_common.py +338 -0
- v0/relationalai/semantics/lqp/rewrite/extract_keys.py +449 -0
- v0/relationalai/semantics/lqp/rewrite/function_annotations.py +114 -0
- v0/relationalai/semantics/lqp/rewrite/functional_dependencies.py +314 -0
- v0/relationalai/semantics/lqp/rewrite/quantify_vars.py +296 -0
- v0/relationalai/semantics/lqp/rewrite/splinter.py +76 -0
- v0/relationalai/semantics/lqp/types.py +101 -0
- v0/relationalai/semantics/lqp/utils.py +160 -0
- v0/relationalai/semantics/lqp/validators.py +57 -0
- v0/relationalai/semantics/metamodel/__init__.py +40 -0
- v0/relationalai/semantics/metamodel/builtins.py +774 -0
- v0/relationalai/semantics/metamodel/compiler.py +133 -0
- v0/relationalai/semantics/metamodel/dependency.py +862 -0
- v0/relationalai/semantics/metamodel/executor.py +61 -0
- v0/relationalai/semantics/metamodel/factory.py +287 -0
- v0/relationalai/semantics/metamodel/helpers.py +361 -0
- v0/relationalai/semantics/metamodel/rewrite/discharge_constraints.py +39 -0
- v0/relationalai/semantics/metamodel/rewrite/dnf_union_splitter.py +210 -0
- v0/relationalai/semantics/metamodel/rewrite/extract_nested_logicals.py +78 -0
- v0/relationalai/semantics/metamodel/rewrite/flatten.py +549 -0
- v0/relationalai/semantics/metamodel/rewrite/format_outputs.py +165 -0
- v0/relationalai/semantics/metamodel/typer/checker.py +353 -0
- v0/relationalai/semantics/metamodel/typer/typer.py +1395 -0
- v0/relationalai/semantics/reasoners/__init__.py +10 -0
- v0/relationalai/semantics/reasoners/graph/__init__.py +37 -0
- v0/relationalai/semantics/reasoners/graph/core.py +9020 -0
- v0/relationalai/semantics/reasoners/optimization/__init__.py +68 -0
- v0/relationalai/semantics/reasoners/optimization/common.py +88 -0
- v0/relationalai/semantics/reasoners/optimization/solvers_dev.py +568 -0
- v0/relationalai/semantics/reasoners/optimization/solvers_pb.py +1163 -0
- v0/relationalai/semantics/rel/builtins.py +40 -0
- v0/relationalai/semantics/rel/compiler.py +989 -0
- v0/relationalai/semantics/rel/executor.py +359 -0
- v0/relationalai/semantics/rel/rel.py +482 -0
- v0/relationalai/semantics/rel/rel_utils.py +276 -0
- v0/relationalai/semantics/snowflake/__init__.py +3 -0
- v0/relationalai/semantics/sql/compiler.py +2503 -0
- v0/relationalai/semantics/sql/executor/duck_db.py +52 -0
- v0/relationalai/semantics/sql/executor/result_helpers.py +64 -0
- v0/relationalai/semantics/sql/executor/snowflake.py +145 -0
- v0/relationalai/semantics/sql/rewrite/denormalize.py +222 -0
- v0/relationalai/semantics/sql/rewrite/double_negation.py +49 -0
- v0/relationalai/semantics/sql/rewrite/recursive_union.py +127 -0
- v0/relationalai/semantics/sql/rewrite/sort_output_query.py +246 -0
- v0/relationalai/semantics/sql/sql.py +504 -0
- v0/relationalai/semantics/std/__init__.py +54 -0
- v0/relationalai/semantics/std/constraints.py +43 -0
- v0/relationalai/semantics/std/datetime.py +363 -0
- v0/relationalai/semantics/std/decimals.py +62 -0
- v0/relationalai/semantics/std/floats.py +7 -0
- v0/relationalai/semantics/std/integers.py +22 -0
- v0/relationalai/semantics/std/math.py +141 -0
- v0/relationalai/semantics/std/pragmas.py +11 -0
- v0/relationalai/semantics/std/re.py +83 -0
- v0/relationalai/semantics/std/std.py +14 -0
- v0/relationalai/semantics/std/strings.py +63 -0
- v0/relationalai/semantics/tests/__init__.py +0 -0
- v0/relationalai/semantics/tests/test_snapshot_abstract.py +143 -0
- v0/relationalai/semantics/tests/test_snapshot_base.py +9 -0
- v0/relationalai/semantics/tests/utils.py +46 -0
- v0/relationalai/std/__init__.py +70 -0
- v0/relationalai/tools/__init__.py +0 -0
- v0/relationalai/tools/cli.py +1940 -0
- v0/relationalai/tools/cli_controls.py +1826 -0
- v0/relationalai/tools/cli_helpers.py +390 -0
- v0/relationalai/tools/debugger.py +183 -0
- v0/relationalai/tools/debugger_client.py +109 -0
- v0/relationalai/tools/debugger_server.py +302 -0
- v0/relationalai/tools/dev.py +685 -0
- v0/relationalai/tools/qb_debugger.py +425 -0
- v0/relationalai/util/clean_up_databases.py +95 -0
- v0/relationalai/util/format.py +123 -0
- v0/relationalai/util/list_databases.py +9 -0
- v0/relationalai/util/otel_configuration.py +25 -0
- v0/relationalai/util/otel_handler.py +484 -0
- v0/relationalai/util/snowflake_handler.py +88 -0
- v0/relationalai/util/span_format_test.py +43 -0
- v0/relationalai/util/span_tracker.py +207 -0
- v0/relationalai/util/spans_file_handler.py +72 -0
- v0/relationalai/util/tracing_handler.py +34 -0
- frontend/debugger/dist/.gitignore +0 -2
- frontend/debugger/dist/assets/favicon-Dy0ZgA6N.png +0 -0
- frontend/debugger/dist/assets/index-Cssla-O7.js +0 -208
- frontend/debugger/dist/assets/index-DlHsYx1V.css +0 -9
- frontend/debugger/dist/index.html +0 -17
- relationalai/clients/azure.py +0 -477
- relationalai/clients/client.py +0 -912
- relationalai/clients/config.py +0 -673
- relationalai/clients/direct_access_client.py +0 -118
- relationalai/clients/export_procedure.py.jinja +0 -249
- relationalai/clients/hash_util.py +0 -31
- relationalai/clients/local.py +0 -571
- relationalai/clients/profile_polling.py +0 -73
- relationalai/clients/result_helpers.py +0 -420
- relationalai/clients/snowflake.py +0 -3869
- relationalai/clients/types.py +0 -113
- relationalai/clients/use_index_poller.py +0 -980
- relationalai/clients/util.py +0 -356
- relationalai/debugging.py +0 -389
- relationalai/dsl.py +0 -1749
- relationalai/early_access/builder/__init__.py +0 -30
- relationalai/early_access/builder/builder/__init__.py +0 -35
- relationalai/early_access/builder/snowflake/__init__.py +0 -12
- relationalai/early_access/builder/std/__init__.py +0 -25
- relationalai/early_access/builder/std/decimals/__init__.py +0 -12
- relationalai/early_access/builder/std/integers/__init__.py +0 -12
- relationalai/early_access/builder/std/math/__init__.py +0 -12
- relationalai/early_access/builder/std/strings/__init__.py +0 -14
- relationalai/early_access/devtools/__init__.py +0 -12
- relationalai/early_access/devtools/benchmark_lqp/__init__.py +0 -12
- relationalai/early_access/devtools/extract_lqp/__init__.py +0 -12
- relationalai/early_access/dsl/adapters/orm/adapter_qb.py +0 -427
- relationalai/early_access/dsl/adapters/orm/parser.py +0 -636
- relationalai/early_access/dsl/adapters/owl/adapter.py +0 -176
- relationalai/early_access/dsl/adapters/owl/parser.py +0 -160
- relationalai/early_access/dsl/bindings/common.py +0 -402
- relationalai/early_access/dsl/bindings/csv.py +0 -170
- relationalai/early_access/dsl/bindings/legacy/binding_models.py +0 -143
- relationalai/early_access/dsl/bindings/snowflake.py +0 -64
- relationalai/early_access/dsl/codegen/binder.py +0 -411
- relationalai/early_access/dsl/codegen/common.py +0 -79
- relationalai/early_access/dsl/codegen/helpers.py +0 -23
- relationalai/early_access/dsl/codegen/relations.py +0 -700
- relationalai/early_access/dsl/codegen/weaver.py +0 -417
- relationalai/early_access/dsl/core/builders/__init__.py +0 -47
- relationalai/early_access/dsl/core/builders/logic.py +0 -19
- relationalai/early_access/dsl/core/builders/scalar_constraint.py +0 -11
- relationalai/early_access/dsl/core/constraints/predicate/atomic.py +0 -455
- relationalai/early_access/dsl/core/constraints/predicate/universal.py +0 -73
- relationalai/early_access/dsl/core/constraints/scalar.py +0 -310
- relationalai/early_access/dsl/core/context.py +0 -13
- relationalai/early_access/dsl/core/cset.py +0 -132
- relationalai/early_access/dsl/core/exprs/__init__.py +0 -116
- relationalai/early_access/dsl/core/exprs/relational.py +0 -18
- relationalai/early_access/dsl/core/exprs/scalar.py +0 -412
- relationalai/early_access/dsl/core/instances.py +0 -44
- relationalai/early_access/dsl/core/logic/__init__.py +0 -193
- relationalai/early_access/dsl/core/logic/aggregation.py +0 -98
- relationalai/early_access/dsl/core/logic/exists.py +0 -223
- relationalai/early_access/dsl/core/logic/helper.py +0 -163
- relationalai/early_access/dsl/core/namespaces.py +0 -32
- relationalai/early_access/dsl/core/relations.py +0 -276
- relationalai/early_access/dsl/core/rules.py +0 -112
- relationalai/early_access/dsl/core/std/__init__.py +0 -45
- relationalai/early_access/dsl/core/temporal/recall.py +0 -6
- relationalai/early_access/dsl/core/types/__init__.py +0 -270
- relationalai/early_access/dsl/core/types/concepts.py +0 -128
- relationalai/early_access/dsl/core/types/constrained/__init__.py +0 -267
- relationalai/early_access/dsl/core/types/constrained/nominal.py +0 -143
- relationalai/early_access/dsl/core/types/constrained/subtype.py +0 -124
- relationalai/early_access/dsl/core/types/standard.py +0 -92
- relationalai/early_access/dsl/core/types/unconstrained.py +0 -50
- relationalai/early_access/dsl/core/types/variables.py +0 -203
- relationalai/early_access/dsl/ir/compiler.py +0 -318
- relationalai/early_access/dsl/ir/executor.py +0 -260
- relationalai/early_access/dsl/ontologies/constraints.py +0 -88
- relationalai/early_access/dsl/ontologies/export.py +0 -30
- relationalai/early_access/dsl/ontologies/models.py +0 -453
- relationalai/early_access/dsl/ontologies/python_printer.py +0 -303
- relationalai/early_access/dsl/ontologies/readings.py +0 -60
- relationalai/early_access/dsl/ontologies/relationships.py +0 -322
- relationalai/early_access/dsl/ontologies/roles.py +0 -87
- relationalai/early_access/dsl/ontologies/subtyping.py +0 -55
- relationalai/early_access/dsl/orm/constraints.py +0 -438
- relationalai/early_access/dsl/orm/measures/dimensions.py +0 -200
- relationalai/early_access/dsl/orm/measures/initializer.py +0 -16
- relationalai/early_access/dsl/orm/measures/measure_rules.py +0 -275
- relationalai/early_access/dsl/orm/measures/measures.py +0 -299
- relationalai/early_access/dsl/orm/measures/role_exprs.py +0 -268
- relationalai/early_access/dsl/orm/models.py +0 -256
- relationalai/early_access/dsl/orm/object_oriented_printer.py +0 -344
- relationalai/early_access/dsl/orm/printer.py +0 -469
- relationalai/early_access/dsl/orm/reasoners.py +0 -480
- relationalai/early_access/dsl/orm/relations.py +0 -19
- relationalai/early_access/dsl/orm/relationships.py +0 -251
- relationalai/early_access/dsl/orm/types.py +0 -42
- relationalai/early_access/dsl/orm/utils.py +0 -79
- relationalai/early_access/dsl/orm/verb.py +0 -204
- relationalai/early_access/dsl/physical_metadata/tables.py +0 -133
- relationalai/early_access/dsl/relations.py +0 -170
- relationalai/early_access/dsl/rulesets.py +0 -69
- relationalai/early_access/dsl/schemas/__init__.py +0 -450
- relationalai/early_access/dsl/schemas/builder.py +0 -48
- relationalai/early_access/dsl/schemas/comp_names.py +0 -51
- relationalai/early_access/dsl/schemas/components.py +0 -203
- relationalai/early_access/dsl/schemas/contexts.py +0 -156
- relationalai/early_access/dsl/schemas/exprs.py +0 -89
- relationalai/early_access/dsl/schemas/fragments.py +0 -464
- relationalai/early_access/dsl/serialization.py +0 -79
- relationalai/early_access/dsl/serialize/exporter.py +0 -163
- relationalai/early_access/dsl/snow/api.py +0 -104
- relationalai/early_access/dsl/snow/common.py +0 -76
- relationalai/early_access/dsl/state_mgmt/__init__.py +0 -129
- relationalai/early_access/dsl/state_mgmt/state_charts.py +0 -125
- relationalai/early_access/dsl/state_mgmt/transitions.py +0 -130
- relationalai/early_access/dsl/types/__init__.py +0 -40
- relationalai/early_access/dsl/types/concepts.py +0 -12
- relationalai/early_access/dsl/types/entities.py +0 -135
- relationalai/early_access/dsl/types/values.py +0 -17
- relationalai/early_access/dsl/utils.py +0 -102
- relationalai/early_access/graphs/__init__.py +0 -13
- relationalai/early_access/lqp/__init__.py +0 -12
- relationalai/early_access/lqp/compiler/__init__.py +0 -12
- relationalai/early_access/lqp/constructors/__init__.py +0 -18
- relationalai/early_access/lqp/executor/__init__.py +0 -12
- relationalai/early_access/lqp/ir/__init__.py +0 -12
- relationalai/early_access/lqp/passes/__init__.py +0 -12
- relationalai/early_access/lqp/pragmas/__init__.py +0 -12
- relationalai/early_access/lqp/primitives/__init__.py +0 -12
- relationalai/early_access/lqp/types/__init__.py +0 -12
- relationalai/early_access/lqp/utils/__init__.py +0 -12
- relationalai/early_access/lqp/validators/__init__.py +0 -12
- relationalai/early_access/metamodel/__init__.py +0 -58
- relationalai/early_access/metamodel/builtins/__init__.py +0 -12
- relationalai/early_access/metamodel/compiler/__init__.py +0 -12
- relationalai/early_access/metamodel/dependency/__init__.py +0 -12
- relationalai/early_access/metamodel/factory/__init__.py +0 -17
- relationalai/early_access/metamodel/helpers/__init__.py +0 -12
- relationalai/early_access/metamodel/ir/__init__.py +0 -14
- relationalai/early_access/metamodel/rewrite/__init__.py +0 -7
- relationalai/early_access/metamodel/typer/__init__.py +0 -3
- relationalai/early_access/metamodel/typer/typer/__init__.py +0 -12
- relationalai/early_access/metamodel/types/__init__.py +0 -15
- relationalai/early_access/metamodel/util/__init__.py +0 -15
- relationalai/early_access/metamodel/visitor/__init__.py +0 -12
- relationalai/early_access/rel/__init__.py +0 -12
- relationalai/early_access/rel/executor/__init__.py +0 -12
- relationalai/early_access/rel/rel_utils/__init__.py +0 -12
- relationalai/early_access/rel/rewrite/__init__.py +0 -7
- relationalai/early_access/solvers/__init__.py +0 -19
- relationalai/early_access/sql/__init__.py +0 -11
- relationalai/early_access/sql/executor/__init__.py +0 -3
- relationalai/early_access/sql/rewrite/__init__.py +0 -3
- relationalai/early_access/tests/logging/__init__.py +0 -12
- relationalai/early_access/tests/test_snapshot_base/__init__.py +0 -12
- relationalai/early_access/tests/utils/__init__.py +0 -12
- relationalai/environments/__init__.py +0 -35
- relationalai/environments/base.py +0 -381
- relationalai/environments/colab.py +0 -14
- relationalai/environments/generic.py +0 -71
- relationalai/environments/ipython.py +0 -68
- relationalai/environments/jupyter.py +0 -9
- relationalai/environments/snowbook.py +0 -169
- relationalai/errors.py +0 -2455
- relationalai/experimental/SF.py +0 -38
- relationalai/experimental/inspect.py +0 -47
- relationalai/experimental/pathfinder/__init__.py +0 -158
- relationalai/experimental/pathfinder/api.py +0 -160
- relationalai/experimental/pathfinder/automaton.py +0 -584
- relationalai/experimental/pathfinder/bridge.py +0 -226
- relationalai/experimental/pathfinder/compiler.py +0 -416
- relationalai/experimental/pathfinder/datalog.py +0 -214
- relationalai/experimental/pathfinder/diagnostics.py +0 -56
- relationalai/experimental/pathfinder/filter.py +0 -236
- relationalai/experimental/pathfinder/glushkov.py +0 -439
- relationalai/experimental/pathfinder/options.py +0 -265
- relationalai/experimental/pathfinder/pathfinder-v0.7.0.rel +0 -1951
- relationalai/experimental/pathfinder/rpq.py +0 -344
- relationalai/experimental/pathfinder/transition.py +0 -200
- relationalai/experimental/pathfinder/utils.py +0 -26
- relationalai/experimental/paths/README.md +0 -107
- relationalai/experimental/paths/api.py +0 -143
- relationalai/experimental/paths/benchmarks/grid_graph.py +0 -37
- relationalai/experimental/paths/code_organization.md +0 -2
- relationalai/experimental/paths/examples/Movies.ipynb +0 -16328
- relationalai/experimental/paths/examples/basic_example.py +0 -40
- relationalai/experimental/paths/examples/minimal_engine_warmup.py +0 -3
- relationalai/experimental/paths/examples/movie_example.py +0 -77
- relationalai/experimental/paths/examples/movies_data/actedin.csv +0 -193
- relationalai/experimental/paths/examples/movies_data/directed.csv +0 -45
- relationalai/experimental/paths/examples/movies_data/follows.csv +0 -7
- relationalai/experimental/paths/examples/movies_data/movies.csv +0 -39
- relationalai/experimental/paths/examples/movies_data/person.csv +0 -134
- relationalai/experimental/paths/examples/movies_data/produced.csv +0 -16
- relationalai/experimental/paths/examples/movies_data/ratings.csv +0 -10
- relationalai/experimental/paths/examples/movies_data/wrote.csv +0 -11
- relationalai/experimental/paths/examples/paths_benchmark.py +0 -115
- relationalai/experimental/paths/examples/paths_example.py +0 -116
- relationalai/experimental/paths/examples/pattern_to_automaton.py +0 -28
- relationalai/experimental/paths/find_paths_via_automaton.py +0 -85
- relationalai/experimental/paths/graph.py +0 -185
- relationalai/experimental/paths/path_algorithms/find_paths.py +0 -280
- relationalai/experimental/paths/path_algorithms/one_sided_ball_repetition.py +0 -26
- relationalai/experimental/paths/path_algorithms/one_sided_ball_upto.py +0 -111
- relationalai/experimental/paths/path_algorithms/single.py +0 -59
- relationalai/experimental/paths/path_algorithms/two_sided_balls_repetition.py +0 -39
- relationalai/experimental/paths/path_algorithms/two_sided_balls_upto.py +0 -103
- relationalai/experimental/paths/path_algorithms/usp-old.py +0 -130
- relationalai/experimental/paths/path_algorithms/usp-tuple.py +0 -183
- relationalai/experimental/paths/path_algorithms/usp.py +0 -150
- relationalai/experimental/paths/product_graph.py +0 -93
- relationalai/experimental/paths/rpq/automaton.py +0 -584
- relationalai/experimental/paths/rpq/diagnostics.py +0 -56
- relationalai/experimental/paths/rpq/rpq.py +0 -378
- relationalai/experimental/paths/tests/tests_limit_sp_max_length.py +0 -90
- relationalai/experimental/paths/tests/tests_limit_sp_multiple.py +0 -119
- relationalai/experimental/paths/tests/tests_limit_sp_single.py +0 -104
- relationalai/experimental/paths/tests/tests_limit_walks_multiple.py +0 -113
- relationalai/experimental/paths/tests/tests_limit_walks_single.py +0 -149
- relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_multiple.py +0 -70
- relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_single.py +0 -64
- relationalai/experimental/paths/tests/tests_one_sided_ball_upto_multiple.py +0 -115
- relationalai/experimental/paths/tests/tests_one_sided_ball_upto_single.py +0 -75
- relationalai/experimental/paths/tests/tests_single_paths.py +0 -152
- relationalai/experimental/paths/tests/tests_single_walks.py +0 -208
- relationalai/experimental/paths/tests/tests_single_walks_undirected.py +0 -297
- relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_multiple.py +0 -107
- relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_single.py +0 -76
- relationalai/experimental/paths/tests/tests_two_sided_balls_upto_multiple.py +0 -76
- relationalai/experimental/paths/tests/tests_two_sided_balls_upto_single.py +0 -110
- relationalai/experimental/paths/tests/tests_usp_nsp_multiple.py +0 -229
- relationalai/experimental/paths/tests/tests_usp_nsp_single.py +0 -108
- relationalai/experimental/paths/tree_agg.py +0 -168
- relationalai/experimental/paths/utilities/iterators.py +0 -27
- relationalai/experimental/paths/utilities/prefix_sum.py +0 -91
- relationalai/experimental/solvers.py +0 -1087
- relationalai/loaders/csv.py +0 -195
- relationalai/loaders/loader.py +0 -177
- relationalai/loaders/types.py +0 -23
- relationalai/rel_emitter.py +0 -373
- relationalai/rel_utils.py +0 -185
- relationalai/semantics/designs/query_builder/identify_by.md +0 -106
- relationalai/semantics/devtools/benchmark_lqp.py +0 -536
- relationalai/semantics/devtools/compilation_manager.py +0 -294
- relationalai/semantics/devtools/extract_lqp.py +0 -110
- relationalai/semantics/internal/internal.py +0 -3785
- relationalai/semantics/internal/snowflake.py +0 -324
- relationalai/semantics/lqp/README.md +0 -34
- relationalai/semantics/lqp/builtins.py +0 -16
- relationalai/semantics/lqp/compiler.py +0 -22
- relationalai/semantics/lqp/constructors.py +0 -68
- relationalai/semantics/lqp/executor.py +0 -469
- relationalai/semantics/lqp/intrinsics.py +0 -24
- relationalai/semantics/lqp/model2lqp.py +0 -839
- relationalai/semantics/lqp/passes.py +0 -680
- relationalai/semantics/lqp/primitives.py +0 -252
- relationalai/semantics/lqp/result_helpers.py +0 -202
- relationalai/semantics/lqp/rewrite/annotate_constraints.py +0 -57
- relationalai/semantics/lqp/rewrite/cdc.py +0 -216
- relationalai/semantics/lqp/rewrite/extract_common.py +0 -338
- relationalai/semantics/lqp/rewrite/extract_keys.py +0 -449
- relationalai/semantics/lqp/rewrite/function_annotations.py +0 -114
- relationalai/semantics/lqp/rewrite/functional_dependencies.py +0 -314
- relationalai/semantics/lqp/rewrite/quantify_vars.py +0 -296
- relationalai/semantics/lqp/rewrite/splinter.py +0 -76
- relationalai/semantics/lqp/types.py +0 -101
- relationalai/semantics/lqp/utils.py +0 -160
- relationalai/semantics/lqp/validators.py +0 -57
- relationalai/semantics/metamodel/compiler.py +0 -133
- relationalai/semantics/metamodel/dependency.py +0 -862
- relationalai/semantics/metamodel/executor.py +0 -61
- relationalai/semantics/metamodel/factory.py +0 -287
- relationalai/semantics/metamodel/helpers.py +0 -361
- relationalai/semantics/metamodel/rewrite/discharge_constraints.py +0 -39
- relationalai/semantics/metamodel/rewrite/dnf_union_splitter.py +0 -210
- relationalai/semantics/metamodel/rewrite/extract_nested_logicals.py +0 -78
- relationalai/semantics/metamodel/rewrite/flatten.py +0 -549
- relationalai/semantics/metamodel/rewrite/format_outputs.py +0 -165
- relationalai/semantics/metamodel/typer/checker.py +0 -353
- relationalai/semantics/metamodel/typer/typer.py +0 -1395
- relationalai/semantics/reasoners/__init__.py +0 -10
- relationalai/semantics/reasoners/graph/README.md +0 -620
- relationalai/semantics/reasoners/graph/__init__.py +0 -37
- relationalai/semantics/reasoners/graph/core.py +0 -9020
- relationalai/semantics/reasoners/graph/design/beyond_demand_transform.md +0 -797
- relationalai/semantics/reasoners/graph/tests/README.md +0 -21
- relationalai/semantics/reasoners/optimization/__init__.py +0 -68
- relationalai/semantics/reasoners/optimization/common.py +0 -88
- relationalai/semantics/reasoners/optimization/solvers_dev.py +0 -568
- relationalai/semantics/reasoners/optimization/solvers_pb.py +0 -1163
- relationalai/semantics/rel/builtins.py +0 -40
- relationalai/semantics/rel/compiler.py +0 -989
- relationalai/semantics/rel/executor.py +0 -359
- relationalai/semantics/rel/rel.py +0 -482
- relationalai/semantics/rel/rel_utils.py +0 -276
- relationalai/semantics/snowflake/__init__.py +0 -3
- relationalai/semantics/sql/compiler.py +0 -2503
- relationalai/semantics/sql/executor/duck_db.py +0 -52
- relationalai/semantics/sql/executor/result_helpers.py +0 -64
- relationalai/semantics/sql/executor/snowflake.py +0 -145
- relationalai/semantics/sql/rewrite/denormalize.py +0 -222
- relationalai/semantics/sql/rewrite/double_negation.py +0 -49
- relationalai/semantics/sql/rewrite/recursive_union.py +0 -127
- relationalai/semantics/sql/rewrite/sort_output_query.py +0 -246
- relationalai/semantics/sql/sql.py +0 -504
- relationalai/semantics/std/pragmas.py +0 -11
- relationalai/semantics/std/std.py +0 -14
- relationalai/semantics/tests/test_snapshot_abstract.py +0 -143
- relationalai/semantics/tests/test_snapshot_base.py +0 -9
- relationalai/semantics/tests/utils.py +0 -46
- relationalai/std/__init__.py +0 -70
- relationalai/tools/cli.py +0 -1940
- relationalai/tools/cli_controls.py +0 -1826
- relationalai/tools/cli_helpers.py +0 -390
- relationalai/tools/debugger_client.py +0 -109
- relationalai/tools/debugger_server.py +0 -302
- relationalai/tools/dev.py +0 -685
- relationalai/tools/notes +0 -7
- relationalai/tools/qb_debugger.py +0 -425
- relationalai/util/clean_up_databases.py +0 -95
- relationalai/util/list_databases.py +0 -9
- relationalai/util/otel_configuration.py +0 -25
- relationalai/util/otel_handler.py +0 -484
- relationalai/util/snowflake_handler.py +0 -88
- relationalai/util/span_format_test.py +0 -43
- relationalai/util/span_tracker.py +0 -207
- relationalai/util/spans_file_handler.py +0 -72
- relationalai/util/tracing_handler.py +0 -34
- relationalai-0.12.13.dist-info/METADATA +0 -74
- relationalai-0.12.13.dist-info/RECORD +0 -449
- relationalai-0.12.13.dist-info/WHEEL +0 -4
- relationalai-0.12.13.dist-info/entry_points.txt +0 -3
- relationalai-0.12.13.dist-info/licenses/LICENSE +0 -202
- relationalai_test_util/__init__.py +0 -4
- relationalai_test_util/fixtures.py +0 -228
- relationalai_test_util/snapshot.py +0 -252
- relationalai_test_util/traceback.py +0 -118
- /relationalai/{analysis → semantics/frontend}/__init__.py +0 -0
- /relationalai/{auth/__init__.py → semantics/metamodel/metamodel_compiler.py} +0 -0
- /relationalai/{early_access → shims}/__init__.py +0 -0
- {relationalai/early_access/dsl/adapters → v0/relationalai/analysis}/__init__.py +0 -0
- {relationalai → v0/relationalai}/analysis/mechanistic.py +0 -0
- {relationalai → v0/relationalai}/analysis/whynot.py +0 -0
- {relationalai/early_access/dsl/adapters/orm → v0/relationalai/auth}/__init__.py +0 -0
- {relationalai → v0/relationalai}/auth/jwt_generator.py +0 -0
- {relationalai → v0/relationalai}/auth/oauth_callback_server.py +0 -0
- {relationalai → v0/relationalai}/auth/token_handler.py +0 -0
- {relationalai → v0/relationalai}/auth/util.py +0 -0
- {relationalai → v0/relationalai}/clients/__init__.py +0 -0
- {relationalai → v0/relationalai}/clients/cache_store.py +0 -0
- {relationalai → v0/relationalai}/compiler.py +0 -0
- {relationalai → v0/relationalai}/dependencies.py +0 -0
- {relationalai → v0/relationalai}/docutils.py +0 -0
- {relationalai/early_access/dsl/adapters/owl → v0/relationalai/early_access}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/__init__.py +0 -0
- {relationalai/early_access/dsl/bindings → v0/relationalai/early_access/dsl/adapters}/__init__.py +0 -0
- {relationalai/early_access/dsl/bindings/legacy → v0/relationalai/early_access/dsl/adapters/orm}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/adapters/orm/model.py +0 -0
- {relationalai/early_access/dsl/codegen → v0/relationalai/early_access/dsl/adapters/owl}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/adapters/owl/model.py +0 -0
- {relationalai/early_access/dsl/core/temporal → v0/relationalai/early_access/dsl/bindings}/__init__.py +0 -0
- {relationalai/early_access/dsl/ir → v0/relationalai/early_access/dsl/bindings/legacy}/__init__.py +0 -0
- {relationalai/early_access/dsl/ontologies → v0/relationalai/early_access/dsl/codegen}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/constants.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/constraints/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/constraints/predicate/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/stack.py +0 -0
- {relationalai/early_access/dsl/orm → v0/relationalai/early_access/dsl/core/temporal}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/utils.py +0 -0
- {relationalai/early_access/dsl/orm/measures → v0/relationalai/early_access/dsl/ir}/__init__.py +0 -0
- {relationalai/early_access/dsl/physical_metadata → v0/relationalai/early_access/dsl/ontologies}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/ontologies/raw_source.py +0 -0
- {relationalai/early_access/dsl/serialize → v0/relationalai/early_access/dsl/orm}/__init__.py +0 -0
- {relationalai/early_access/dsl/snow → v0/relationalai/early_access/dsl/orm/measures}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/orm/reasoner_errors.py +0 -0
- {relationalai/loaders → v0/relationalai/early_access/dsl/physical_metadata}/__init__.py +0 -0
- {relationalai/semantics/tests → v0/relationalai/early_access/dsl/serialize}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/serialize/binding_model.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/serialize/model.py +0 -0
- {relationalai/tools → v0/relationalai/early_access/dsl/snow}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/tests/__init__.py +0 -0
- {relationalai → v0/relationalai}/environments/ci.py +0 -0
- {relationalai → v0/relationalai}/environments/hex.py +0 -0
- {relationalai → v0/relationalai}/environments/terminal.py +0 -0
- {relationalai → v0/relationalai}/experimental/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/graphs.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/benchmarks/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/path_algorithms/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/filter.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/glushkov.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/transition.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/utilities/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/utilities/utilities.py +0 -0
- {relationalai → v0/relationalai}/metagen.py +0 -0
- {relationalai → v0/relationalai}/metamodel.py +0 -0
- {relationalai → v0/relationalai}/rel.py +0 -0
- {relationalai → v0/relationalai}/semantics/devtools/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/internal/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/internal/annotations.py +0 -0
- {relationalai → v0/relationalai}/semantics/lqp/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/lqp/ir.py +0 -0
- {relationalai → v0/relationalai}/semantics/lqp/pragmas.py +0 -0
- {relationalai → v0/relationalai}/semantics/lqp/rewrite/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/dataflow.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/ir.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/rewrite/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/typer/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/types.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/util.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/visitor.py +0 -0
- {relationalai → v0/relationalai}/semantics/reasoners/experimental/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/rel/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/sql/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/sql/executor/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/sql/rewrite/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/tests/logging.py +0 -0
- {relationalai → v0/relationalai}/std/aggregates.py +0 -0
- {relationalai → v0/relationalai}/std/dates.py +0 -0
- {relationalai → v0/relationalai}/std/graphs.py +0 -0
- {relationalai → v0/relationalai}/std/inspect.py +0 -0
- {relationalai → v0/relationalai}/std/math.py +0 -0
- {relationalai → v0/relationalai}/std/re.py +0 -0
- {relationalai → v0/relationalai}/std/strings.py +0 -0
- {relationalai → v0/relationalai}/tools/cleanup_snapshots.py +0 -0
- {relationalai → v0/relationalai}/tools/constants.py +0 -0
- {relationalai → v0/relationalai}/tools/query_utils.py +0 -0
- {relationalai → v0/relationalai}/tools/snapshot_viewer.py +0 -0
- {relationalai → v0/relationalai}/util/__init__.py +0 -0
- {relationalai → v0/relationalai}/util/constants.py +0 -0
- {relationalai → v0/relationalai}/util/graph.py +0 -0
- {relationalai → v0/relationalai}/util/timeout.py +0 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
from collections import OrderedDict
|
|
2
|
+
from itertools import product
|
|
3
|
+
from types import MappingProxyType
|
|
4
|
+
from typing import Union, Sequence
|
|
5
|
+
|
|
6
|
+
import v0.relationalai.semantics as qb
|
|
7
|
+
from v0.relationalai.semantics import where
|
|
8
|
+
from v0.relationalai.early_access.dsl.bindings.common import Binding, RoleBinding, IdentifierConceptBinding, BindableTable, \
|
|
9
|
+
BindableAttribute, SubtypeConceptBinding, ReferentConceptBinding
|
|
10
|
+
from v0.relationalai.early_access.dsl.codegen.binder import Binder
|
|
11
|
+
from v0.relationalai.early_access.dsl.codegen.common import BoundIdentifierConstraint, BoundRelationship
|
|
12
|
+
from v0.relationalai.early_access.dsl.codegen.relations import ValueMap, CompositeEntityMap, EntitySubtypeMap, \
|
|
13
|
+
UnionEntityMap, AbstractEntityMap, SimpleConstructorEntityMap, ReferentEntityMap, InlineValueMap, \
|
|
14
|
+
Map, MaterializedEntityMap, AbstractInlineEntityMap
|
|
15
|
+
from v0.relationalai.semantics.metamodel.util import OrderedSet
|
|
16
|
+
|
|
17
|
+
DEFAULT_WEAVER_CONFIG = MappingProxyType({
|
|
18
|
+
'inline_value_maps': False,
|
|
19
|
+
'inline_entity_maps': False,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Weaver:
|
|
24
|
+
|
|
25
|
+
def __init__(self, model, config=None):
|
|
26
|
+
self._model = model
|
|
27
|
+
self._config = config or DEFAULT_WEAVER_CONFIG
|
|
28
|
+
self._reasoner = self._model.reasoner()
|
|
29
|
+
self._binder = Binder(self._model)
|
|
30
|
+
|
|
31
|
+
# Lookup dictionaries for generated relations
|
|
32
|
+
self._binding_to_value_map: dict[Binding, Union[ValueMap, InlineValueMap]] = OrderedDict()
|
|
33
|
+
self._ctor_binding_to_entity_map:\
|
|
34
|
+
dict[IdentifierConceptBinding, Union[AbstractInlineEntityMap, MaterializedEntityMap]] = OrderedDict()
|
|
35
|
+
self._ref_binding_to_entity_map:\
|
|
36
|
+
dict[ReferentConceptBinding, Union[AbstractInlineEntityMap, MaterializedEntityMap]] = OrderedDict()
|
|
37
|
+
self._bound_identifier_to_composite_entity_map:\
|
|
38
|
+
dict[BoundIdentifierConstraint, OrderedSet[Union[AbstractInlineEntityMap, MaterializedEntityMap]]] = OrderedDict()
|
|
39
|
+
self._subtype_binding_to_entity_map:\
|
|
40
|
+
dict[Union[IdentifierConceptBinding, ReferentConceptBinding], Union[AbstractInlineEntityMap, MaterializedEntityMap]] = OrderedDict()
|
|
41
|
+
self._filtering_subtype_binding_to_entity_map:\
|
|
42
|
+
dict[SubtypeConceptBinding, Union[AbstractInlineEntityMap, MaterializedEntityMap]] = OrderedDict()
|
|
43
|
+
self._supertype_to_entity_map: dict[qb.Concept, UnionEntityMap] = OrderedDict()
|
|
44
|
+
|
|
45
|
+
def generate(self):
|
|
46
|
+
self._generate_value_maps()
|
|
47
|
+
self._generate_entity_maps()
|
|
48
|
+
self._generate_semantic_predicates()
|
|
49
|
+
|
|
50
|
+
def _generate_value_maps(self):
|
|
51
|
+
for binding in self._binder.value_type_bindings():
|
|
52
|
+
self._generate_value_map(binding)
|
|
53
|
+
|
|
54
|
+
def _generate_value_map(self, binding: Binding):
|
|
55
|
+
role = self._binder.lookup_binding_role(binding)
|
|
56
|
+
if self._cfg_should_inline_value_maps():
|
|
57
|
+
value_map = InlineValueMap(self._model, binding, role)
|
|
58
|
+
else:
|
|
59
|
+
value_map = ValueMap(self._model, binding, role)
|
|
60
|
+
self._binding_to_value_map[binding] = value_map
|
|
61
|
+
|
|
62
|
+
def _look_up_value_map(self, binding: Binding):
|
|
63
|
+
"""
|
|
64
|
+
Look up a value map in the model by value type binding.
|
|
65
|
+
"""
|
|
66
|
+
return self._binding_to_value_map[binding]
|
|
67
|
+
|
|
68
|
+
def _generate_entity_maps(self):
|
|
69
|
+
self._generate_simple_ctor_entity_maps()
|
|
70
|
+
self._generate_referent_entity_maps()
|
|
71
|
+
self._generate_composite_entity_maps()
|
|
72
|
+
self._generate_subtype_entity_maps()
|
|
73
|
+
self._generate_filtered_subtype_entity_maps()
|
|
74
|
+
self._generate_supertype_entity_maps()
|
|
75
|
+
|
|
76
|
+
def _generate_simple_ctor_entity_maps(self):
|
|
77
|
+
for binding in self._binder.constructor_bindings():
|
|
78
|
+
self._generate_simple_ctor_entity_map(binding)
|
|
79
|
+
|
|
80
|
+
def _generate_simple_ctor_entity_map(self, binding: IdentifierConceptBinding):
|
|
81
|
+
ctor_role = self._binder.lookup_binding_role(binding)
|
|
82
|
+
role = ctor_role.sibling()
|
|
83
|
+
assert role is not None, "Constructor binding must have a sibling role"
|
|
84
|
+
identifier_to_role_map = self._lookup_supertype_identifier_role_maps(binding)
|
|
85
|
+
|
|
86
|
+
entity_map = SimpleConstructorEntityMap(self._model, binding, role, identifier_to_role_map)
|
|
87
|
+
entity_map = self._try_materialize_entity_map(entity_map)
|
|
88
|
+
self._ctor_binding_to_entity_map[binding] = entity_map
|
|
89
|
+
|
|
90
|
+
def _lookup_supertype_identifier_role_maps(self, binding: IdentifierConceptBinding):
|
|
91
|
+
"""
|
|
92
|
+
Build a mapping from each reference scheme of the binding's concept to the corresponding constructing role map.
|
|
93
|
+
"""
|
|
94
|
+
concept = binding.entity_type
|
|
95
|
+
ref_scheme_to_role_map = OrderedDict()
|
|
96
|
+
|
|
97
|
+
for ref_scheme in self._reasoner.ref_schemes_of(concept):
|
|
98
|
+
constructed_concept = self._reasoner.identifies_concept(ref_scheme)
|
|
99
|
+
|
|
100
|
+
#=
|
|
101
|
+
# May need to look up the constructor binding for another concept with (.id) in the concept's hierarchy.
|
|
102
|
+
# E.g., if the concept is a subtype with multiple ref schemes, we need to look up the respective constructor
|
|
103
|
+
# binding for each supertype with a reference scheme.
|
|
104
|
+
#=
|
|
105
|
+
constructor_binding = (
|
|
106
|
+
binding if constructed_concept is concept
|
|
107
|
+
else self._binder.lookup_constructor_binding_by_source(constructed_concept, binding.column.table)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
ctor_role = self._binder.lookup_binding_role(constructor_binding)
|
|
111
|
+
player = ctor_role.player()
|
|
112
|
+
|
|
113
|
+
# If the constructor role is played by a primitive, use its sibling's player
|
|
114
|
+
if player._is_primitive():
|
|
115
|
+
sibling = ctor_role.sibling()
|
|
116
|
+
assert sibling is not None, "Constructor roles must have a sibling role"
|
|
117
|
+
player = sibling.player()
|
|
118
|
+
|
|
119
|
+
role_map = self._lookup_constructing_role_map(constructor_binding, player)
|
|
120
|
+
ref_scheme_to_role_map[ref_scheme] = role_map
|
|
121
|
+
return ref_scheme_to_role_map
|
|
122
|
+
|
|
123
|
+
def _lookup_constructing_role_map(self, binding: Union[IdentifierConceptBinding, ReferentConceptBinding],
|
|
124
|
+
concept: qb.Concept):
|
|
125
|
+
if self._binder.is_value_type_binding(binding):
|
|
126
|
+
role_map = self._binding_to_value_map[binding]
|
|
127
|
+
elif isinstance(binding, IdentifierConceptBinding):
|
|
128
|
+
#=
|
|
129
|
+
# This call is needed to ensure we look up the ctor binding for the concept, which may not be the same as
|
|
130
|
+
# the one in the binding. This is because the reference scheme may have an entity type in the constructing
|
|
131
|
+
# role, hence we need to look up the constructor binding and then the role map for that binding.
|
|
132
|
+
#=
|
|
133
|
+
ctor_binding = self._binder.lookup_constructor_binding(concept, binding.column)
|
|
134
|
+
assert isinstance(ctor_binding, IdentifierConceptBinding)
|
|
135
|
+
role_map = self._ctor_binding_to_entity_map[ctor_binding]
|
|
136
|
+
elif isinstance(binding, ReferentConceptBinding):
|
|
137
|
+
# TODO: check why we need `binder.lookup_constructor_binding` above?
|
|
138
|
+
role_map = self._ref_binding_to_entity_map[binding]
|
|
139
|
+
else:
|
|
140
|
+
raise ValueError(f'Cannot lookup constructing role map for binding {binding} and concept {concept}')
|
|
141
|
+
return role_map
|
|
142
|
+
|
|
143
|
+
def _generate_referent_entity_maps(self):
|
|
144
|
+
for binding in self._binder.referent_concept_bindings():
|
|
145
|
+
self._generate_referent_entity_map(binding)
|
|
146
|
+
|
|
147
|
+
def _generate_referent_entity_map(self, binding: ReferentConceptBinding):
|
|
148
|
+
ctor_role = self._binder.lookup_binding_role(binding)
|
|
149
|
+
role = ctor_role.sibling()
|
|
150
|
+
assert role is not None, "Referent concept binding must have a sibling role"
|
|
151
|
+
constructing_role_map = self._lookup_constructing_role_map(binding, binding.entity_type)
|
|
152
|
+
entity_map = ReferentEntityMap(self._model, binding, role, constructing_role_map)
|
|
153
|
+
entity_map = self._try_materialize_entity_map(entity_map)
|
|
154
|
+
self._ref_binding_to_entity_map[binding] = entity_map
|
|
155
|
+
|
|
156
|
+
def _generate_composite_entity_maps(self):
|
|
157
|
+
for constraint in self._binder.bound_identifier_constraints():
|
|
158
|
+
if constraint.is_external():
|
|
159
|
+
# generate a composite entity map
|
|
160
|
+
self._generate_composite_entity_map(constraint)
|
|
161
|
+
|
|
162
|
+
def _generate_composite_entity_map(self, constraint: BoundIdentifierConstraint):
|
|
163
|
+
role_map_combinations = self._composite_entity_map_combinations(constraint)
|
|
164
|
+
entity_concept = constraint.concept
|
|
165
|
+
for role_maps in role_map_combinations:
|
|
166
|
+
entity_map = CompositeEntityMap(self._model, entity_concept, *role_maps)
|
|
167
|
+
entity_map = self._try_materialize_entity_map(entity_map)
|
|
168
|
+
self._bound_identifier_to_composite_entity_map.setdefault(constraint, OrderedSet()).add(entity_map)
|
|
169
|
+
|
|
170
|
+
def _composite_entity_map_combinations(self, bound_uc: BoundIdentifierConstraint) -> Sequence[Sequence[Map]]:
|
|
171
|
+
role_bindings = bound_uc.role_bindings
|
|
172
|
+
# Build a list of binding lists for each role in the right order
|
|
173
|
+
role_binding_lists = [role_bindings[role] for role in bound_uc.constraint.roles()]
|
|
174
|
+
# Generate all possible combinations of bindings and convert each combination to a list
|
|
175
|
+
all_combinations = [list(combination) for combination in product(*role_binding_lists)] # pyright: ignore[reportArgumentType, reportCallIssue]
|
|
176
|
+
# Construct entity map combinations using the _ref_entity_map method
|
|
177
|
+
role_map_combinations = [
|
|
178
|
+
[self._lookup_ref_role_map(binding) for binding in combination]
|
|
179
|
+
for combination in all_combinations
|
|
180
|
+
]
|
|
181
|
+
return role_map_combinations
|
|
182
|
+
|
|
183
|
+
def _lookup_ref_role_map(self, binding: RoleBinding):
|
|
184
|
+
concept = binding.role.player()
|
|
185
|
+
if concept._is_primitive():
|
|
186
|
+
role_map = self._binding_to_value_map[binding]
|
|
187
|
+
else:
|
|
188
|
+
ctor_binding = self._binder.lookup_constructor_binding(concept, binding.column)
|
|
189
|
+
role_map = self._lookup_ref_role_map_by_ctor_binding(ctor_binding)
|
|
190
|
+
return role_map
|
|
191
|
+
|
|
192
|
+
def _lookup_ref_role_map_by_ctor_binding(self, binding: Union[IdentifierConceptBinding, ReferentConceptBinding]):
|
|
193
|
+
if isinstance(binding, IdentifierConceptBinding):
|
|
194
|
+
role_map = self._ctor_binding_to_entity_map[binding]
|
|
195
|
+
elif isinstance(binding, ReferentConceptBinding):
|
|
196
|
+
role_map = self._ref_binding_to_entity_map[binding]
|
|
197
|
+
else:
|
|
198
|
+
raise ValueError(f'Cannot lookup role map for binding {binding} - invalid type of binding')
|
|
199
|
+
return role_map
|
|
200
|
+
|
|
201
|
+
def _lookup_ref_entity_maps_by_column(self, concept: qb.Concept, column: BindableAttribute):
|
|
202
|
+
if self._reasoner.is_composite_concept(concept): # composite entity type
|
|
203
|
+
identifier_constraint = self._binder.lookup_bound_identifier_constraint_by_column(concept, column)
|
|
204
|
+
entity_map_candidates = self._bound_identifier_to_composite_entity_map[identifier_constraint]
|
|
205
|
+
# note: for now, we look up by table, though needs fixing
|
|
206
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, column.table)
|
|
207
|
+
elif self._reasoner.has_own_ref_scheme(concept): # simple entity type
|
|
208
|
+
entity_map_candidates = (list(self._ctor_binding_to_entity_map.values()) +
|
|
209
|
+
list(self._ref_binding_to_entity_map.values()))
|
|
210
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, column)
|
|
211
|
+
elif self._reasoner.is_exclusive_entity_type(concept): # exclusive entity type
|
|
212
|
+
entity_map_candidates = self._supertype_to_entity_map.values()
|
|
213
|
+
# note: for now, we look up by table, though needs fixing
|
|
214
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, column.table, strict_match=True)
|
|
215
|
+
else: # entity subtype
|
|
216
|
+
entity_map_candidates = self._subtype_binding_to_entity_map.values()
|
|
217
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, column)
|
|
218
|
+
|
|
219
|
+
def _lookup_ref_entity_maps_by_source(self, concept: qb.Concept, source: BindableTable):
|
|
220
|
+
if self._reasoner.is_composite_concept(concept): # composite entity type
|
|
221
|
+
identifier_constraints = self._binder.lookup_bound_identifier_constraint_by_source(concept, source)
|
|
222
|
+
entity_map_candidates = [entity_map for identifier_constraint in identifier_constraints
|
|
223
|
+
for entity_map in
|
|
224
|
+
self._bound_identifier_to_composite_entity_map[identifier_constraint]]
|
|
225
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, source)
|
|
226
|
+
elif self._reasoner.has_own_ref_scheme(concept): # simple entity type
|
|
227
|
+
entity_map_candidates = (list(self._ctor_binding_to_entity_map.values()) +
|
|
228
|
+
list(self._ref_binding_to_entity_map.values()))
|
|
229
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, source)
|
|
230
|
+
elif self._reasoner.is_exclusive_entity_type(concept): # exclusive entity type
|
|
231
|
+
entity_map_candidates = self._supertype_to_entity_map.values()
|
|
232
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, source, strict_match=True)
|
|
233
|
+
else: # entity subtype
|
|
234
|
+
entity_map_candidates = (list(self._subtype_binding_to_entity_map.values()) +
|
|
235
|
+
list(self._filtering_subtype_binding_to_entity_map.values()))
|
|
236
|
+
return self._find_matching_entity_maps(entity_map_candidates, concept, source)
|
|
237
|
+
# TODO : revise the above logic and see if uniqueness check is needed for anythine else
|
|
238
|
+
|
|
239
|
+
@staticmethod
|
|
240
|
+
def _find_matching_entity_maps(entity_maps, concept: qb.Concept,
|
|
241
|
+
source_or_col: Union[BindableTable, BindableAttribute],
|
|
242
|
+
strict_match: bool=False):
|
|
243
|
+
strictly_matching = OrderedSet()
|
|
244
|
+
loosely_matching = OrderedSet()
|
|
245
|
+
for entity_map in entity_maps:
|
|
246
|
+
value_player = entity_map.value_player()
|
|
247
|
+
if Weaver._matches_source(entity_map, source_or_col):
|
|
248
|
+
if concept is value_player:
|
|
249
|
+
strictly_matching.add(entity_map)
|
|
250
|
+
elif concept._isa(value_player):
|
|
251
|
+
loosely_matching.add(entity_map)
|
|
252
|
+
matching_entity_maps = strictly_matching if bool(strictly_matching) or strict_match else loosely_matching
|
|
253
|
+
if not matching_entity_maps:
|
|
254
|
+
raise ValueError(f'No entity map found for concept {concept} and {source_or_col}')
|
|
255
|
+
return matching_entity_maps
|
|
256
|
+
|
|
257
|
+
@staticmethod
|
|
258
|
+
def _matches_source(entity_map, source_or_col: Union[BindableTable, BindableAttribute]):
|
|
259
|
+
if isinstance(source_or_col, BindableTable):
|
|
260
|
+
return entity_map.table() == source_or_col
|
|
261
|
+
elif isinstance(source_or_col, BindableAttribute):
|
|
262
|
+
return entity_map.column() is source_or_col
|
|
263
|
+
else:
|
|
264
|
+
return False
|
|
265
|
+
|
|
266
|
+
def _generate_subtype_entity_maps(self):
|
|
267
|
+
for binding in self._binder.subtype_ctor_bindings():
|
|
268
|
+
self._generate_subtype_entity_map(binding)
|
|
269
|
+
|
|
270
|
+
def _generate_subtype_entity_map(self, binding: Union[IdentifierConceptBinding, ReferentConceptBinding]):
|
|
271
|
+
if isinstance(binding, ReferentConceptBinding):
|
|
272
|
+
ctor_entity_map = self._ref_binding_to_entity_map[binding]
|
|
273
|
+
else:
|
|
274
|
+
ctor_binding = self._binder.lookup_subtype_reference_binding(binding)
|
|
275
|
+
ctor_entity_map = self._lookup_ref_role_map_by_ctor_binding(ctor_binding)
|
|
276
|
+
entity_map = EntitySubtypeMap(self._model, binding, ctor_entity_map)
|
|
277
|
+
entity_map = self._try_materialize_entity_map(entity_map)
|
|
278
|
+
self._subtype_binding_to_entity_map[binding] = entity_map
|
|
279
|
+
|
|
280
|
+
def _generate_filtered_subtype_entity_maps(self):
|
|
281
|
+
for binding in self._binder.subtype_filtering_bindings():
|
|
282
|
+
self._generate_filtered_subtype_entity_map(binding)
|
|
283
|
+
|
|
284
|
+
def _generate_filtered_subtype_entity_map(self, binding: SubtypeConceptBinding):
|
|
285
|
+
ctor_binding = self._binder.lookup_subtype_reference_binding(binding)
|
|
286
|
+
ctor_entity_map = self._lookup_ref_role_map_by_ctor_binding(ctor_binding)
|
|
287
|
+
entity_map = EntitySubtypeMap(self._model, binding, ctor_entity_map)
|
|
288
|
+
entity_map = self._try_materialize_entity_map(entity_map)
|
|
289
|
+
self._filtering_subtype_binding_to_entity_map[binding] = entity_map
|
|
290
|
+
|
|
291
|
+
def _generate_supertype_entity_maps(self):
|
|
292
|
+
simple_subtype_maps = self._subtype_binding_to_entity_map.values()
|
|
293
|
+
filtering_subtype_maps = self._filtering_subtype_binding_to_entity_map.values()
|
|
294
|
+
subtype_maps = (OrderedSet()
|
|
295
|
+
.update(simple_subtype_maps)
|
|
296
|
+
.update(filtering_subtype_maps))
|
|
297
|
+
for subtype_map in subtype_maps:
|
|
298
|
+
self._generate_supertype_entity_map(subtype_map)
|
|
299
|
+
# after generating all supertype maps, try to materialize them
|
|
300
|
+
[entity_map.materialize_population() for entity_map in self._supertype_to_entity_map.values()]
|
|
301
|
+
|
|
302
|
+
def _generate_supertype_entity_map(self, subtype_map: AbstractEntityMap):
|
|
303
|
+
subtype = subtype_map.value_player()
|
|
304
|
+
supertype = self._reasoner.subtype_exclusive_supertype(subtype)
|
|
305
|
+
if not supertype:
|
|
306
|
+
return
|
|
307
|
+
supertype_map = self._supertype_to_entity_map.get(supertype)
|
|
308
|
+
if supertype_map is None:
|
|
309
|
+
supertype_map = UnionEntityMap(self._model, supertype, subtype_map, generate_population=True)
|
|
310
|
+
self._supertype_to_entity_map[supertype] = supertype_map
|
|
311
|
+
else:
|
|
312
|
+
supertype_map.update(subtype_map)
|
|
313
|
+
# go higher in the hierarchy
|
|
314
|
+
self._generate_supertype_entity_map(supertype_map)
|
|
315
|
+
|
|
316
|
+
def _generate_semantic_predicates(self):
|
|
317
|
+
for bound_relationship in self._binder.bound_relationships():
|
|
318
|
+
self._generate_semantic_predicate(bound_relationship)
|
|
319
|
+
|
|
320
|
+
def _generate_semantic_predicate(self, bound_relationship: BoundRelationship):
|
|
321
|
+
if bound_relationship.relationship._unary():
|
|
322
|
+
self._generate_unary_predicate_rule(bound_relationship)
|
|
323
|
+
else:
|
|
324
|
+
self._generate_nary_predicate_rule(bound_relationship)
|
|
325
|
+
|
|
326
|
+
def _generate_unary_predicate_rule(self, bound_relationship: BoundRelationship):
|
|
327
|
+
relationship = bound_relationship.relationship
|
|
328
|
+
roles = relationship._roles()
|
|
329
|
+
assert len(roles) == 1, "Unary predicate should have exactly one role"
|
|
330
|
+
unary_role = roles[0]
|
|
331
|
+
bound_concept = unary_role.player()
|
|
332
|
+
if bound_concept._is_primitive():
|
|
333
|
+
raise ValueError(f'Unary relationships cannot be defined on value types: {relationship}')
|
|
334
|
+
role_bindings = bound_relationship.bindings
|
|
335
|
+
for binding in role_bindings:
|
|
336
|
+
if not self._binder.is_filtering_binding(binding):
|
|
337
|
+
raise ValueError(f'Unary relationship roles must be bound by a filtering binding (use `filter_by`): {relationship}')
|
|
338
|
+
self._generate_unary_predicate_rule_body(bound_concept, binding, relationship)
|
|
339
|
+
|
|
340
|
+
def _generate_unary_predicate_rule_body(self, concept_player: qb.Concept, binding: Binding, relationship):
|
|
341
|
+
entity_maps = self._lookup_ref_entity_maps_by_column(concept_player, binding.column)
|
|
342
|
+
if not entity_maps:
|
|
343
|
+
raise ValueError(
|
|
344
|
+
f'Cannot generate semantic predicate for {relationship}, no role maps found')
|
|
345
|
+
for entity_map in entity_maps:
|
|
346
|
+
entity_ref, subformula_atoms = entity_map.formula()
|
|
347
|
+
where(
|
|
348
|
+
*subformula_atoms,
|
|
349
|
+
where(binding.filter_by)
|
|
350
|
+
).define(relationship(entity_ref))
|
|
351
|
+
|
|
352
|
+
def _generate_nary_predicate_rule(self, bound_relationship: BoundRelationship):
|
|
353
|
+
relationship = bound_relationship.relationship
|
|
354
|
+
roles = relationship._roles()
|
|
355
|
+
#=
|
|
356
|
+
# Each role should either be covered by a value map (value type role), or by an entity map (entity type role).
|
|
357
|
+
# The entity map either can be inferred if unique exists for the entity type, or must be generated by
|
|
358
|
+
# the respective EntityBinding.
|
|
359
|
+
#=
|
|
360
|
+
role_to_role_maps = OrderedDict()
|
|
361
|
+
role_map_casts_to = OrderedDict()
|
|
362
|
+
for role in roles:
|
|
363
|
+
role_concept = role.player()
|
|
364
|
+
if role_concept._is_primitive():
|
|
365
|
+
# TODO: [SB] I suppose we can do bound_relationship.role_bindings[role] here?
|
|
366
|
+
role_bindings = self._binder.lookup_role_bindings(role, bound_relationship.table)
|
|
367
|
+
role_maps = [self._binding_to_value_map[binding] for binding in role_bindings]
|
|
368
|
+
else:
|
|
369
|
+
role_is_bound = self._binder.is_role_bound(role, bound_relationship.table)
|
|
370
|
+
if role_is_bound:
|
|
371
|
+
# lookup referent entity maps
|
|
372
|
+
role_bindings = self._binder.lookup_role_bindings(role, bound_relationship.table)
|
|
373
|
+
role_maps = [entity_map for binding in role_bindings
|
|
374
|
+
for entity_map in self._lookup_ref_entity_maps_by_column(role.player(), binding.column)]
|
|
375
|
+
for role_map in role_maps:
|
|
376
|
+
role_map_concept = role_map.value_player()
|
|
377
|
+
if role_map_concept is not role_concept and self._reasoner.in_subtype_closure(role_concept, role_map_concept):
|
|
378
|
+
role_map_casts_to[role_map] = role_concept
|
|
379
|
+
else:
|
|
380
|
+
# lookup inferred entity map (note: must be unique?)
|
|
381
|
+
role_maps = [entity_map
|
|
382
|
+
for entity_map in self._lookup_ref_entity_maps_by_source(role.player(), bound_relationship.table)]
|
|
383
|
+
if not role_maps:
|
|
384
|
+
raise ValueError(f'Cannot generate semantic predicate for {relationship},'
|
|
385
|
+
f' no role maps found for role {role}')
|
|
386
|
+
role_to_role_maps[role] = role_maps
|
|
387
|
+
# if we got all roles with role maps, we can generate the rules
|
|
388
|
+
role_map_combinations = [list(combination) for combination in product(*role_to_role_maps.values())] # pyright: ignore[reportCallIssue]
|
|
389
|
+
for role_maps in role_map_combinations:
|
|
390
|
+
assert len(role_maps) > 0, "Must have at least one role map to derive a relationship"
|
|
391
|
+
casted_var_refs, atoms = [], []
|
|
392
|
+
for role_map in role_maps:
|
|
393
|
+
var_ref, subformula = role_map.formula()
|
|
394
|
+
if role_map in role_map_casts_to:
|
|
395
|
+
var_ref = role_map_casts_to[role_map](var_ref)
|
|
396
|
+
casted_var_refs.append(var_ref)
|
|
397
|
+
atoms.extend(subformula)
|
|
398
|
+
where(*atoms).define(relationship(*casted_var_refs))
|
|
399
|
+
|
|
400
|
+
def _try_materialize_entity_map(self, entity_map: AbstractInlineEntityMap) -> Union[AbstractInlineEntityMap, MaterializedEntityMap]:
|
|
401
|
+
if self._cfg_should_inline_entity_maps():
|
|
402
|
+
entity_map.materialize_population()
|
|
403
|
+
return entity_map
|
|
404
|
+
else:
|
|
405
|
+
return entity_map.materialize()
|
|
406
|
+
|
|
407
|
+
def _cfg_should_inline_value_maps(self):
|
|
408
|
+
"""
|
|
409
|
+
Check if the config should inline value maps.
|
|
410
|
+
"""
|
|
411
|
+
return self._config.get('inline_value_maps', DEFAULT_WEAVER_CONFIG['inline_value_maps'])
|
|
412
|
+
|
|
413
|
+
def _cfg_should_inline_entity_maps(self):
|
|
414
|
+
"""
|
|
415
|
+
Check if the config should inline entity maps.
|
|
416
|
+
"""
|
|
417
|
+
return self._config.get('inline_entity_maps', DEFAULT_WEAVER_CONFIG['inline_entity_maps'])
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright 2024 RelationalAI, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
# This module declares various kinds of logic builders, many of which
|
|
16
|
+
# must be accessed via facades in order to break circular dependencies
|
|
17
|
+
# among core classes. We declare the abstract builders here and their
|
|
18
|
+
# concrete main
|
|
19
|
+
#
|
|
20
|
+
from abc import abstractmethod
|
|
21
|
+
|
|
22
|
+
from v0.relationalai.early_access.dsl.core.exprs import Expr
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# We use ExprBuilders to build instances of Expr objects
|
|
26
|
+
#
|
|
27
|
+
class ExprBuilder:
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def build_divide(self, left, right) -> Expr: pass
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def build_plus(self, left, right) -> Expr: pass
|
|
34
|
+
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def build_minus(self, left, right) -> Expr: pass
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def build_modulus(self, left, right) -> Expr: pass
|
|
40
|
+
|
|
41
|
+
@abstractmethod
|
|
42
|
+
def build_negate(self, expr) -> Expr: pass
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
def build_times(self, left, right) -> Expr: pass
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from v0.relationalai.early_access.dsl.core.builders.scalar_constraint import ScalarConstraintBuilder
|
|
2
|
+
from v0.relationalai.early_access.dsl.core.constraints.predicate.atomic import Atom
|
|
3
|
+
from v0.relationalai.early_access.dsl.core.exprs.scalar import box_number
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# A LogicBuilder is used to construct LogicFragments
|
|
7
|
+
#
|
|
8
|
+
class LogicBuilder(ScalarConstraintBuilder):
|
|
9
|
+
|
|
10
|
+
def build_atom(self, rel, args):
|
|
11
|
+
nargs = len(args)
|
|
12
|
+
nroles = rel.arity()
|
|
13
|
+
|
|
14
|
+
if nargs != nroles:
|
|
15
|
+
raise Exception(
|
|
16
|
+
f"++ Error: Reference of {nroles}-ary relation {rel.qualified_name()} with {nargs} arguments")
|
|
17
|
+
|
|
18
|
+
boxedargs = [box_number(a) for a in args]
|
|
19
|
+
return Atom(rel, boxedargs)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from v0.relationalai.early_access.dsl.core.constraints.scalar import Constraint, ScalarConstraint
|
|
2
|
+
from v0.relationalai.early_access.dsl.core.exprs.scalar import box_number
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# A ScalarConstraintBuilder is used to build ScalarConstraints
|
|
6
|
+
# (comparisons between ScalarExpressions)
|
|
7
|
+
#
|
|
8
|
+
class ScalarConstraintBuilder:
|
|
9
|
+
|
|
10
|
+
def build_comparison(self, left, op, right) -> Constraint:
|
|
11
|
+
return ScalarConstraint(left, op, box_number(right))
|