I'm trying this code where I want to convert T-SQL to databricks-SQL and I'm trying to change only the uncommon by first defining the common keywords and check it against the parsed list. I want the code to go to next step of transformation when it encounters the keyword top as its not defined in databricks. but that is not happening. This is my code parsed = sqlparse.parse(sql_query)[0] tokens = TokenList(parsed.tokens).flatten() common_keywords = ["SELECT","FROM","DISTINCT","WHERE","GROUP BY","ORDER BY","AS","JOIN","VALUES","INSERT INTO","UPDATE","DELETE FROM","SET","COUNT","AVG","MIN","MAX","SUM"] flag=True for token in tokens: if token.ttype==Keyword: if token.value.upper() not in common_keywords: flag=False break if flag: return sql_query" later I'm writing the code for replacing top with limit at the end. but the o/p of this is the query itself instead of break. Continue reading...