Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1630 #1660

Merged
merged 2 commits into from
May 15, 2024
Merged

#1630 #1660

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opteryx/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__build__ = 500
__build__ = 501

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
1 change: 0 additions & 1 deletion opteryx/connectors/aws_s3_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from typing import List

import pyarrow
from orso.schema import FlatColumn
from orso.schema import RelationSchema
from orso.tools import single_item_cache

Expand Down
12 changes: 12 additions & 0 deletions opteryx/models/logical_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,15 @@ def copy(self):

def __repr__(self) -> str:
return f"<LogicalColumn name: '{self.current_name}' fullname: '{self.qualified_name}'>"

def to_dict(self) -> str:
from dataclasses import asdict

return {
"class": "LogicalColumn",
"node_type": self.node_type,
"source_column": self.source_column,
"source": self.source,
"alias": self.alias,
"schema_column": asdict(self.schema_column),
}
4 changes: 2 additions & 2 deletions opteryx/operators/#heap_sort_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def __init__(self, properties: QueryProperties, **config):
self.order = config.get("order", [])
self.limit: int = config.get("limit", -1)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/#information_schema_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ def __init__(self, properties: QueryProperties, **config):
# pushed down selection/filter
self._selection = config.get("selection")

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/#show_databases_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class ShowDatabasesNode(BasePlanNode):
def __init__(self, properties: QueryProperties, **config):
super().__init__(properties=properties)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/aggregate_and_group_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def __init__(self, properties: QueryProperties, **config):
self.group_by_columns = list({node.schema_column.identity for node in self.groups})
self.column_map, self.aggregate_functions = build_aggregations(self.aggregates)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/aggregate_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ def __init__(self, properties: QueryProperties, **config):

self.column_map, self.aggregate_functions = build_aggregations(self.aggregates)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
2 changes: 1 addition & 1 deletion opteryx/operators/async_read_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(self, *args, **kwargs):
MAX_BUFFER_SIZE_MB * 1024 * 1024, f"ReadBuffer <{self.parameters['alias']}>"
)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/base_plan_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def __init__(self, properties: QueryProperties, **parameters):
self.execution_time = 0
self.identity = random_string()

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

def set_producers(self, producers):
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/cross_join_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ def __init__(self, properties: QueryProperties, **config):
):
self._unnest_column.value = tuple([self._unnest_column.value])

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/distinct_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def __init__(self, properties: QueryProperties, **config):
self._distinct_on = [col.schema_column.identity for col in self._distinct_on]
self.hash_set = HashSet()

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
20 changes: 12 additions & 8 deletions opteryx/operators/exit_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ def __init__(self, properties: QueryProperties, **config):
super().__init__(properties=properties)
self.columns = config.get("columns", [])

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover

return {
"node": self.__class__.__name__,
"identity": self.identity,
"query_id": self.properties.qid,
"configuration": {"columns": self.columns},
}
import orjson

return orjson.dumps(
{
"node": self.__class__.__name__,
"identity": self.identity,
"query_id": self.properties.qid,
"configuration": {"columns": [c.to_dict() for c in self.columns]},
}
)

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/explain_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def name(self): # pragma: no cover
def config(self):
return ""

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

def execute(self) -> Generator:
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/filter_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def __init__(self, properties: QueryProperties, **config):
select_nodes=(NodeType.FUNCTION,),
)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/function_dataset_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def __init__(self, properties: QueryProperties, **config):
self.parameters = config
self.columns = config.get("columns", [])

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/inner_join_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ def __init__(self, properties: QueryProperties, **config):
self._right_columns = config.get("right_columns")
self._right_relation = config.get("right_relation_names")

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/join_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def __init__(self, properties: QueryProperties, **config):
self._right_columns = config.get("right_columns")
self._right_relation = config.get("right_relation_names")

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/left_join_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ def __init__(self, properties: QueryProperties, **config):
self._right_columns = config.get("right_columns")
self._right_relation = config.get("right_relation_names")

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/limit_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def __init__(self, properties: QueryProperties, **config):
self.limit = config.get("limit")
self.offset = config.get("offset", 0)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/metadata_writer_node.py_
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class MetadataWriterNode(BasePlanNode):
super().__init__(properties=properties)


def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/morsel_defragment_node.py_
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class MorselDefragmentNode(BasePlanNode):
super().__init__(properties=properties)


def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/noop_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class NoOpNode(BasePlanNode):
def __init__(self, properties: QueryProperties, **config):
super().__init__(properties=properties)

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/projection_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def __init__(self, properties: QueryProperties, **config):
column for column in projection if column.node_type != NodeType.IDENTIFIER
]

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/set_variable_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def __init__(self, properties: QueryProperties, **config):

self.variables = config.get("variables")

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/show_columns_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ def __init__(self, properties: QueryProperties, **config):
self._schema = config.get("schema")
self._column_map = {c.schema_column.identity: c.source_column for c in config["columns"]}

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/show_value_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def __init__(self, properties: QueryProperties, **config):
self.key = self.value
self.value = properties.variables[self.value]

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
4 changes: 2 additions & 2 deletions opteryx/operators/sort_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def __init__(self, properties: QueryProperties, **config):
super().__init__(properties=properties)
self.order = config.get("order", [])

def to_dict(self) -> dict: # pragma: no cover
def to_json(self) -> dict: # pragma: no cover
raise NotImplementedError()

@classmethod
def from_dict(cls, dic: dict) -> "BasePlanNode": # pragma: no cover
def from_json(cls, json_obj: str) -> "BasePlanNode": # pragma: no cover
raise NotImplementedError()

@property
Expand Down
Loading