Skip to content

Commit 60fc1d0

Browse files
committed
Format with Black
1 parent 51655bb commit 60fc1d0

File tree

5 files changed

+455
-280
lines changed

5 files changed

+455
-280
lines changed

databend_sqlalchemy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
FileColumnClause,
2626
StageClause,
2727
Compression,
28-
)
28+
)

databend_sqlalchemy/databend_dialect.py

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@
6262
from sqlalchemy.exc import DBAPIError, NoSuchTableError
6363

6464
from .dml import (
65-
Merge, StageClause, _StorageClause, GoogleCloudStorage,
66-
AzureBlobStorage, AmazonS3
65+
Merge,
66+
StageClause,
67+
_StorageClause,
68+
GoogleCloudStorage,
69+
AzureBlobStorage,
70+
AmazonS3,
6771
)
6872
from .types import INTERVAL
6973

@@ -978,13 +982,10 @@ def visit_copy_into(self, copy_into, **kw):
978982
else:
979983
source = f"({copy_into.from_._compiler_dispatch(self, **kw)})"
980984

981-
result = (
982-
f"COPY INTO {target}"
983-
f" FROM {source}"
984-
)
985-
if hasattr(copy_into, 'files') and isinstance(copy_into.files, list):
985+
result = f"COPY INTO {target}" f" FROM {source}"
986+
if hasattr(copy_into, "files") and isinstance(copy_into.files, list):
986987
result += f"FILES = {', '.join([f for f in copy_into.files])}"
987-
if hasattr(copy_into, 'pattern') and copy_into.pattern:
988+
if hasattr(copy_into, "pattern") and copy_into.pattern:
988989
result += f" PATTERN = '{copy_into.pattern}'"
989990
if not isinstance(copy_into.file_format, NoneType):
990991
result += f" {copy_into.file_format._compiler_dispatch(self, **kw)}\n"
@@ -1002,27 +1003,26 @@ def visit_copy_format(self, file_format, **kw):
10021003
return f"FILE_FORMAT=(format_name = {file_format.options['format_name']})"
10031004
# format specifics
10041005
format_options = [f"TYPE = {file_format.format_type}"]
1005-
format_options.extend([
1006-
"{} = {}".format(
1007-
option,
1008-
(
1009-
value._compiler_dispatch(self, **kw)
1010-
if hasattr(value, "_compiler_dispatch")
1011-
else str(value)
1012-
),
1013-
)
1014-
for option, value in options_list
1015-
])
1006+
format_options.extend(
1007+
[
1008+
"{} = {}".format(
1009+
option,
1010+
(
1011+
value._compiler_dispatch(self, **kw)
1012+
if hasattr(value, "_compiler_dispatch")
1013+
else str(value)
1014+
),
1015+
)
1016+
for option, value in options_list
1017+
]
1018+
)
10161019
return f"FILE_FORMAT = ({', '.join(format_options)})"
10171020

10181021
def visit_copy_into_options(self, copy_into_options, **kw):
10191022
options_list = list(copy_into_options.options.items())
10201023
# if kw.get("deterministic", False):
10211024
# options_list.sort(key=operator.itemgetter(0))
1022-
return "\n".join([
1023-
f"{k} = {v}"
1024-
for k, v in options_list
1025-
])
1025+
return "\n".join([f"{k} = {v}" for k, v in options_list])
10261026

10271027
def visit_file_column(self, file_column_clause, **kw):
10281028
if isinstance(file_column_clause.from_, (TableClause,)):
@@ -1034,15 +1034,19 @@ def visit_file_column(self, file_column_clause, **kw):
10341034
if isinstance(file_column_clause.columns, str):
10351035
select_str = file_column_clause.columns
10361036
else:
1037-
select_str = ",".join([col._compiler_dispatch(self, **kw) for col in file_column_clause.columns])
1038-
return (
1039-
f"SELECT {select_str}"
1040-
f" FROM {source}"
1041-
)
1037+
select_str = ",".join(
1038+
[
1039+
col._compiler_dispatch(self, **kw)
1040+
for col in file_column_clause.columns
1041+
]
1042+
)
1043+
return f"SELECT {select_str}" f" FROM {source}"
10421044

10431045
def visit_amazon_s3(self, amazon_s3: AmazonS3, **kw):
10441046
connection_params_str = f" ACCESS_KEY_ID = '{amazon_s3.access_key_id}' \n"
1045-
connection_params_str += f" SECRET_ACCESS_KEY = '{amazon_s3.secret_access_key}'\n"
1047+
connection_params_str += (
1048+
f" SECRET_ACCESS_KEY = '{amazon_s3.secret_access_key}'\n"
1049+
)
10461050
if amazon_s3.endpoint_url:
10471051
connection_params_str += f" ENDPOINT_URL = '{amazon_s3.endpoint_url}' \n"
10481052
if amazon_s3.enable_virtual_host_style:
@@ -1052,7 +1056,9 @@ def visit_amazon_s3(self, amazon_s3: AmazonS3, **kw):
10521056
if amazon_s3.region:
10531057
connection_params_str += f" REGION = '{amazon_s3.region}'\n"
10541058
if amazon_s3.security_token:
1055-
connection_params_str += f" SECURITY_TOKEN = '{amazon_s3.security_token}'\n"
1059+
connection_params_str += (
1060+
f" SECURITY_TOKEN = '{amazon_s3.security_token}'\n"
1061+
)
10561062

10571063
return (
10581064
f"'{amazon_s3.uri}' \n"

0 commit comments

Comments
 (0)