DataLake#
- morningstar_data.datalake.query(
- query_str: str,
- temp_tables: List[TempTable] | None = None,
Retrieve the results of a SQL query from the Morningstar DataLake as a Pandas DataFrame.
- Parameters:
query_str – SQL query to be executed in Morningstar DataLake
temp_tables – A list of temporary tables that will exist for the duration of the data lake query.
- Returns:
A Pandas DataFrame with results of the SQL query.
- Examples:
Submit a query using a temp table
import morningstar_data as md import pandas as pd df_my_table = pd.DataFrame({'sec_id': ['F0GBR0606A', 'F00000SYAH', 'F00000WP51'] 'closing_price': [128.372, 23.02, 528.33]}) md.datalake.query(query_str = 'select * from my_table;', temp_tables = [md.datalake.TempTable('my_table', df_my_table)]
- Output:
sec_id
closing_price
F0GBR0606A
128.372
F00000SYAH
23.02
F00000WP51
528.33
- Errors:
InvalidQueryException: When query_str contains invalid sql syntax.
UnauthorizedDataLakeAccessError: When the calling user is not authorized to query the Morningstar DataLake.
TempTableNameNotFoundException: When one or more temp tables being used are not found in the query string.