relationalai 1.0.0a3__py3-none-any.whl → 1.0.0a5__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/config/config.py +47 -21
- relationalai/config/connections/__init__.py +5 -2
- relationalai/config/connections/duckdb.py +2 -2
- relationalai/config/connections/local.py +31 -0
- relationalai/config/connections/snowflake.py +0 -1
- relationalai/config/external/raiconfig_converter.py +235 -0
- relationalai/config/external/raiconfig_models.py +202 -0
- relationalai/config/external/utils.py +31 -0
- relationalai/config/shims.py +1 -0
- relationalai/semantics/__init__.py +10 -8
- relationalai/semantics/backends/sql/sql_compiler.py +1 -4
- relationalai/semantics/experimental/__init__.py +0 -0
- relationalai/semantics/experimental/builder.py +295 -0
- relationalai/semantics/experimental/builtins.py +154 -0
- relationalai/semantics/frontend/base.py +67 -42
- relationalai/semantics/frontend/core.py +34 -6
- relationalai/semantics/frontend/front_compiler.py +209 -37
- relationalai/semantics/frontend/pprint.py +6 -2
- relationalai/semantics/metamodel/__init__.py +7 -0
- relationalai/semantics/metamodel/metamodel.py +2 -0
- relationalai/semantics/metamodel/metamodel_analyzer.py +58 -16
- relationalai/semantics/metamodel/pprint.py +6 -1
- relationalai/semantics/metamodel/rewriter.py +11 -7
- relationalai/semantics/metamodel/typer.py +116 -41
- relationalai/semantics/reasoners/__init__.py +11 -0
- relationalai/semantics/reasoners/graph/__init__.py +35 -0
- relationalai/semantics/reasoners/graph/core.py +9028 -0
- relationalai/semantics/std/__init__.py +30 -10
- relationalai/semantics/std/aggregates.py +641 -12
- relationalai/semantics/std/common.py +146 -13
- relationalai/semantics/std/constraints.py +71 -1
- relationalai/semantics/std/datetime.py +904 -21
- relationalai/semantics/std/decimals.py +143 -2
- relationalai/semantics/std/floats.py +57 -4
- relationalai/semantics/std/integers.py +98 -4
- relationalai/semantics/std/math.py +857 -35
- relationalai/semantics/std/numbers.py +216 -20
- relationalai/semantics/std/re.py +213 -5
- relationalai/semantics/std/strings.py +437 -44
- relationalai/shims/executor.py +60 -52
- relationalai/shims/fixtures.py +85 -0
- relationalai/shims/helpers.py +26 -2
- relationalai/shims/hoister.py +28 -9
- relationalai/shims/mm2v0.py +204 -173
- relationalai/tools/cli/cli.py +192 -10
- relationalai/tools/cli/components/progress_reader.py +1 -1
- relationalai/tools/cli/docs.py +394 -0
- relationalai/tools/debugger.py +11 -4
- relationalai/tools/qb_debugger.py +435 -0
- relationalai/tools/typer_debugger.py +1 -2
- relationalai/util/dataclasses.py +3 -5
- relationalai/util/docutils.py +1 -2
- relationalai/util/error.py +2 -5
- relationalai/util/python.py +23 -0
- relationalai/util/runtime.py +1 -2
- relationalai/util/schema.py +2 -4
- relationalai/util/structures.py +4 -2
- relationalai/util/tracing.py +8 -2
- {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/METADATA +8 -5
- {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/RECORD +118 -95
- {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/WHEEL +1 -1
- v0/relationalai/__init__.py +1 -1
- v0/relationalai/clients/client.py +52 -18
- v0/relationalai/clients/exec_txn_poller.py +122 -0
- v0/relationalai/clients/local.py +23 -8
- v0/relationalai/clients/resources/azure/azure.py +36 -11
- v0/relationalai/clients/resources/snowflake/__init__.py +4 -4
- v0/relationalai/clients/resources/snowflake/cli_resources.py +12 -1
- v0/relationalai/clients/resources/snowflake/direct_access_resources.py +124 -100
- v0/relationalai/clients/resources/snowflake/engine_service.py +381 -0
- v0/relationalai/clients/resources/snowflake/engine_state_handlers.py +35 -29
- v0/relationalai/clients/resources/snowflake/error_handlers.py +43 -2
- v0/relationalai/clients/resources/snowflake/snowflake.py +277 -179
- v0/relationalai/clients/resources/snowflake/use_index_poller.py +8 -0
- v0/relationalai/clients/types.py +5 -0
- v0/relationalai/errors.py +19 -1
- v0/relationalai/semantics/lqp/algorithms.py +173 -0
- v0/relationalai/semantics/lqp/builtins.py +199 -2
- v0/relationalai/semantics/lqp/executor.py +68 -37
- v0/relationalai/semantics/lqp/ir.py +28 -2
- v0/relationalai/semantics/lqp/model2lqp.py +215 -45
- v0/relationalai/semantics/lqp/passes.py +13 -658
- v0/relationalai/semantics/lqp/rewrite/__init__.py +12 -0
- v0/relationalai/semantics/lqp/rewrite/algorithm.py +385 -0
- v0/relationalai/semantics/lqp/rewrite/constants_to_vars.py +70 -0
- v0/relationalai/semantics/lqp/rewrite/deduplicate_vars.py +104 -0
- v0/relationalai/semantics/lqp/rewrite/eliminate_data.py +108 -0
- v0/relationalai/semantics/lqp/rewrite/extract_keys.py +25 -3
- v0/relationalai/semantics/lqp/rewrite/period_math.py +77 -0
- v0/relationalai/semantics/lqp/rewrite/quantify_vars.py +65 -31
- v0/relationalai/semantics/lqp/rewrite/unify_definitions.py +317 -0
- v0/relationalai/semantics/lqp/utils.py +11 -1
- v0/relationalai/semantics/lqp/validators.py +14 -1
- v0/relationalai/semantics/metamodel/builtins.py +2 -1
- v0/relationalai/semantics/metamodel/compiler.py +2 -1
- v0/relationalai/semantics/metamodel/dependency.py +12 -3
- v0/relationalai/semantics/metamodel/executor.py +11 -1
- v0/relationalai/semantics/metamodel/factory.py +2 -2
- v0/relationalai/semantics/metamodel/helpers.py +7 -0
- v0/relationalai/semantics/metamodel/ir.py +3 -2
- v0/relationalai/semantics/metamodel/rewrite/dnf_union_splitter.py +30 -20
- v0/relationalai/semantics/metamodel/rewrite/flatten.py +50 -13
- v0/relationalai/semantics/metamodel/rewrite/format_outputs.py +9 -3
- v0/relationalai/semantics/metamodel/typer/checker.py +6 -4
- v0/relationalai/semantics/metamodel/typer/typer.py +4 -3
- v0/relationalai/semantics/metamodel/visitor.py +4 -3
- v0/relationalai/semantics/reasoners/optimization/solvers_dev.py +1 -1
- v0/relationalai/semantics/reasoners/optimization/solvers_pb.py +336 -86
- v0/relationalai/semantics/rel/compiler.py +2 -1
- v0/relationalai/semantics/rel/executor.py +3 -2
- v0/relationalai/semantics/tests/lqp/__init__.py +0 -0
- v0/relationalai/semantics/tests/lqp/algorithms.py +345 -0
- v0/relationalai/tools/cli.py +339 -186
- v0/relationalai/tools/cli_controls.py +216 -67
- v0/relationalai/tools/cli_helpers.py +410 -6
- v0/relationalai/util/format.py +5 -2
- {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/entry_points.txt +0 -0
- {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/top_level.txt +0 -0
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
|
|
2
|
+
"""
|
|
3
|
+
The RelationalAI Semantics Standard Library.
|
|
4
|
+
"""
|
|
2
5
|
from ..frontend.base import Variable, Literal, Expression
|
|
3
|
-
from ...util.error import warn, exc, source
|
|
6
|
+
from ...util.error import warn, exc, source, Part
|
|
4
7
|
from ...util.source import SourcePos
|
|
5
8
|
from decimal import Decimal as PyDecimal
|
|
6
9
|
import datetime as dt
|
|
7
10
|
from typing import Any, Union
|
|
8
11
|
|
|
12
|
+
__include_in_docs__ = True
|
|
13
|
+
|
|
9
14
|
#------------------------------------------------------
|
|
10
15
|
# Helpers
|
|
11
16
|
#------------------------------------------------------
|
|
12
17
|
|
|
13
18
|
def _deprecated_library(library, replacement=None, example=None):
|
|
14
19
|
replacement_message = ""
|
|
15
|
-
parts = [source(SourcePos.new())]
|
|
20
|
+
parts: list[Part] = [source(SourcePos.new())]
|
|
16
21
|
if replacement is not None:
|
|
17
22
|
replacement_message = f" Use '{replacement}' instead."
|
|
18
23
|
if example is not None:
|
|
@@ -21,7 +26,7 @@ def _deprecated_library(library, replacement=None, example=None):
|
|
|
21
26
|
|
|
22
27
|
def _deprecated_function(func_name, replacement=None, example=None):
|
|
23
28
|
replacement_message = ""
|
|
24
|
-
parts = [source(SourcePos.new())]
|
|
29
|
+
parts: list[Part] = [source(SourcePos.new())]
|
|
25
30
|
if replacement is not None:
|
|
26
31
|
replacement_message = f" Use '{replacement}' instead."
|
|
27
32
|
if example is not None:
|
|
@@ -29,15 +34,28 @@ def _deprecated_function(func_name, replacement=None, example=None):
|
|
|
29
34
|
warn("Deprecated function", f"The function '{func_name}' is deprecated.{replacement_message}", parts)
|
|
30
35
|
|
|
31
36
|
def _function_not_implemented(func_name: str):
|
|
32
|
-
parts = [source(SourcePos.new())]
|
|
37
|
+
parts: list[Part] = [source(SourcePos.new())]
|
|
33
38
|
exc("Function not implemented", f"The function '{func_name}' is not yet implemented in PyRel.", parts)
|
|
34
39
|
|
|
35
|
-
StringValue = Union[Variable, str]
|
|
36
|
-
IntegerValue = Union[Variable, int]
|
|
37
|
-
DateValue = Union[Variable, dt.date]
|
|
38
40
|
DateTimeValue = Union[Variable, dt.datetime]
|
|
39
|
-
|
|
41
|
+
""" A type representing a datetime value, which can be a literal `datetime.datetime` or a `Variable` resulting from
|
|
42
|
+
some other expression which will evaluate to a datetime. """
|
|
43
|
+
DateValue = Union[Variable, dt.date]
|
|
44
|
+
""" A type representing a date value, which can be a literal `datetime.date` or a `Variable` resulting from
|
|
45
|
+
some other expression which will evaluate to a date. """
|
|
40
46
|
FloatValue = Union[Variable, float]
|
|
47
|
+
""" A type representing a float value, which can be a literal `float` or a `Variable` resulting from
|
|
48
|
+
some other expression which will evaluate to a float. """
|
|
49
|
+
IntegerValue = Union[Variable, int]
|
|
50
|
+
""" A type representing an integer value, which can be a literal `int` or a `Variable` resulting from
|
|
51
|
+
some other expression which will evaluate to an integer. """
|
|
52
|
+
NumberValue = Union[Variable, float, int, PyDecimal]
|
|
53
|
+
""" A type representing a number value, which can be a literal `float`, `int`, or `Decimal`, or a `Variable` resulting from
|
|
54
|
+
some other expression which will evaluate to a number. """
|
|
55
|
+
StringValue = Union[Variable, str]
|
|
56
|
+
""" A type representing a string value, which can be a literal `str` or a `Variable` resulting from
|
|
57
|
+
some other expression which will evaluate to a string. """
|
|
58
|
+
|
|
41
59
|
|
|
42
60
|
def _get_number_value(value: Any) -> Union[float, int, PyDecimal, None]:
|
|
43
61
|
""" If the value is a number literal, return its value as a Python number. """
|
|
@@ -51,7 +69,9 @@ def _get_number_value(value: Any) -> Union[float, int, PyDecimal, None]:
|
|
|
51
69
|
#------------------------------------------------------
|
|
52
70
|
# Libraries
|
|
53
71
|
#------------------------------------------------------
|
|
54
|
-
|
|
72
|
+
# Import submodules after type aliases are defined to avoid circular imports
|
|
73
|
+
from . import aggregates, common, datetime, decimals, integers, math, numbers, re, strings, constraints # noqa: E402
|
|
74
|
+
|
|
55
75
|
__all__ = [
|
|
56
76
|
"aggregates",
|
|
57
77
|
"common",
|
|
@@ -70,5 +90,5 @@ __all__ = [
|
|
|
70
90
|
#------------------------------------------------------
|
|
71
91
|
|
|
72
92
|
def range(*args: IntegerValue) -> Expression:
|
|
73
|
-
_deprecated_function("std.range", "common.range")
|
|
93
|
+
_deprecated_function("std.range", "std.common.range")
|
|
74
94
|
return common.range(*args)
|