moose-lib 0.6.12__tar.gz → 0.6.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of moose-lib might be problematic. Click here for more details.

Files changed (43) hide show
  1. {moose_lib-0.6.12 → moose_lib-0.6.14}/PKG-INFO +1 -1
  2. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/materialized_view.py +33 -15
  3. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib.egg-info/PKG-INFO +1 -1
  4. {moose_lib-0.6.12 → moose_lib-0.6.14}/README.md +0 -0
  5. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/__init__.py +0 -0
  6. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/blocks.py +0 -0
  7. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/clients/__init__.py +0 -0
  8. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/clients/redis_client.py +0 -0
  9. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/commons.py +0 -0
  10. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/config/__init__.py +0 -0
  11. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/config/config_file.py +0 -0
  12. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/config/runtime.py +0 -0
  13. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/data_models.py +0 -0
  14. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/__init__.py +0 -0
  15. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/_registry.py +0 -0
  16. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/consumption.py +0 -0
  17. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/ingest_api.py +0 -0
  18. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/ingest_pipeline.py +0 -0
  19. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/life_cycle.py +0 -0
  20. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/olap_table.py +0 -0
  21. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/registry.py +0 -0
  22. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/sql_resource.py +0 -0
  23. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/stream.py +0 -0
  24. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/types.py +0 -0
  25. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/view.py +0 -0
  26. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2/workflow.py +0 -0
  27. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/dmv2-serializer.py +0 -0
  28. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/internal.py +0 -0
  29. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/main.py +0 -0
  30. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/query_param.py +0 -0
  31. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/streaming/__init__.py +0 -0
  32. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/streaming/streaming_function_runner.py +0 -0
  33. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib/tasks.py +0 -0
  34. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib.egg-info/SOURCES.txt +0 -0
  35. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib.egg-info/dependency_links.txt +0 -0
  36. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib.egg-info/requires.txt +0 -0
  37. {moose_lib-0.6.12 → moose_lib-0.6.14}/moose_lib.egg-info/top_level.txt +0 -0
  38. {moose_lib-0.6.12 → moose_lib-0.6.14}/setup.cfg +0 -0
  39. {moose_lib-0.6.12 → moose_lib-0.6.14}/setup.py +0 -0
  40. {moose_lib-0.6.12 → moose_lib-0.6.14}/tests/__init__.py +0 -0
  41. {moose_lib-0.6.12 → moose_lib-0.6.14}/tests/conftest.py +0 -0
  42. {moose_lib-0.6.12 → moose_lib-0.6.14}/tests/test_moose.py +0 -0
  43. {moose_lib-0.6.12 → moose_lib-0.6.14}/tests/test_redis_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moose_lib
3
- Version: 0.6.12
3
+ Version: 0.6.14
4
4
  Home-page: https://www.fiveonefour.com/moose
5
5
  Author: Fiveonefour Labs Inc.
6
6
  Author-email: support@fiveonefour.com
@@ -5,29 +5,33 @@ This module provides classes for defining Materialized Views,
5
5
  including their SQL statements, target tables, and dependencies.
6
6
  """
7
7
  from typing import Any, Optional, Union, Generic, TypeVar
8
- from pydantic import BaseModel, ConfigDict
8
+ from pydantic import BaseModel, ConfigDict, model_validator
9
9
 
10
10
  from moose_lib import ClickHouseEngines
11
11
  from .types import BaseTypedResource, T
12
12
  from .olap_table import OlapTable, OlapConfig
13
13
  from .sql_resource import SqlResource
14
14
 
15
+
15
16
  class MaterializedViewOptions(BaseModel):
16
17
  """Configuration options for creating a Materialized View.
17
18
 
18
19
  Attributes:
19
20
  select_statement: The SQL SELECT statement defining the view's data.
20
21
  select_tables: List of source tables/views the select statement reads from.
