def token2sql( token: Token, query: 'query_module.BaseQuery' ) -> U['CountFuncAll', 'CountFuncSingle']: try: ## FIX: COUNT(DISTINCT COL) ## TODO: This just gets the parser through the token, but distinct logic is not actually handled yet. if isinstance(token[0], Identifier): token.get_parameters()[0] else: token[0].get_parameters()[0] except IndexError: return CountFuncAll(token, query) else: return CountFuncSingle(token, query)
def handle_into( self, idx: int, next_token: Token, statement: TokenList ) -> Tuple[Schema, int]: table_alias = self.get_identifier_name(next_token) table_name = self.get_full_name(next_token) if isinstance(next_token, Function): extracted = self.extract_write_schema( next_token.get_parameters(), table_alias, table_alias ) else: extracted = self.extract_write_schema( [Token(Wildcard, "*")], table_name, table_alias ) return extracted, idx
def handle_into(self, idx: int, next_token: Token, statement: TokenList) -> Tuple[Schema, int]: if next_token.is_group: # if token is group, get inner function token if exist for token in next_token.tokens: if isinstance(token, Function): next_token = token table_alias = self.get_identifier_name(next_token) table_name = self.get_full_name(next_token) if isinstance(next_token, Function): extracted = self.extract_write_schema(next_token.get_parameters(), table_alias, table_alias) else: extracted = self.extract_write_schema([Token(Wildcard, "*")], table_name, table_alias) return extracted, idx