lakehouse_engine.io.readers.query_reader

Module to define behaviour to read from a query.

 1"""Module to define behaviour to read from a query."""
 2
 3from pyspark.sql import DataFrame
 4
 5from lakehouse_engine.core.definitions import InputSpec
 6from lakehouse_engine.core.exec_env import ExecEnv
 7from lakehouse_engine.io.reader import Reader
 8
 9
10class QueryReader(Reader):
11    """Class to read data from a query."""
12
13    def __init__(self, input_spec: InputSpec):
14        """Construct QueryReader instances.
15
16        Args:
17            input_spec: input specification.
18        """
19        super().__init__(input_spec)
20
21    def read(self) -> DataFrame:
22        """Read data from a query.
23
24        Returns:
25            A dataframe containing the data from the query.
26        """
27        return ExecEnv.SESSION.sql(self._input_spec.query)
class QueryReader(lakehouse_engine.io.reader.Reader):
11class QueryReader(Reader):
12    """Class to read data from a query."""
13
14    def __init__(self, input_spec: InputSpec):
15        """Construct QueryReader instances.
16
17        Args:
18            input_spec: input specification.
19        """
20        super().__init__(input_spec)
21
22    def read(self) -> DataFrame:
23        """Read data from a query.
24
25        Returns:
26            A dataframe containing the data from the query.
27        """
28        return ExecEnv.SESSION.sql(self._input_spec.query)

Class to read data from a query.

QueryReader(input_spec: lakehouse_engine.core.definitions.InputSpec)
14    def __init__(self, input_spec: InputSpec):
15        """Construct QueryReader instances.
16
17        Args:
18            input_spec: input specification.
19        """
20        super().__init__(input_spec)

Construct QueryReader instances.

Arguments:
  • input_spec: input specification.
def read(self) -> pyspark.sql.dataframe.DataFrame:
22    def read(self) -> DataFrame:
23        """Read data from a query.
24
25        Returns:
26            A dataframe containing the data from the query.
27        """
28        return ExecEnv.SESSION.sql(self._input_spec.query)

Read data from a query.

Returns:

A dataframe containing the data from the query.