File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -390,21 +390,17 @@ def has_alias(self):
390390
391391 def get_alias (self ):
392392 """Returns the alias for this identifier or ``None``."""
393+
394+ # "name AS alias"
393395 kw = self .token_next_match (0 , T .Keyword , 'AS' )
394396 if kw is not None :
395- alias = self .token_next (self .token_index (kw ))
396- if alias is None :
397- return None
398- else :
399- next_ = self .token_next_by_instance (0 , Identifier )
400- if next_ is None :
401- next_ = self .token_next_by_type (0 , T .String .Symbol )
402- if next_ is None :
403- return None
404- alias = next_
405- if isinstance (alias , Identifier ):
406- return alias .get_name ()
407- return self ._remove_quotes (unicode (alias ))
397+ return self ._get_first_name (kw , keywords = True )
398+
399+ # "name alias" or "complicated column expression alias"
400+ if len (self .tokens ) > 2 :
401+ return self ._get_first_name (reverse = True )
402+
403+ return None
408404
409405 def get_name (self ):
410406 """Returns the name of this identifier.
You can’t perform that action at this time.
0 commit comments