@@ -60,21 +60,21 @@ def process_column_name(column_name_listener, walker, ctx, quote_char):
6060 for i in column_name_listener .column_name :
6161 cni = [None , None , None , i ]
6262 if i .schema_name ():
63- cni [0 ] = i .schema_name ().getText ().replace (quote_char , "" )
63+ cni [0 ] = i .schema_name ().getText ().replace (quote_char , '' )
6464 if i .table_name ():
65- cni [1 ] = i .table_name ().getText ().replace (quote_char , "" )
65+ cni [1 ] = i .table_name ().getText ().replace (quote_char , '' )
6666 if i .column_name ():
67- cni [2 ] = i .column_name ().getText ().replace (quote_char , "" )
67+ cni [2 ] = i .column_name ().getText ().replace (quote_char , '' )
6868 cn .append (cni )
6969 else :
7070 try :
7171 ctx .ASTERISK ()
7272 ts = ctx .table_spec ()
73- cn = [[None , None , "*" , None ]]
73+ cn = [[None , None , '*' , None ]]
7474 if ts .schema_name ():
75- cn [0 ][0 ] = ts .schema_name ().getText ().replace (quote_char , "" )
75+ cn [0 ][0 ] = ts .schema_name ().getText ().replace (quote_char , '' )
7676 if ts .table_name ():
77- cn [0 ][1 ] = ts .table_name ().getText ().replace (quote_char , "" )
77+ cn [0 ][1 ] = ts .table_name ().getText ().replace (quote_char , '' )
7878 except AttributeError :
7979 cn = [[None , None , None , None ]]
8080 return cn
@@ -134,16 +134,16 @@ def enterSchema_name(self, ctx):
134134 ttype = ctx .start .type
135135 sn = ctx .getTokens (ttype )[0 ].getSymbol ().text
136136 try :
137- nsn = self .replace_schema_name [sn .replace (quote_char , "" )]
137+ nsn = self .replace_schema_name [sn .replace (quote_char , '' )]
138138 try :
139- nsn = unicode (nsn , " utf-8" )
139+ nsn = unicode (nsn , ' utf-8' )
140140 except NameError :
141141 pass
142142 nsn = re .sub (
143- r" (|{})(?!{})[\S]*[^{}](|{})" .format (
143+ r' (|{})(?!{})[\S]*[^{}](|{})' .format (
144144 quote_char , quote_char , quote_char , quote_char
145145 ),
146- r" \1{}\2" .format (nsn ),
146+ r' \1{}\2' .format (nsn ),
147147 sn ,
148148 )
149149 ctx .getTokens (ttype )[0 ].getSymbol ().text = nsn
@@ -202,7 +202,7 @@ def __init__(self):
202202
203203 def enterSelect_statement (self , ctx ):
204204 if ctx .UNION_SYM ():
205- self .keywords .append (" union" )
205+ self .keywords .append (' union' )
206206
207207 def enterSelect_expression (self , ctx ):
208208 # we need to keep track of unions as they act as subqueries
@@ -294,9 +294,9 @@ def enterTable_atom(self, ctx):
294294 if ts :
295295 tn = [None , None ]
296296 if ts .schema_name ():
297- tn [0 ] = ts .schema_name ().getText ().replace (quote_char , "" )
297+ tn [0 ] = ts .schema_name ().getText ().replace (quote_char , '' )
298298 if ts .table_name ():
299- tn [1 ] = ts .table_name ().getText ().replace (quote_char , "" )
299+ tn [1 ] = ts .table_name ().getText ().replace (quote_char , '' )
300300 self .tables .append ((alias , tn , ctx .depth ()))
301301
302302 logging .info ((ctx .depth (), ctx .__class__ .__name__ , [tn , alias ]))
@@ -315,7 +315,7 @@ def enterDisplayed_column(self, ctx):
315315 )
316316 self ._extract_column (ctx )
317317 if ctx .ASTERISK ():
318- self .keywords .append ("*" )
318+ self .keywords .append ('*' )
319319
320320 def enterSelect_expression (self , ctx ):
321321 logging .info ((ctx .depth (), ctx .__class__ .__name__ ))
@@ -324,11 +324,11 @@ def enterSelect_expression(self, ctx):
324324 def enterSelect_list (self , ctx ):
325325 if ctx .ASTERISK ():
326326 logging .info (
327- (ctx .depth (), ctx .__class__ .__name__ , [[None , None , "*" ], None ])
327+ (ctx .depth (), ctx .__class__ .__name__ , [[None , None , '*' ], None ])
328328 )
329- self .data .append ([ctx .depth (), ctx , [[[None , None , "*" ], None ]]])
330- self .columns .append (("*" , None ))
331- self .keywords .append ("*" )
329+ self .data .append ([ctx .depth (), ctx , [[[None , None , '*' ], None ]]])
330+ self .columns .append (('*' , None ))
331+ self .keywords .append ('*' )
332332
333333 def enterFunctionList (self , ctx ):
334334 self .functions .append (ctx .getText ())
@@ -337,7 +337,7 @@ def enterGroup_functions(self, ctx):
337337 self .functions .append (ctx .getText ())
338338
339339 def enterGroupby_clause (self , ctx ):
340- self .keywords .append (" group by" )
340+ self .keywords .append (' group by' )
341341 col = self ._extract_column (ctx , append = False )
342342 if col [1 ][0 ][0 ][2 ] not in self .column_aliases :
343343 self ._extract_column (ctx )
@@ -353,7 +353,7 @@ def enterGroupby_clause(self, ctx):
353353 )
354354
355355 def enterWhere_clause (self , ctx ):
356- self .keywords .append (" where" )
356+ self .keywords .append (' where' )
357357 self ._extract_column (ctx )
358358 logging .info (
359359 (
@@ -367,7 +367,7 @@ def enterWhere_clause(self, ctx):
367367 )
368368
369369 def enterHaving_clause (self , ctx ):
370- self .keywords .append (" having" )
370+ self .keywords .append (' having' )
371371 self ._extract_column (ctx )
372372 logging .info (
373373 (
@@ -381,7 +381,7 @@ def enterHaving_clause(self, ctx):
381381 )
382382
383383 def enterOrderby_clause (self , ctx ):
384- self .keywords .append (" order by" )
384+ self .keywords .append (' order by' )
385385 col = self ._extract_column (ctx , append = False )
386386 if col [1 ][0 ][0 ][2 ] not in self .column_aliases :
387387 self ._extract_column (ctx )
@@ -397,10 +397,10 @@ def enterOrderby_clause(self, ctx):
397397 )
398398
399399 def enterLimit_clause (self , ctx ):
400- self .keywords .append (" limit" )
400+ self .keywords .append (' limit' )
401401
402402 def enterJoin_condition (self , ctx ):
403- self .keywords .append (" join" )
403+ self .keywords .append (' join' )
404404 self ._extract_column (ctx , join_columns = ctx )
405405 logging .info (
406406 (
@@ -414,28 +414,28 @@ def enterJoin_condition(self, ctx):
414414 )
415415
416416 def enterSpoint (self , ctx ):
417- self .functions .append (" spoint" )
417+ self .functions .append (' spoint' )
418418
419419 def enterScircle (self , ctx ):
420- self .functions .append (" scircle" )
420+ self .functions .append (' scircle' )
421421
422422 def enterSline (self , ctx ):
423- self .functions .append (" sline" )
423+ self .functions .append (' sline' )
424424
425425 def enterSellipse (self , ctx ):
426- self .functions .append (" sellipse" )
426+ self .functions .append (' sellipse' )
427427
428428 def enterSbox (self , ctx ):
429- self .functions .append (" sbox" )
429+ self .functions .append (' sbox' )
430430
431431 def enterSpoly (self , ctx ):
432- self .functions .append (" spoly" )
432+ self .functions .append (' spoly' )
433433
434434 def enterSpath (self , ctx ):
435- self .functions .append (" spath" )
435+ self .functions .append (' spath' )
436436
437437 def enterStrans (self , ctx ):
438- self .functions .append (" strans" )
438+ self .functions .append (' strans' )
439439
440440 return ColumnKeywordFunctionListener
441441
@@ -623,19 +623,19 @@ def _get_budget_column(self, c, tab, ref):
623623 column_found = False
624624
625625 for bc in ref :
626- if bc [0 ][2 ] == "*" :
627- t = [[bc [0 ][0 ], bc [0 ][1 ]], " None" ]
626+ if bc [0 ][2 ] == '*' :
627+ t = [[bc [0 ][0 ], bc [0 ][1 ]], ' None' ]
628628 column_found = True
629629 break
630630 elif bc [1 ] and c [0 ][2 ] == bc [1 ]:
631- t = [[bc [0 ][0 ], bc [0 ][1 ]], " None" ]
631+ t = [[bc [0 ][0 ], bc [0 ][1 ]], ' None' ]
632632 cname = bc [0 ][2 ]
633633 if c [1 ] is None :
634634 calias = c [0 ][2 ]
635635 column_found = True
636636 break
637637 elif c [0 ][2 ] == bc [0 ][2 ] and bc [1 ] is None :
638- t = [[bc [0 ][0 ], bc [0 ][1 ]], " None" ]
638+ t = [[bc [0 ][0 ], bc [0 ][1 ]], ' None' ]
639639 column_found = True
640640 break
641641
@@ -666,7 +666,7 @@ def _extract_columns(
666666 calias = c [1 ]
667667
668668 # if * is selected we don't care too much
669- if c [0 ][0 ] is None and c [0 ][1 ] is None and c [0 ][2 ] == "*" and not join :
669+ if c [0 ][0 ] is None and c [0 ][1 ] is None and c [0 ][2 ] == '*' and not join :
670670 for slt in select_list_tables :
671671 extra_columns .append (
672672 [[slt [0 ][0 ][0 ], slt [0 ][0 ][1 ], cname , c [0 ][3 ]], calias ]
@@ -683,13 +683,13 @@ def _extract_columns(
683683 try :
684684 tab = select_list_tables [0 ][0 ]
685685 if tab [0 ][0 ] is None :
686- raise QueryError (" Missing schema specification." )
686+ raise QueryError (' Missing schema specification.' )
687687
688688 # We have to check if we also have a join on the same level
689689 # and we are actually touching a column from the joined table
690690 if (
691691 join
692- and c [0 ][2 ] != "*"
692+ and c [0 ][2 ] != '*'
693693 and (tab [1 ] != c [0 ][1 ] or (tab [1 ] is None and c [0 ][1 ] is None ))
694694 ):
695695 cname , cctx , calias , column_found , tab = self ._get_budget_column (
@@ -718,7 +718,7 @@ def _extract_columns(
718718 not column_found
719719 and c [0 ][1 ] is not None
720720 and c [0 ][1 ] != tab [0 ][1 ]
721- and "*" not in ref_cols
721+ and '*' not in ref_cols
722722 ):
723723 raise QueryError ("Unknown column '%s.%s'." % (c [0 ][1 ], c [0 ][2 ]))
724724
@@ -776,7 +776,7 @@ def _extract_columns(
776776
777777 elif (
778778 c [0 ][2 ] is not None
779- and c [0 ][2 ] != "*"
779+ and c [0 ][2 ] != '*'
780780 and c [0 ][1 ] is None
781781 and len (ref_dict .keys ()) > 1
782782 and not join
@@ -818,12 +818,12 @@ def _match_and_replace_function_name(query, function_name, i):
818818 This very roughly checks if the function name is present in the query.
819819 We check for a space, the function name, and an opening parenthesis.
820820 """
821- pattern = r"\s" + re .escape (function_name ) + r"\("
821+ pattern = r'\s' + re .escape (function_name ) + r'\('
822822 match = re .search (pattern , query )
823823 if match :
824824 start , end = match .span ()
825825 # Replace the matched function name with UDF_{i}
826- query = query [: start + 1 ] + f" UDF_{ i } " + query [end - 1 :]
826+ query = query [: start + 1 ] + f' UDF_{ i } ' + query [end - 1 :]
827827
828828 return match , query
829829
@@ -1025,7 +1025,7 @@ def process_query(
10251025 )
10261026 if len (mc ):
10271027 unref_cols = "', '" .join (
1028- ["." .join ([j for j in i [0 ][:3 ] if j ]) for i in mc ]
1028+ ['.' .join ([j for j in i [0 ][:3 ] if j ]) for i in mc ]
10291029 )
10301030 raise QueryError ("Unreferenced column(s): '%s'." % unref_cols )
10311031
@@ -1052,7 +1052,7 @@ def process_query(
10521052 asterisk_columns = []
10531053 del_columns = []
10541054 for col in touched_columns :
1055- if col [2 ] == "*" :
1055+ if col [2 ] == '*' :
10561056 asterisk_columns .append (col )
10571057
10581058 for acol in asterisk_columns :
@@ -1089,8 +1089,8 @@ def process_query(
10891089
10901090 if len (self .replaced_functions ) > 0 :
10911091 for i , function_name in self .replaced_functions .items ():
1092- self ._query = self .query .replace (f" UDF_{ i } " , function_name )
1093- self .functions .remove (f" UDF_{ i } " )
1092+ self ._query = self .query .replace (f' UDF_{ i } ' , function_name )
1093+ self .functions .remove (f' UDF_{ i } ' )
10941094 self .functions .append (function_name )
10951095
10961096 @property
@@ -1102,7 +1102,7 @@ def query(self):
11021102 return self ._query
11031103
11041104 def _strip_query (self , query ):
1105- return query .lstrip (" \n " ).rstrip ().rstrip (";" ) + ";"
1105+ return query .lstrip (' \n ' ).rstrip ().rstrip (';' ) + ';'
11061106
11071107 def _strip_column (self , col ):
11081108 scol = [None , None , None ]
0 commit comments