docs: def get_query_tables(query):
      """
      :type query str
      :rtype: list[str]
      """
      tables = []
      last_keyword = None
      last_token = None
  
      table_syntax_keywords = [
          # SELECT queries
          'FROM', 'WHERE', 'JOIN', 'INNER JOIN', 'LEFT JOIN', 'RIGHT JOIN', 'ON',
          # INSERT queries
          'INTO', 'VALUES',
          # UPDATE queries
          'UPDATE', 'SET',
          # Hive queries
          'TABLE',  # INSERT TABLE
      ]
  
      # print(query, get_query_tokens(query))
  
      for token in get_query_tokens(query):
          # print([token, token.ttype, last_token, last_keyword])
          if token.is_keyword and token.value.upper() in table_syntax_keywords:
              # keep the name of the last keyword, the next one can be a table name
              last_keyword = token.value.upper()
              # print('keyword', last_keyword)
          elif str(token) == '(':
              # reset the last_keyword for INSERT `foo` VALUES(id, bar) ...
              last_keyword = None
          elif token.is_keyword and str(token) in ['FORCE', 'ORDER']:
              # reset the last_keyword for "SELECT x FORCE INDEX" queries and "SELECT x ORDER BY"
              last_keyword = None
          elif token.is_keyword and str(token) == 'SELECT' and last_keyword in ['INTO', 'TABLE']:
              # reset the last_keyword for "INSERT INTO SELECT" and "INSERT TABLE SELECT" queries
              last_keyword = None
          elif token.ttype is Name or token.is_keyword:
              # print([last_keyword, last_token, token.value])
              # analyze the name tokens, column names and where condition values
              if last_keyword in ['FROM', 'JOIN', 'INNER JOIN', 'LEFT JOIN', 'RIGHT JOIN',
                                  'INTO', 'UPDATE', 'TABLE'] \
                      and last_token not in ['AS'] \
                      and token.value not in ['AS', 'SELECT']:
  
                  if last_token == '.':
                      # we have database.table notation example
                      # append table name to the last entry of tables
                      # as it is a database name in fact
                      database_name = tables[-1]
                      tables[-1] = '{}.{}'.format(database_name, token)
                      last_keyword = None
                  elif last_token not in [',', last_keyword]:
                      # it's not a list of tables, e.g. SELECT * FROM foo, bar
                      # hence, it can be the case of alias without AS, e.g. SELECT * FROM foo bar
                      pass
                  else:
                      table_name = str(token.value.strip('`'))
                      tables.append(table_name)
  
          last_token = token.value.upper()
  
      return unique(tables)