Teradata Package for Python Function Reference - 17.00 - from_query - Teradata Package for Python
Teradata® Package for Python Function Reference
- Product
- Teradata Package for Python
- Release Number
- 17.00
- Published
- November 2021
- Language
- English (United States)
- Last Update
- 2021-11-19
- teradataml.dataframe.dataframe.DataFrame.from_query = from_query(query, index=True, index_label=None, materialize=False) method of builtins.type instance
- Class method for creating a DataFrame from a table or view.
PARAMETERS:
query:
Required Argument.
Specifies the Teradata Vantage SQL query referenced by this DataFrame.
Only "SELECT" queries are supported. Exception will be
raised, if any other type of query is passed.
Unsupported queries include:
1. DDL Queries like CREATE, DROP, ALTER etc.
2. DML Queries like INSERT, UPDATE, DELETE etc. except SELECT.
3. SELECT query with ORDER BY clause is not supported.
Types: str
index:
Optional Argument.
True if using index column for sorting otherwise False.
Default Value: True
Types: bool
index_label:
Optional Argument.
Column/s used for sorting.
Types: str
materialize:
Optional Argument.
Whether to materialize DataFrame or not when created.
One should use enable materialization, when the query passed to from_query(),
is expected to produce non-deterministic results, when it is executed multiple
times. Using this option will help user to have deterministic results in the
resulting teradataml DataFrame.
Default Value: False (No materialization)
Types: bool
EXAMPLES:
from teradataml.dataframe.dataframe import DataFrame
load_example_data("dataframe","sales")
df = DataFrame.from_query("select accounts, Jan, Feb from sales")
df = DataFrame.from_query("select accounts, Jan, Feb from sales", False)
df = DataFrame.from_query("select * from sales", True, "accounts")
RETURNS:
DataFrame
RAISES:
TeradataMlException - TDMLDF_CREATE_FAIL