relationalai 1.0.0a2__py3-none-any.whl → 1.0.0a4__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 (57) hide show
  1. relationalai/config/shims.py +1 -0
  2. relationalai/semantics/__init__.py +7 -1
  3. relationalai/semantics/frontend/base.py +19 -13
  4. relationalai/semantics/frontend/core.py +30 -2
  5. relationalai/semantics/frontend/front_compiler.py +38 -11
  6. relationalai/semantics/frontend/pprint.py +1 -1
  7. relationalai/semantics/metamodel/rewriter.py +6 -2
  8. relationalai/semantics/metamodel/typer.py +70 -26
  9. relationalai/semantics/reasoners/__init__.py +11 -0
  10. relationalai/semantics/reasoners/graph/__init__.py +38 -0
  11. relationalai/semantics/reasoners/graph/core.py +9015 -0
  12. relationalai/shims/executor.py +4 -1
  13. relationalai/shims/hoister.py +9 -0
  14. relationalai/shims/mm2v0.py +47 -34
  15. relationalai/tools/cli/cli.py +138 -0
  16. relationalai/tools/cli/docs.py +394 -0
  17. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/METADATA +5 -3
  18. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/RECORD +57 -43
  19. v0/relationalai/__init__.py +69 -22
  20. v0/relationalai/clients/__init__.py +15 -2
  21. v0/relationalai/clients/client.py +4 -4
  22. v0/relationalai/clients/exec_txn_poller.py +91 -0
  23. v0/relationalai/clients/local.py +5 -5
  24. v0/relationalai/clients/resources/__init__.py +8 -0
  25. v0/relationalai/clients/{azure.py → resources/azure/azure.py} +12 -12
  26. v0/relationalai/clients/resources/snowflake/__init__.py +20 -0
  27. v0/relationalai/clients/resources/snowflake/cli_resources.py +87 -0
  28. v0/relationalai/clients/resources/snowflake/direct_access_resources.py +717 -0
  29. v0/relationalai/clients/resources/snowflake/engine_state_handlers.py +309 -0
  30. v0/relationalai/clients/resources/snowflake/error_handlers.py +199 -0
  31. v0/relationalai/clients/resources/snowflake/resources_factory.py +99 -0
  32. v0/relationalai/clients/{snowflake.py → resources/snowflake/snowflake.py} +642 -1399
  33. v0/relationalai/clients/{use_index_poller.py → resources/snowflake/use_index_poller.py} +51 -12
  34. v0/relationalai/clients/resources/snowflake/use_index_resources.py +188 -0
  35. v0/relationalai/clients/resources/snowflake/util.py +387 -0
  36. v0/relationalai/early_access/dsl/ir/executor.py +4 -4
  37. v0/relationalai/early_access/dsl/snow/api.py +2 -1
  38. v0/relationalai/errors.py +18 -0
  39. v0/relationalai/experimental/solvers.py +7 -7
  40. v0/relationalai/semantics/devtools/benchmark_lqp.py +4 -5
  41. v0/relationalai/semantics/devtools/extract_lqp.py +1 -1
  42. v0/relationalai/semantics/internal/snowflake.py +1 -1
  43. v0/relationalai/semantics/lqp/executor.py +7 -12
  44. v0/relationalai/semantics/lqp/rewrite/extract_keys.py +25 -3
  45. v0/relationalai/semantics/metamodel/util.py +6 -5
  46. v0/relationalai/semantics/reasoners/optimization/solvers_pb.py +335 -84
  47. v0/relationalai/semantics/rel/executor.py +14 -11
  48. v0/relationalai/semantics/sql/executor/snowflake.py +9 -5
  49. v0/relationalai/semantics/tests/test_snapshot_abstract.py +1 -1
  50. v0/relationalai/tools/cli.py +26 -30
  51. v0/relationalai/tools/cli_helpers.py +10 -2
  52. v0/relationalai/util/otel_configuration.py +2 -1
  53. v0/relationalai/util/otel_handler.py +1 -1
  54. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/WHEEL +0 -0
  55. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/entry_points.txt +0 -0
  56. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/top_level.txt +0 -0
  57. /v0/relationalai/clients/{cache_store.py → resources/snowflake/cache_store.py} +0 -0
