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.
Files changed (118) hide show
  1. relationalai/config/config.py +47 -21
  2. relationalai/config/connections/__init__.py +5 -2
  3. relationalai/config/connections/duckdb.py +2 -2
  4. relationalai/config/connections/local.py +31 -0
  5. relationalai/config/connections/snowflake.py +0 -1
  6. relationalai/config/external/raiconfig_converter.py +235 -0
  7. relationalai/config/external/raiconfig_models.py +202 -0
  8. relationalai/config/external/utils.py +31 -0
  9. relationalai/config/shims.py +1 -0
  10. relationalai/semantics/__init__.py +10 -8
  11. relationalai/semantics/backends/sql/sql_compiler.py +1 -4
  12. relationalai/semantics/experimental/__init__.py +0 -0
  13. relationalai/semantics/experimental/builder.py +295 -0
  14. relationalai/semantics/experimental/builtins.py +154 -0
  15. relationalai/semantics/frontend/base.py +67 -42
  16. relationalai/semantics/frontend/core.py +34 -6
  17. relationalai/semantics/frontend/front_compiler.py +209 -37
  18. relationalai/semantics/frontend/pprint.py +6 -2
  19. relationalai/semantics/metamodel/__init__.py +7 -0
  20. relationalai/semantics/metamodel/metamodel.py +2 -0
  21. relationalai/semantics/metamodel/metamodel_analyzer.py +58 -16
  22. relationalai/semantics/metamodel/pprint.py +6 -1
  23. relationalai/semantics/metamodel/rewriter.py +11 -7
  24. relationalai/semantics/metamodel/typer.py +116 -41
  25. relationalai/semantics/reasoners/__init__.py +11 -0
  26. relationalai/semantics/reasoners/graph/__init__.py +35 -0
  27. relationalai/semantics/reasoners/graph/core.py +9028 -0
  28. relationalai/semantics/std/__init__.py +30 -10
  29. relationalai/semantics/std/aggregates.py +641 -12
  30. relationalai/semantics/std/common.py +146 -13
  31. relationalai/semantics/std/constraints.py +71 -1
  32. relationalai/semantics/std/datetime.py +904 -21
  33. relationalai/semantics/std/decimals.py +143 -2
  34. relationalai/semantics/std/floats.py +57 -4
  35. relationalai/semantics/std/integers.py +98 -4
  36. relationalai/semantics/std/math.py +857 -35
  37. relationalai/semantics/std/numbers.py +216 -20
  38. relationalai/semantics/std/re.py +213 -5
  39. relationalai/semantics/std/strings.py +437 -44
  40. relationalai/shims/executor.py +60 -52
  41. relationalai/shims/fixtures.py +85 -0
  42. relationalai/shims/helpers.py +26 -2
  43. relationalai/shims/hoister.py +28 -9
  44. relationalai/shims/mm2v0.py +204 -173
  45. relationalai/tools/cli/cli.py +192 -10
  46. relationalai/tools/cli/components/progress_reader.py +1 -1
  47. relationalai/tools/cli/docs.py +394 -0
  48. relationalai/tools/debugger.py +11 -4
  49. relationalai/tools/qb_debugger.py +435 -0
  50. relationalai/tools/typer_debugger.py +1 -2
  51. relationalai/util/dataclasses.py +3 -5
  52. relationalai/util/docutils.py +1 -2
  53. relationalai/util/error.py +2 -5
  54. relationalai/util/python.py +23 -0
  55. relationalai/util/runtime.py +1 -2
  56. relationalai/util/schema.py +2 -4
  57. relationalai/util/structures.py +4 -2
  58. relationalai/util/tracing.py +8 -2
  59. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/METADATA +8 -5
  60. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/RECORD +118 -95
  61. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/WHEEL +1 -1
  62. v0/relationalai/__init__.py +1 -1
  63. v0/relationalai/clients/client.py +52 -18
  64. v0/relationalai/clients/exec_txn_poller.py +122 -0
  65. v0/relationalai/clients/local.py +23 -8
  66. v0/relationalai/clients/resources/azure/azure.py +36 -11
  67. v0/relationalai/clients/resources/snowflake/__init__.py +4 -4
  68. v0/relationalai/clients/resources/snowflake/cli_resources.py +12 -1
  69. v0/relationalai/clients/resources/snowflake/direct_access_resources.py +124 -100
  70. v0/relationalai/clients/resources/snowflake/engine_service.py +381 -0
  71. v0/relationalai/clients/resources/snowflake/engine_state_handlers.py +35 -29
  72. v0/relationalai/clients/resources/snowflake/error_handlers.py +43 -2
  73. v0/relationalai/clients/resources/snowflake/snowflake.py +277 -179
  74. v0/relationalai/clients/resources/snowflake/use_index_poller.py +8 -0
  75. v0/relationalai/clients/types.py +5 -0
  76. v0/relationalai/errors.py +19 -1
  77. v0/relationalai/semantics/lqp/algorithms.py +173 -0
  78. v0/relationalai/semantics/lqp/builtins.py +199 -2
  79. v0/relationalai/semantics/lqp/executor.py +68 -37
  80. v0/relationalai/semantics/lqp/ir.py +28 -2
  81. v0/relationalai/semantics/lqp/model2lqp.py +215 -45
  82. v0/relationalai/semantics/lqp/passes.py +13 -658
  83. v0/relationalai/semantics/lqp/rewrite/__init__.py +12 -0
  84. v0/relationalai/semantics/lqp/rewrite/algorithm.py +385 -0
  85. v0/relationalai/semantics/lqp/rewrite/constants_to_vars.py +70 -0
  86. v0/relationalai/semantics/lqp/rewrite/deduplicate_vars.py +104 -0
  87. v0/relationalai/semantics/lqp/rewrite/eliminate_data.py +108 -0
  88. v0/relationalai/semantics/lqp/rewrite/extract_keys.py +25 -3
  89. v0/relationalai/semantics/lqp/rewrite/period_math.py +77 -0
  90. v0/relationalai/semantics/lqp/rewrite/quantify_vars.py +65 -31
  91. v0/relationalai/semantics/lqp/rewrite/unify_definitions.py +317 -0
  92. v0/relationalai/semantics/lqp/utils.py +11 -1
  93. v0/relationalai/semantics/lqp/validators.py +14 -1
  94. v0/relationalai/semantics/metamodel/builtins.py +2 -1
  95. v0/relationalai/semantics/metamodel/compiler.py +2 -1
  96. v0/relationalai/semantics/metamodel/dependency.py +12 -3
  97. v0/relationalai/semantics/metamodel/executor.py +11 -1
  98. v0/relationalai/semantics/metamodel/factory.py +2 -2
  99. v0/relationalai/semantics/metamodel/helpers.py +7 -0
  100. v0/relationalai/semantics/metamodel/ir.py +3 -2
  101. v0/relationalai/semantics/metamodel/rewrite/dnf_union_splitter.py +30 -20
  102. v0/relationalai/semantics/metamodel/rewrite/flatten.py +50 -13
  103. v0/relationalai/semantics/metamodel/rewrite/format_outputs.py +9 -3
  104. v0/relationalai/semantics/metamodel/typer/checker.py +6 -4
  105. v0/relationalai/semantics/metamodel/typer/typer.py +4 -3
  106. v0/relationalai/semantics/metamodel/visitor.py +4 -3
  107. v0/relationalai/semantics/reasoners/optimization/solvers_dev.py +1 -1
  108. v0/relationalai/semantics/reasoners/optimization/solvers_pb.py +336 -86
  109. v0/relationalai/semantics/rel/compiler.py +2 -1
  110. v0/relationalai/semantics/rel/executor.py +3 -2
  111. v0/relationalai/semantics/tests/lqp/__init__.py +0 -0
  112. v0/relationalai/semantics/tests/lqp/algorithms.py +345 -0
  113. v0/relationalai/tools/cli.py +339 -186
  114. v0/relationalai/tools/cli_controls.py +216 -67
  115. v0/relationalai/tools/cli_helpers.py +410 -6
  116. v0/relationalai/util/format.py +5 -2
  117. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/entry_points.txt +0 -0
  118. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/top_level.txt +0 -0
