Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 201c4e9

Browse files
committed
Ran black
1 parent 6c94e17 commit 201c4e9

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

sqeleton/abcs/mixins.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,12 @@ def time_travel(
146146
Must specify exactly one of `timestamp`, `offset` or `statement`.
147147
"""
148148

149+
149150
class AbstractMixin_OptimizerHints(AbstractMixin):
150151
@abstractmethod
151-
def optimizer_hints(
152-
self,
153-
optimizer_hints: str
154-
) -> str:
152+
def optimizer_hints(self, optimizer_hints: str) -> str:
155153
"""Creates a compatible optimizer_hints string
156154
157155
Parameters:
158156
optimizer_hints - string of optimizer hints
159-
"""
157+
"""

sqeleton/databases/base.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
AbstractMixin_Schema,
4141
AbstractMixin_RandomSample,
4242
AbstractMixin_NormalizeValue,
43-
AbstractMixin_OptimizerHints
44-
)
43+
AbstractMixin_OptimizerHints,
44+
)
4545
from ..bound_exprs import bound_table
4646

4747
logger = logging.getLogger("database")
@@ -140,10 +140,7 @@ def random_sample_ratio_approx(self, tbl: AbstractTable, ratio: float) -> Abstra
140140

141141

142142
class Mixin_OptimizerHints(AbstractMixin_OptimizerHints):
143-
def optimizer_hints(
144-
self,
145-
hints: str
146-
) -> str:
143+
def optimizer_hints(self, hints: str) -> str:
147144
return f"/*+ {hints} */ "
148145

149146

@@ -181,7 +178,6 @@ def current_timestamp(self) -> str:
181178
def explain_as_text(self, query: str) -> str:
182179
return f"EXPLAIN {query}"
183180

184-
185181
def _constant_value(self, v):
186182
if v is None:
187183
return "NULL"

sqeleton/databases/databricks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def set_timezone_to_utc(self) -> str:
9595
return "SET TIME ZONE 'UTC'"
9696

9797

98-
9998
class Databricks(ThreadedDatabase):
10099
dialect = Dialect()
101100
CONNECT_URI_HELP = "databricks://:<access_token>@<server_hostname>/<http_path>"

sqeleton/databases/oracle.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
from ..abcs.mixins import AbstractMixin_MD5, AbstractMixin_NormalizeValue, AbstractMixin_Schema
1818
from ..abcs import Compilable
1919
from ..queries import this, table, SKIP
20-
from .base import BaseDialect, Mixin_OptimizerHints, ThreadedDatabase, import_helper, ConnectError, QueryError, Mixin_RandomSample
20+
from .base import (
21+
BaseDialect,
22+
Mixin_OptimizerHints,
23+
ThreadedDatabase,
24+
import_helper,
25+
ConnectError,
26+
QueryError,
27+
Mixin_RandomSample,
28+
)
2129
from .base import TIMESTAMP_PRECISION_POS
2230

2331
SESSION_TIME_ZONE = None # Changed by the tests

sqeleton/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def repl(uri):
4848
continue
4949
try:
5050
path = db.parse_table_name(table_name)
51-
print('->', path)
51+
print("->", path)
5252
schema = db.query_table_schema(path)
5353
except Exception as e:
5454
logging.error(e)

sqeleton/utils.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
from typing import Iterable, Iterator, MutableMapping, Union, Any, Sequence, Dict, Hashable, TypeVar, TYPE_CHECKING, List
1+
from typing import (
2+
Iterable,
3+
Iterator,
4+
MutableMapping,
5+
Union,
6+
Any,
7+
Sequence,
8+
Dict,
9+
Hashable,
10+
TypeVar,
11+
TYPE_CHECKING,
12+
List,
13+
)
214
from abc import abstractmethod
315
from weakref import ref
416
import math
@@ -256,7 +268,6 @@ def __eq__(self, other):
256268
return NotImplemented
257269
return self._str == other._str
258270

259-
260271
def new(self, *args, **kw):
261272
return type(self)(*args, **kw, max_len=self._max_len)
262273

tests/test_query.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,19 @@ def test_select_with_optimizer_hints(self):
197197
c = Compiler(MockDatabase())
198198
t = table("a")
199199

200-
q = c.compile(t.select(this.b, optimizer_hints='PARALLEL(a 16)'))
200+
q = c.compile(t.select(this.b, optimizer_hints="PARALLEL(a 16)"))
201201
assert q == "SELECT /*+ PARALLEL(a 16) */ b FROM a"
202202

203-
q = c.compile(t.where(this.b > 10).select(this.b, optimizer_hints='PARALLEL(a 16)'))
203+
q = c.compile(t.where(this.b > 10).select(this.b, optimizer_hints="PARALLEL(a 16)"))
204204
self.assertEqual(q, "SELECT /*+ PARALLEL(a 16) */ b FROM a WHERE (b > 10)")
205205

206-
q = c.compile(t.limit(10).select(this.b, optimizer_hints='PARALLEL(a 16)'))
206+
q = c.compile(t.limit(10).select(this.b, optimizer_hints="PARALLEL(a 16)"))
207207
self.assertEqual(q, "SELECT /*+ PARALLEL(a 16) */ b FROM (SELECT * FROM a LIMIT 10) tmp1")
208208

209-
q = c.compile(t.select(this.a).group_by(this.b).agg(this.c).select(optimizer_hints='PARALLEL(a 16)'))
210-
self.assertEqual(q, "SELECT /*+ PARALLEL(a 16) */ * FROM (SELECT b, c FROM (SELECT a FROM a) tmp2 GROUP BY 1) tmp3")
209+
q = c.compile(t.select(this.a).group_by(this.b).agg(this.c).select(optimizer_hints="PARALLEL(a 16)"))
210+
self.assertEqual(
211+
q, "SELECT /*+ PARALLEL(a 16) */ * FROM (SELECT b, c FROM (SELECT a FROM a) tmp2 GROUP BY 1) tmp3"
212+
)
211213

212214
def test_table_ops(self):
213215
c = Compiler(MockDatabase())

0 commit comments

Comments
 (0)