Teradata Package for Python Function Reference | 20.00 - from_query - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.
Teradata® Package for Python Function Reference - 20.00
- Deployment
- VantageCloud
- VantageCore
- Edition
- Enterprise
- IntelliFlex
- VMware
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- Language
- English (United States)
- Last Update
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Enterprise_2000
- Product Category
- Teradata Vantage
- teradataml.geospatial.geodataframe.GeoDataFrame.from_query = from_query(query, index=True, index_label=None, materialize=False) method of builtins.type instance
- Class method for creating a GeoDataFrame using a query.
Note:
Use GeoDataFrame only when query result contains a Geometry data, i.e.,
column of teradatasqlalchemy types: Geometry(ST_Geometry in SQL), MBB, MBR.
Otherwise, an exception is raised.
PARAMETERS:
query:
Required Argument.
Specifies the Teradata Vantage SQL query referenced by this GeoDataFrame.
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.
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 GeoDataFrame or not when created.
You should use 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 GeoDataFrame.
Default Value: False (No materialization)
Types: bool
RETURNS:
GeoDataFrame
RAISES:
TeradataMlException - TDMLDF_CREATE_FAIL
EXAMPLES:
>>> from teradataml import GeoDataFrame
>>> load_example_data("geodataframe","sample_streets")
>>> gdf = GeoDataFrame.from_query("select skey, street_shape from sample_streets")
>>> gdf
street_shape
skey
1 LINESTRING (12 12,18 17)
1 LINESTRING (2 2,3 2,4 1)
>>> gdf = GeoDataFrame.from_query("select skey, street_shape from sample_streets", True, "skey")
>>> gdf
street_shape
skey
1 LINESTRING (12 12,18 17)
1 LINESTRING (2 2,3 2,4 1)
>>>