21
- table_name: The name of the underlying target table storing the materialized data.
22
+ table_name: (Deprecated in favor of target_table) Optional name of the underlying
23
+ target table storing the materialized data.
22
24
  materialized_view_name: The name of the MATERIALIZED VIEW object itself.
23
- engine: Optional ClickHouse engine for the target table.
25
+ engine: Optional ClickHouse engine for the target table (used when creating
26
+ a target table via table_name or inline config).
24
27
  order_by_fields: Optional ordering key for the target table (required for
25
28
  engines like ReplacingMergeTree).
26
29
  model_config: ConfigDict for Pydantic validation
27
30
  """
28
31
  select_statement: str
29
32
  select_tables: list[Union[OlapTable, SqlResource]]
30
- table_name: str
33
+ # Backward-compatibility: allow specifying just the table_name and engine
34
+ table_name: Optional[str] = None
31
35
  materialized_view_name: str
32
36
  engine: Optional[ClickHouseEngines] = None
33
37
  order_by_fields: Optional[list[str]] = None
@@ -35,6 +39,7 @@ class MaterializedViewOptions(BaseModel):
35
39
  # Ensure arbitrary types are allowed for Pydantic validation
36
40
  model_config = ConfigDict(arbitrary_types_allowed=True)
37
41
 
42
+
38
43
  class MaterializedView(SqlResource, BaseTypedResource, Generic[T]):
39
44
  """Represents a ClickHouse Materialized View.
40
45
 
@@ -62,25 +67,38 @@ class MaterializedView(SqlResource, BaseTypedResource, Generic[T]):
62
67
  def __init__(
63
68
  self,
64
69
  options: MaterializedViewOptions,
70
+ target_table: Optional[OlapTable[T]] = None,
65
71
  **kwargs
66
72
  ):
67
73
  self._set_type(options.materialized_view_name, self._get_type(kwargs))
68
74
 
75
+ # Resolve target table from options
76
+ if target_table:
77
+ self.target_table = target_table
78
+ if self._t != target_table._t:
79
+ raise ValueError("Target table must have the same type as the materialized view")
80
+ else:
81
+ # Backward-compatibility path using table_name/engine/order_by_fields
82
+ if not options.table_name:
83
+ raise ValueError("Name of target table is not specified. Provide 'target_table' or 'table_name'.")
84
+ target_table = OlapTable(
85
+ name=options.table_name,
86
+ config=OlapConfig(
87
+ order_by_fields=options.order_by_fields or [],
88
+ engine=options.engine
89
+ ),
90
+ t=self._t
91
+ )
92
+
93
+ if target_table.name == options.materialized_view_name:
94
+ raise ValueError("Target table name cannot be the same as the materialized view name")
95
+
69
96
  setup = [
70
- f"CREATE MATERIALIZED VIEW IF NOT EXISTS {options.materialized_view_name} TO {options.table_name} AS {options.select_statement}",
71
- f"INSERT INTO {options.table_name} {options.select_statement}"
97
+ f"CREATE MATERIALIZED VIEW IF NOT EXISTS {options.materialized_view_name} TO {target_table.name} AS {options.select_statement}",
98
+ f"INSERT INTO {target_table.name} {options.select_statement}"
72
99
  ]
73
100
  teardown = [f"DROP VIEW IF EXISTS {options.materialized_view_name}"]
74
101
 
75
- target_table = OlapTable(
76
- name=options.table_name,
77
- config=OlapConfig(
78
- order_by_fields=options.order_by_fields or [],
79
- engine=options.engine
80
- ),
81
- t=self._t
82
- )
83
-
84
102
  super().__init__(
85
103
  options.materialized_view_name,
86
104
  setup,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moose_lib
3
- Version: 0.6.12
3
+ Version: 0.6.14
4
4
  Home-page: https://www.fiveonefour.com/moose
5
5
  Author: Fiveonefour Labs Inc.
6
6
  Author-email: support@fiveonefour.com
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes