<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query_by_sql(self, sql):
 """ Returns entries matching given SQL query :type sql str :rtype: list[dict] """

        # https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest.html
        # https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-select.html
        body = {'query': sql}

        resp = self._es.transport.perform_request('POST', '/_xpack/sql', params={'format': 'json'}, body=body)

        # build key-value dictionary for each row to match results returned by query_by_string
        columns = [column['name'] for column in resp.get('columns')]

        return [dict(zip(columns, row)) for row in resp.get('rows')]