@@ -1,23 +1,96 @@
1
+ """
2
+ Decimal manipulation functions.
3
+
4
+ .. deprecated:: 0.13.0
5
+ This module is deprecated. Use `std.numbers` instead.
6
+
7
+ This module provides functions for working with decimal numbers including
8
+ type construction, parsing from strings, and querying decimal properties.
9
+ """
1
10
  from __future__ import annotations
2
11
 
3
12
  from ..frontend.base import Concept, NumberConcept, Expression, Variable
13
+ from relationalai.util.docutils import include_in_docs
4
14
 
5
15
  from . import NumberValue, numbers, _deprecated_library
6
16
 
17
+ __include_in_docs__ = True
18
+
7
19
 
8
20
  #--------------------------------------------------
9
21
  # Constructors
10
22
  #--------------------------------------------------
11
23
 
12
- def decimal(value: NumberValue, precision=38, scale=14) -> Variable:
24
+ @include_in_docs
25
+ def decimal(value: NumberValue, precision:int=38, scale:int=14) -> Variable:
26
+ """
27
+ Create a decimal with specified precision and scale.
28
+
29
+ .. deprecated:: 0.13.0
30
+ Use `numbers.number(value, precision, scale) <std.numbers.number>` instead.
31
+
32
+ Parameters
33
+ ----------
34
+ value: NumberValue
35
+ The numeric value.
36
+ precision: int
37
+ The precision (total number of digits).
38
+ scale: int
39
+ The scale (number of decimal places).
40
+
41
+ Returns
42
+ -------
43
+ Variable
44
+ A Variable representing the decimal value.
45
+ """
13
46
  _warning(f"numbers.number({value}, {precision}, {scale})")
