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

#1162 #1167

Merged
merged 1 commit into from
Sep 23, 2023
Merged

#1162 #1167

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
  • Loading branch information
joocer committed Sep 23, 2023
commit 0931d8c36c798a0d03468356354f3319f9a126c3
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
lint:
python -m pycln .
python -m isort .
python -m black .

refresh:
python -m pip install --quiet --upgrade -r requirements.txt
python -m pip install --quiet --upgrade -r tests/requirements.txt

t:
python tests/sql_battery/test_shapes_and_errors_battery.py

test:
python -m pytest
3 changes: 0 additions & 3 deletions opteryx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@

cache_manager = CacheManager(cache_backend=None)

from opteryx.__author__ import __author__
from opteryx.__build__ import __build__
from opteryx.__version__ import __version__
from opteryx.connection import Connection
from opteryx.connectors import register_arrow
from opteryx.connectors import register_df
Expand Down
23 changes: 16 additions & 7 deletions opteryx/components/binder/binder_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,28 @@ def visit_project(self, node: Node, context: BindingContext) -> Tuple[Node, Bind

all_identities = [c.schema_column.identity for c in node.columns]

columns = []
for relation, schema in list(context.schemas.items()):
columns = []
for column in schema.columns:
if column.identity in all_identities:
columns.append(column)
if len(columns) == 0:
schema_columns = [
column for column in schema.columns if column.identity in all_identities
]
if len(schema_columns) == 0:
context.schemas.pop(relation)
else:
schema.columns = columns

schema.columns = schema_columns
columns += [
column
for column in node.columns
if column.schema_column.identity in [i.identity for i in schema_columns]
]

if "$derived" in context.schemas:
context.schemas["$project"] = context.schemas.pop("$derived")
if not "$derived" in context.schemas:
context.schemas["$derived"] = derived.schema()

node.columns = columns

return node, context

def visit_filter(self, node: Node, context: BindingContext) -> Tuple[Node, BindingContext]:
Expand Down
10 changes: 6 additions & 4 deletions opteryx/connectors/capabilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .cacheable import Cacheable
from .partitionable import Partitionable
from .predicate_pushable import PredicatePushable
from .projection_pushable import ProjectionPushable
from opteryx.connectors.capabilities.cacheable import Cacheable
from opteryx.connectors.capabilities.partitionable import Partitionable
from opteryx.connectors.capabilities.predicate_pushable import PredicatePushable
from opteryx.connectors.capabilities.projection_pushable import ProjectionPushable

__all__ = ("Cacheable", "Partitionable", "PredicatePushable", "ProjectionPushable")
16 changes: 15 additions & 1 deletion opteryx/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
from .permissions import PERMISSIONS
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from opteryx.constants.permissions import PERMISSIONS

__all__ = ("PERMISSIONS",)
1 change: 0 additions & 1 deletion opteryx/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"""

from typing import Optional
from typing import Union


# ======================== Begin Codebase Errors ========================
Expand Down
1 change: 0 additions & 1 deletion opteryx/functions/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""
import datetime
import inspect
import os
import re
import sys
import typing
Expand Down
1 change: 0 additions & 1 deletion opteryx/managers/cache/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
This implements an interface to Memcached
"""

import io
import os
from typing import Union

Expand Down
1 change: 0 additions & 1 deletion opteryx/managers/kvstores/kv_firestore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Iterable
from typing import Optional

Expand Down
10 changes: 6 additions & 4 deletions opteryx/shared/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .buffer_pool import BufferPool
from .materialized_datasets import MaterializedDatasets
from .query_statistics import QueryStatistics
from .rolling_log import RollingLog
from opteryx.shared.buffer_pool import BufferPool
from opteryx.shared.materialized_datasets import MaterializedDatasets
from opteryx.shared.query_statistics import QueryStatistics
from opteryx.shared.rolling_log import RollingLog

__all__ = ("BufferPool", "MaterializedDatasets", "QueryStatistics", "RollingLog")
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mypy
pytest
black
isort
pycln

pandas
pymemcache
Expand Down
Loading