pytrilogy 0.0.2.41__tar.gz → 0.0.2.42__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 pytrilogy might be problematic. Click here for more details.
- {pytrilogy-0.0.2.41/pytrilogy.egg-info → pytrilogy-0.0.2.42}/PKG-INFO +1 -1
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42/pytrilogy.egg-info}/PKG-INFO +1 -1
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_functions.py +10 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/__init__.py +1 -1
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/window_node.py +10 -3
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/common.py +12 -2
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/LICENSE.md +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/README.md +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/pyproject.toml +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/pytrilogy.egg-info/SOURCES.txt +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/pytrilogy.egg-info/dependency_links.txt +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/pytrilogy.egg-info/entry_points.txt +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/pytrilogy.egg-info/requires.txt +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/pytrilogy.egg-info/top_level.txt +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/setup.cfg +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/setup.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_datatypes.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_declarations.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_derived_concepts.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_discovery_nodes.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_enums.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_environment.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_executor.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_imports.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_metadata.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_models.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_multi_join_assignments.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_parse_engine.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_parsing.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_partial_handling.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_query_processing.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_select.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_show.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_statements.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_undefined_concept.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/tests/test_where_clause.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/compiler.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/constants.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/constants.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/enums.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/env_processor.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/environment_helpers.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/ergonomics.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/exceptions.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/functions.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/graph_models.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/internal.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/models.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/optimization.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/optimizations/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/optimizations/base_optimization.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/optimizations/inline_constant.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/optimizations/inline_datasource.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/optimizations/predicate_pushdown.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/concept_strategies_v3.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/graph_utils.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/basic_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/common.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/filter_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/group_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/group_to_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/multiselect_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/node_merge_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/rowset_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/select_merge_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/select_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/unnest_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/base_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/filter_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/group_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/merge_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/select_node_v2.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/unnest_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/nodes/window_node.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/utility.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/query_processor.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/base.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/bigquery.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/common.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/config.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/duckdb.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/enums.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/postgres.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/presto.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/snowflake.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/dialect/sql_server.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/engine.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/executor.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/hooks/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/hooks/base_hook.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/hooks/graph_hook.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/hooks/query_debugger.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/metadata/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parser.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/config.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/exceptions.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/helpers.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/parse_engine.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/render.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/parsing/trilogy.lark +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/py.typed +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/scripts/__init__.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/scripts/trilogy.py +0 -0
- {pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/utility.py +0 -0
|
@@ -89,6 +89,16 @@ def test_window_functions(test_environment):
|
|
|
89
89
|
dialect.compile_statement(process_query(test_environment, select))
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
def test_window_datatype(test_environment):
|
|
93
|
+
declarations = """
|
|
94
|
+
|
|
95
|
+
auto category_rank <- rank category_name order by count(order_id) desc;
|
|
96
|
+
|
|
97
|
+
"""
|
|
98
|
+
env, parsed = parse(declarations, environment=test_environment)
|
|
99
|
+
assert env.concepts["category_rank"].datatype == DataType.INTEGER
|
|
100
|
+
|
|
101
|
+
|
|
92
102
|
def test_date_functions(test_environment):
|
|
93
103
|
declarations = """
|
|
94
104
|
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/window_node.py
RENAMED
|
@@ -10,7 +10,9 @@ from trilogy.core.processing.utility import padding
|
|
|
10
10
|
LOGGER_PREFIX = "[GEN_WINDOW_NODE]"
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
def resolve_window_parent_concepts(
|
|
13
|
+
def resolve_window_parent_concepts(
|
|
14
|
+
concept: Concept, environment: Environment
|
|
15
|
+
) -> tuple[Concept, List[Concept]]:
|
|
14
16
|
if not isinstance(concept.lineage, WindowItem):
|
|
15
17
|
raise ValueError
|
|
16
18
|
base = []
|
|
@@ -18,6 +20,11 @@ def resolve_window_parent_concepts(concept: Concept) -> tuple[Concept, List[Conc
|
|
|
18
20
|
base += concept.lineage.over
|
|
19
21
|
if concept.lineage.order_by:
|
|
20
22
|
for item in concept.lineage.order_by:
|
|
23
|
+
# TODO: we do want to use the rehydrated value, but
|
|
24
|
+
# that introduces a circular dependency on an aggregate
|
|
25
|
+
# that is grouped by a window
|
|
26
|
+
# need to figure out how to resolve this
|
|
27
|
+
# base += [environment.concepts[item.expr.output.address]]
|
|
21
28
|
base += [item.expr.output]
|
|
22
29
|
return concept.lineage.content, unique(base, "address")
|
|
23
30
|
|
|
@@ -32,12 +39,12 @@ def gen_window_node(
|
|
|
32
39
|
history: History | None = None,
|
|
33
40
|
conditions: WhereClause | None = None,
|
|
34
41
|
) -> StrategyNode | None:
|
|
35
|
-
base, parent_concepts = resolve_window_parent_concepts(concept)
|
|
42
|
+
base, parent_concepts = resolve_window_parent_concepts(concept, environment)
|
|
36
43
|
equivalent_optional = [
|
|
37
44
|
x
|
|
38
45
|
for x in local_optional
|
|
39
46
|
if isinstance(x.lineage, WindowItem)
|
|
40
|
-
and resolve_window_parent_concepts(x)[1] == parent_concepts
|
|
47
|
+
and resolve_window_parent_concepts(x, environment)[1] == parent_concepts
|
|
41
48
|
]
|
|
42
49
|
|
|
43
50
|
non_equivalent_optional = [
|
|
@@ -13,6 +13,7 @@ from trilogy.core.models import (
|
|
|
13
13
|
Parenthetical,
|
|
14
14
|
FunctionClass,
|
|
15
15
|
Environment,
|
|
16
|
+
DataType,
|
|
16
17
|
)
|
|
17
18
|
from typing import List, Tuple
|
|
18
19
|
from trilogy.core.functions import (
|
|
@@ -25,7 +26,7 @@ from trilogy.core.enums import PurposeLineage
|
|
|
25
26
|
from trilogy.constants import (
|
|
26
27
|
VIRTUAL_CONCEPT_PREFIX,
|
|
27
28
|
)
|
|
28
|
-
from trilogy.core.enums import Modifier
|
|
29
|
+
from trilogy.core.enums import Modifier, WindowType
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
def get_upstream_modifiers(keys: List[Concept]) -> list[Modifier]:
|
|
@@ -234,9 +235,18 @@ def window_item_to_concept(
|
|
|
234
235
|
else:
|
|
235
236
|
grain = parent.over + [parent.content.output]
|
|
236
237
|
modifiers = get_upstream_modifiers(parent.content.concept_arguments)
|
|
238
|
+
datatype = parent.content.datatype
|
|
239
|
+
if parent.type in (
|
|
240
|
+
WindowType.RANK,
|
|
241
|
+
WindowType.ROW_NUMBER,
|
|
242
|
+
WindowType.COUNT,
|
|
243
|
+
WindowType.COUNT_DISTINCT,
|
|
244
|
+
):
|
|
245
|
+
datatype = DataType.INTEGER
|
|
246
|
+
|
|
237
247
|
return Concept(
|
|
238
248
|
name=name,
|
|
239
|
-
datatype=
|
|
249
|
+
datatype=datatype,
|
|
240
250
|
purpose=local_purpose,
|
|
241
251
|
lineage=parent,
|
|
242
252
|
metadata=fmetadata,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/__init__.py
RENAMED
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/basic_node.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/filter_node.py
RENAMED
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/group_node.py
RENAMED
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/group_to_node.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/node_merge_node.py
RENAMED
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/rowset_node.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/select_node.py
RENAMED
|
File without changes
|
{pytrilogy-0.0.2.41 → pytrilogy-0.0.2.42}/trilogy/core/processing/node_generators/unnest_node.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|