14
47
  return numbers.number(value, precision, scale)
15
48
 
16
- def parse_decimal(value: str, precision=38, scale=14) -> Expression:
49
+ @include_in_docs
50
+ def parse_decimal(value: str, precision:int=38, scale:int=14) -> Expression:
51
+ """
52
+ Parse a string into a decimal with specified precision and scale.
53
+
54
+ .. deprecated:: 0.13.0
55
+ Use `numbers.parse_number(value, precision, scale) <std.numbers.parse_number>` instead.
56
+
57
+ Parameters
58
+ ----------
59
+ value: str
60
+ The string value to parse.
61
+ precision: int
62
+ The precision (total number of digits).
63
+ scale: int
64
+ The scale (number of decimal places).
65
+
66
+ Returns
67
+ -------
68
+ Expression
69
+ An Expression computing the parsed decimal.
70
+ """
17
71
  _warning(f"numbers.parse_number({value}, {precision}, {scale})")
18
72
  return numbers.parse_number(value, precision, scale)
19
73
 
74
+ @include_in_docs
20
75
  def parse(value: str, decimal: Concept) -> Expression:
76
+ """
77
+ Parse a string into a decimal with the type specified by decimal concept.
78
+
79
+ .. deprecated:: 0.13.0
80
+ Use `numbers.parse(value, decimal) <std.numbers.parse>` instead.
81
+
82
+ Parameters
83
+ ----------
84
+ value: str
85
+ The string value to parse.
86
+ decimal: Concept
87
+ The NumberConcept specifying the decimal type.
88
+
89
+ Returns
90
+ -------
91
+ Expression
92
+ An Expression computing the parsed decimal.
93
+ """
21
94
  assert isinstance(decimal, NumberConcept)
22
95
  _warning(f"numbers.parse({value}, {decimal})")
23
96
  return numbers.parse(value, decimal)
@@ -26,22 +99,90 @@ def parse(value: str, decimal: Concept) -> Expression:
26
99
  # Decimal information
27
100
  #--------------------------------------------------
28
101
 
102
+ @include_in_docs
29
103
  def is_decimal(decimal: Concept) -> bool:
104
+ """
105
+ Check if a concept represents a decimal number.
106
+
107
+ .. deprecated:: 0.13.0
108
+ Use `numbers.is_number(decimal) <std.numbers.is_number>` instead.
109
+
110
+ Parameters
111
+ ----------
112
+ decimal: Concept
113
+ The NumberConcept to check.
114
+
115
+ Returns
116
+ -------
117
+ bool
118
+ True if the concept is a decimal number.
119
+ """
30
120
  assert isinstance(decimal, NumberConcept)
31
121
  _warning(f"numbers.is_number({decimal})")
32
122
  return numbers.is_number(decimal)
33
123
 
124
+ @include_in_docs
34
125
  def precision(decimal: Concept) -> int:
126
+ """
127
+ Get the precision (total number of digits) of a decimal concept.
128
+
129
+ .. deprecated:: 0.13.0
130
+ Use `numbers.precision(decimal) <std.numbers.precision>` instead.
131
+
132
+ Parameters
133
+ ----------
134
+ decimal: Concept
135
+ The NumberConcept to query.
136
+
137
+ Returns
138
+ -------
139
+ int
140
+ The precision of the decimal.
141
+ """
35
142
  assert isinstance(decimal, NumberConcept)
36
143
  _warning(f"numbers.precision({decimal})")
37
144
  return numbers.precision(decimal)
38
145
 
146
+ @include_in_docs
39
147
  def scale(decimal: Concept) -> int:
148
+ """
149
+ Get the scale (number of decimal places) of a decimal concept.
150
+
151
+ .. deprecated:: 0.13.0
152
+ Use `numbers.scale(decimal) <std.numbers.scale>` instead.
153
+
154
+ Parameters
155
+ ----------
156
+ decimal: Concept
157
+ The NumberConcept to query.
158
+
159
+ Returns
160
+ -------
161
+ int
162
+ The scale of the decimal.
163
+ """
40
164
  assert isinstance(decimal, NumberConcept)
41
165
  _warning(f"numbers.scale({decimal})")
42
166
  return numbers.scale(decimal)
43
167
 
168
+ @include_in_docs
44
169
  def size(decimal: Concept) -> int:
170
+ """
171
+ Get the size (in bytes) of a decimal concept.
172
+
173
+ .. deprecated:: 0.13.0
174
+ Use `numbers.size(decimal) <std.numbers.size>` instead.
175
+
176
+ Parameters
177
+ ----------
178
+ decimal: Concept
179
+ The NumberConcept to query.
180
+
181
+ Returns
182
+ -------
183
+ int
184
+ The size in bytes of the decimal.
185
+ """
45
186
  assert isinstance(decimal, NumberConcept)
46
187
  _warning(f"numbers.size({decimal})")
47
188
  return numbers.size(decimal)
@@ -1,15 +1,68 @@
1
+ """
2
+ Float manipulation functions.
3
+
4
+ This module provides functions for working with floating-point numbers including
5
+ type conversion and parsing from strings.
6
+ """
7
+ from __future__ import annotations
8
+
1
9
  from . import StringValue
2
10
  from ..frontend.base import Library, Expression, Field, Value
3
- from ..frontend.core import Float, String, Number
4
- from decimal import Decimal as PyDecimal
11
+ from ..frontend.core import Float, String
12
+ from relationalai.util.docutils import include_in_docs
13
+
14
+ __include_in_docs__ = True
5
15
 
6
16
  # the front-end library object
7
17
  library = Library("floats")
8
18
 
9
- _parse_float = library.Relation("parse_float", [Field.input("value", String), Field("result", Float)])
10
-
19
+ @include_in_docs
11
20
  def float(value: Value) -> Expression:
21
+ """
22
+ Convert a value to a Float.
23
+
24
+ Parameters
25
+ ----------
26
+ value: Value
27
+ The value to convert to a `Float`.
28
+
29
+ Returns
30
+ -------
31
+ Expression
32
+ An `Expression` computing the `Float` conversion. Returns `Float`.
33
+
34
+ Examples
35
+ --------
36
+ Convert various types to floats:
37
+
38
+ >>> floats.float(42)
39
+ >>> floats.float(Product.price)
40
+ """
12
41
  return Float(value)
13
42
 
43
+ _parse_float = library.Relation("parse_float", [Field.input("value", String), Field("result", Float)])
44
+
45
+ @include_in_docs
14
46
  def parse_float(value: StringValue) -> Expression:
47
+ """
48
+ Parse a string into a Float.
49
+
50
+ Parameters
51
+ ----------
52
+ value: StringValue
53
+ The string value to parse.
54
+
55
+ Returns
56
+ -------
57
+ Expression
58
+ An `Expression` computing the parsed `Float`. Returns `Float`.
59
+
60
+ Examples
61
+ --------
62
+ Parse strings into floats:
63
+
64
+ >>> floats.parse_float("3.14159")
65
+ >>> floats.parse_float("2.3E40")
66
+ >>> floats.parse_float(Measurement.value_str)
67
+ """
15
68
  return _parse_float(value)
@@ -1,31 +1,125 @@
1
+ """
2
+ Integer manipulation functions.
3
+
4
+ .. deprecated:: 0.13.0
5
+ This module is deprecated. Use `std.numbers` instead.
6
+
7
+ This module provides functions for working with integers including type coercion
8
+ and parsing from strings.
9
+ """
1
10
  from __future__ import annotations
2
11
 
3
12
  from ..frontend.base import Expression, Variable
4
13
  from ..frontend.core import Integer
14
+ from relationalai.util.docutils import include_in_docs
5
15
 
6
16
  from . import StringValue, IntegerValue, numbers, _deprecated_library
7
17
 
18
+ __include_in_docs__ = True
19
+
8
20
 
9
- # Coerce a number to Int64.
21
+ @include_in_docs
10
22
  def int64(value: IntegerValue) -> Variable:
23
+ """
24
+ Coerce a number to Int64.
25
+
26
+ .. deprecated:: 0.13.0
27
+ Use `std.numbers` functions instead.
28
+
29
+ Parameters
30
+ ----------
31
+ value: IntegerValue
32
+ The integer value to coerce.
33
+
34
+ Returns
35
+ -------
36
+ Variable
37
+ A Variable representing the Int64 value.
38
+ """
11
39
  _warning()
12
40
  return Integer(value)
13
41
 
14
- # Coerce a number to Int128.
42
+ @include_in_docs
15
43
  def int128(value: IntegerValue) -> Variable:
44
+ """
45
+ Coerce a number to Int128.
46
+
47
+ .. deprecated:: 0.13.0
48
+ Use `std.numbers` functions instead.
49
+
50
+ Parameters
51
+ ----------
52
+ value: IntegerValue
53
+ The integer value to coerce.
54
+
55
+ Returns
56
+ -------
57
+ Variable
58
+ A Variable representing the Int128 value.
59
+ """
16
60
  _warning()
17
61
  return Integer(value)
18
62
 
63
+ @include_in_docs
19
64
  def parse_int64(value: StringValue) -> Expression:
20
- _warning(f"numbers.parse_number({value}, , 0)")
65
+ """
66
+ Parse a string into an Int64.
67
+
68
+ .. deprecated:: 0.13.0
69
+ Use `numbers.parse_number(value, 19, 0) <std.numbers.parse_number>` instead.
70
+
71
+ Parameters
72
+ ----------
73
+ value: StringValue
74
+ The string value to parse.
75
+
76
+ Returns
77
+ -------
78
+ Expression
79
+ An Expression computing the parsed Int64.
80
+ """
81
+ _warning(f"numbers.parse_number({value}, 19, 0)")
21
82
  return numbers.parse_number(value, 19, 0)
22
83
 
84
+ @include_in_docs
23
85
  def parse_int128(value: StringValue) -> Expression:
86
+ """
87
+ Parse a string into an Int128.
88
+
89
+ .. deprecated:: 0.13.0
90
+ Use `numbers.parse_number(value, 38, 0) <std.numbers.parse_number>` instead.
91
+
92
+ Parameters
93
+ ----------
94
+ value: StringValue
95
+ The string value to parse.
96
+
97
+ Returns
98
+ -------
99
+ Expression
100
+ An Expression computing the parsed Int128.
101
+ """
24
102
  _warning(f"numbers.parse_number({value}, 38, 0)")
25
103
  return numbers.parse_number(value, 38, 0)
26
104
 
27
- # Alias parse_int128 to parse
105
+ @include_in_docs
28
106
  def parse(value: StringValue) -> Expression:
107
+ """
108
+ Parse a string into an Int128 (alias for parse_int128).
109
+
110
+ .. deprecated:: 0.13.0
111
+ Use `numbers.parse_number(value, 38, 0) <std.numbers.parse_number>` instead.
112
+
113
+ Parameters
114
+ ----------
115
+ value: StringValue
116
+ The string value to parse.
117
+
118
+ Returns
119
+ -------
120
+ Expression
121
+ An Expression computing the parsed Int128.
122
+ """
29
123
  return parse_int128(value)
30
124
 
31
125