@runner<EOL><INDENT>async def query(<EOL>self,<EOL>q: AnyStr,<EOL>*,<EOL>epoch: str = '<STR_LIT>',<EOL>chunked: bool = False,<EOL>chunk_size: Optional[int] = None,<EOL>db: Optional[str] = None,<EOL>use_cache: bool = False,<EOL>) -> Union[AsyncGenerator[ResultType, None], ResultType]:<DEDENT>
async def _chunked_generator(url, data):<EOL><INDENT>async with self._session.post(url, data=data) as resp:<EOL><INDENT>logger.debug(f'<STR_LIT>')<EOL>resp.content._high_water *= <NUM_LIT:16><EOL>async for chunk in resp.content:<EOL><INDENT>chunk = json.loads(chunk)<EOL>self._check_error(chunk)<EOL>yield chunk<EOL><DEDENT><DEDENT><DEDENT>if not self._session:<EOL><INDENT>await self.create_session()<EOL><DEDENT>if not isinstance(chunked, bool):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>data = dict(q=q, db=db or self.db, chunked=str(chunked).lower(), epoch=epoch)<EOL>if chunked and chunk_size:<EOL><INDENT>data['<STR_LIT>'] = chunk_size<EOL><DEDENT>url = self.url.format(endpoint='<STR_LIT>')<EOL>if chunked:<EOL><INDENT>if use_cache:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if self.mode != '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if self.output == '<STR_LIT>':<EOL><INDENT>return _chunked_generator(url, data)<EOL><DEDENT>raise ValueError(f"<STR_LIT>")<EOL><DEDENT>key = f'<STR_LIT>'<EOL>if use_cache and self._redis and await self._redis.exists(key):<EOL><INDENT>logger.debug(f'<STR_LIT>')<EOL>data = lz4.decompress(await self._redis.get(key))<EOL><DEDENT>else:<EOL><INDENT>async with self._session.post(url, data=data) as resp:<EOL><INDENT>data = await resp.read()<EOL>if use_cache and self._redis:<EOL><INDENT>logger.debug(f'<STR_LIT>')<EOL>if resp.status == <NUM_LIT:200>:<EOL><INDENT>await self._redis.set(key, lz4.compress(data))<EOL>await self._redis.expire(key, self.cache_expiry)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logger.debug(f'<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>data = json.loads(data)<EOL>self._check_error(data)<EOL>if self.output == '<STR_LIT>':<EOL><INDENT>return data<EOL><DEDENT>elif self.output == '<STR_LIT>':<EOL><INDENT>return serialization.dataframe.parse(data)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>
Sends a query to InfluxDB.
        Please refer to the InfluxDB documentation for all the possible queries:
        https://docs.influxdata.com/influxdb/latest/query_language/

        :param q: Raw query string
        :param db: Database to be queried. Defaults to `self.db`.
        :param epoch: Precision level of response timestamps.
            Valid values: ``{'ns', 'u', 'µ', 'ms', 's', 'm', 'h'}``.
        :param chunked: If ``True``, makes InfluxDB return results in streamed batches
            rather than as a single response.
            Returns an AsyncGenerator which yields responses
            in the same format as non-chunked queries.
        :param chunk_size: Max number of points for each chunk. By default, InfluxDB chunks
            responses by series or by every 10,000 points, whichever occurs first.
        :param use_cache:
        :return: Response in the format specified by the combination of
           :attr:`.InfluxDBClient.output` and ``chunked``