<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(self, sql=None, filename=None, **kwargs):
 """ run raw sql from sql or file against. :param sql: Raw SQL query to pass directly to the connection. :type sql: string :param filename: Path to a file containing a SQL query. The path should be relative to CWD. :type filename: string :param db: `optional` Database name from your ``jardin_conf.py``, overrides the default database set in the model declaration. :type db: string :param role: `optional` One of ``('master', 'replica')`` to override the default. :type role: string :returns: ``jardin.Collection`` collection, which is a ``pandas.DataFrame``. """

        results = query(
            sql=sql,
            filename=filename,
            db=self.db_names[kwargs.get('role', 'replica')],
            **kwargs
            )

        if results is None:
            return None
        else:
            return self.collection_instance(results)