62
62
from sqlalchemy .exc import DBAPIError , NoSuchTableError
63
63
64
64
from .dml import (
65
- Merge , StageClause , _StorageClause , GoogleCloudStorage ,
66
- AzureBlobStorage , AmazonS3
65
+ Merge ,
66
+ StageClause ,
67
+ _StorageClause ,
68
+ GoogleCloudStorage ,
69
+ AzureBlobStorage ,
70
+ AmazonS3 ,
67
71
)
68
72
from .types import INTERVAL
69
73
@@ -978,13 +982,10 @@ def visit_copy_into(self, copy_into, **kw):
978
982
else :
979
983
source = f"({ copy_into .from_ ._compiler_dispatch (self , ** kw )} )"
980
984
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 ):
986
987
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 :
988
989
result += f" PATTERN = '{ copy_into .pattern } '"
989
990
if not isinstance (copy_into .file_format , NoneType ):
990
991
result += f" { copy_into .file_format ._compiler_dispatch (self , ** kw )} \n "
@@ -1002,27 +1003,26 @@ def visit_copy_format(self, file_format, **kw):
1002
1003
return f"FILE_FORMAT=(format_name = { file_format .options ['format_name' ]} )"
1003
1004
# format specifics
1004
1005
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
+ )
1016
1019
return f"FILE_FORMAT = ({ ', ' .join (format_options )} )"
1017
1020
1018
1021
def visit_copy_into_options (self , copy_into_options , ** kw ):
1019
1022
options_list = list (copy_into_options .options .items ())
1020
1023
# if kw.get("deterministic", False):
1021
1024
# 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 ])
1026
1026
1027
1027
def visit_file_column (self , file_column_clause , ** kw ):
1028
1028
if isinstance (file_column_clause .from_ , (TableClause ,)):
@@ -1034,15 +1034,19 @@ def visit_file_column(self, file_column_clause, **kw):
1034
1034
if isinstance (file_column_clause .columns , str ):
1035
1035
select_str = file_column_clause .columns
1036
1036
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 } "
1042
1044
1043
1045
def visit_amazon_s3 (self , amazon_s3 : AmazonS3 , ** kw ):
1044
1046
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
+ )
1046
1050
if amazon_s3 .endpoint_url :
1047
1051
connection_params_str += f" ENDPOINT_URL = '{ amazon_s3 .endpoint_url } ' \n "
1048
1052
if amazon_s3 .enable_virtual_host_style :
@@ -1052,7 +1056,9 @@ def visit_amazon_s3(self, amazon_s3: AmazonS3, **kw):
1052
1056
if amazon_s3 .region :
1053
1057
connection_params_str += f" REGION = '{ amazon_s3 .region } '\n "
1054
1058
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
+ )
1056
1062
1057
1063
return (
1058
1064
f"'{ amazon_s3 .uri } ' \n "
0 commit comments