@@ -0,0 +1,20 @@
1
+ """
2
+ Snowflake resources module.
3
+ """
4
+ # Import order matters - Resources must be imported first since other classes depend on it
5
+ from .snowflake import Resources, Provider, Graph, SnowflakeClient, APP_NAME, PYREL_ROOT_DB, ExecContext, INTERNAL_ENGINE_SIZES, ENGINE_SIZES_AWS, ENGINE_SIZES_AZURE, PrimaryKey, PRINT_TXN_PROGRESS_FLAG
6
+
7
+ # These imports depend on Resources, so they come after
8
+ from .cli_resources import CLIResources
9
+ from .use_index_resources import UseIndexResources
10
+ from .direct_access_resources import DirectAccessResources
11
+ from .resources_factory import create_resources_instance
12
+
13
+ __all__ = [
14
+ 'Resources', 'DirectAccessResources', 'Provider', 'Graph', 'SnowflakeClient',
15
+ 'APP_NAME', 'PYREL_ROOT_DB', 'CLIResources', 'UseIndexResources', 'ExecContext',
16
+ 'INTERNAL_ENGINE_SIZES', 'ENGINE_SIZES_AWS', 'ENGINE_SIZES_AZURE', 'PrimaryKey',
17
+ 'PRINT_TXN_PROGRESS_FLAG', 'create_resources_instance',
18
+ ]
19
+
20
+
@@ -0,0 +1,87 @@
1
+ """
2
+ CLI Resources - Resources class for CLI operations.
3
+ Re-raises exceptions without transformation and provides CLI utility methods.
4
+ """
5
+ from __future__ import annotations
6
+ import json
7
+ from typing import Any
8
+
9
+ from ....tools.constants import RAI_APP_NAME
10
+
11
+ # Import Resources from snowflake - this creates a dependency but no circular import
12
+ # since snowflake.py doesn't import from this file
13
+ from .snowflake import Resources, ExecContext
14
+
15
+
16
+ class CLIResources(Resources):
17
+ """
18
+ Resources class for CLI operations.
19
+ Re-raises exceptions without transformation and provides CLI utility methods.
20
+ """
21
+
22
+ def _handle_standard_exec_errors(self, e: Exception, ctx: ExecContext) -> Any | None:
23
+ """For CLI resources, re-raise exceptions without transformation."""
24
+ raise e
25
+
26
+ def list_warehouses(self):
27
+ """List all warehouses in the Snowflake account."""
28
+ results = self._exec("SHOW WAREHOUSES")
29
+ if not results:
30
+ return []
31
+ return [{"name": name}
32
+ for (name, *rest) in results]
33
+
34
+ def list_compute_pools(self):
35
+ """List all compute pools in the Snowflake account."""
36
+ results = self._exec("SHOW COMPUTE POOLS")
37
+ if not results:
38
+ return []
39
+ return [{"name": name, "status": status, "min_nodes": min_nodes, "max_nodes": max_nodes, "instance_family": instance_family}
40
+ for (name, status, min_nodes, max_nodes, instance_family, *rest) in results]
41
+
42
+ def list_roles(self):
43
+ """List all available roles in the Snowflake account."""
44
+ results = self._exec("SELECT CURRENT_AVAILABLE_ROLES()")
45
+ if not results:
46
+ return []
47
+ # the response is a single row with a single column containing
48
+ # a stringified JSON array of role names:
49
+ row = results[0]
50
+ if not row:
51
+ return []
52
+ return [{"name": name} for name in json.loads(row[0])]
53
+
54
+ def list_apps(self):
55
+ """List all applications in the Snowflake account."""
56
+ all_apps = self._exec(f"SHOW APPLICATIONS LIKE '{RAI_APP_NAME}'")
57
+ if not all_apps:
58
+ all_apps = self._exec("SHOW APPLICATIONS")
59
+ if not all_apps:
60
+ return []
61
+ return [{"name": name}
62
+ for (time, name, *rest) in all_apps]
63
+
64
+ def list_databases(self):
65
+ """List all databases in the Snowflake account."""
66
+ results = self._exec("SHOW DATABASES")
67
+ if not results:
68
+ return []
69
+ return [{"name": name}
70
+ for (time, name, *rest) in results]
71
+
72
+ def list_sf_schemas(self, database: str):
73
+ """List all schemas in a given database."""
74
+ results = self._exec(f"SHOW SCHEMAS IN {database}")
75
+ if not results:
76
+ return []
77
+ return [{"name": name}
78
+ for (time, name, *rest) in results]
79
+
80
+ def list_tables(self, database: str, schema: str):
81
+ """List all tables and views in a given schema."""
82
+ results = self._exec(f"SHOW OBJECTS IN {database}.{schema}")
83
+ items = []
84
+ if results:
85
+ for (time, name, db_name, schema_name, kind, *rest) in results:
86
+ items.append({"name": name, "kind": kind.lower()})
87
+ return items