Teradata Package for Python Function Reference | 17.10 - show_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

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
Teradata Vantage
teradataml.geospatial.geodataframe.GeoDataFrame.show_query = show_query(self, full_query=False)
DESCRIPTION:
    Function returns underlying SQL for the teradataml GeoDataFrame. It is the same 
    SQL that is used to view the data for a teradataml GeoDataFrame.
 
PARAMETERS:
    full_query:
        Optional Argument.
        Specifies if the complete query for the GeoDataFrame should be returned.
        When this parameter is set to True, query for the GeoDataFrame is returned
        with respect to the base GeoDataFrame's table (from_table() or from_query()) or from the
        output tables of analytical functions (if there are any in the workflow).
        This query may or may not be directly used to retrieve data for the GeoDataFrame upon
        which the function is called.
        When this parameter is not used, string returned is the query already used
        or will be used to retrieve data for the teradataml GeoDataFrame.
        Default Value: False
        Types: bool
 
RETURNS:
    String representing the underlying SQL query for the teradataml GeoDataFrame.
 
EXAMPLES:
    >>> load_example_data("geodataframe","sample_streets")
    >>> df = GeoDataFrame.from_table("sample_streets")
    >>>
 
    # Example 1: Show query on base (from_table) GeoDataFrame, with default option
    >>> df.show_query()
    'select * from "sample_streets"'
    >>>
 
    # Example 2: Show query on base (from_query) GeoDataFrame, with default option
    >>> df_from_query = GeoDataFrame.from_query("select skey, street_shape from sample_streets")
    >>> df_from_query.show_query()
    'select skey, street_shape from sample_streets'
    >>>
 
    # Example 3: Show query on base (from_table) GeoDataFrame, with full_query option
    #            This will return same query as with default option because workflow
    #            only has one GeoDataFrame.
    >>> df.show_query(full_query = True)
    'select * from "sample_streets"'
    >>>
 
    # Example 4: Show query on base (from_query) GeoDataFrame, with full_query option
    #            This will return same query as with default option because workflow
    #            only has one GeoDataFrame.
    >>> df_from_query = GeoDataFrame.from_query("select skey, street_shape from sample_streets")
    >>> df_from_query.show_query(full_query = True)
    'select skey, street_shape from sample_streets'
    >>>
 
    # Example 5: Show query used in a workflow demonstrating default and full_query options.
    >>>
    # Workflow Step-1: Assign operation on base GeoDataFrame
    >>> df1 = df.assign(temp_column=df.skey + df.skey)
    >>>
    # Workflow Step-2: Selecting columns from assign's result
    >>> df2 = df1.select(["skey", "street_shape"])
    >>>
    # Workflow Step-3: Filtering on top of select's result
    >>> df3 = df2[df2.street_shape.is_valid == 1]
    >>>
    # Show query with full_query option on df3.
    # This will give full query upto base GeoDataFrame(df)
    >>> df3.show_query(full_query = True)
    'select * from (select skey,street_shape from (select skey AS skey, street_name AS street_name, street_shape AS street_shape, skey + skey AS temp_column from "sample_streets") as temp_table) as temp_table where street_shape.ST_IsValid() = 1'
    >>>
    # Show query with default option on df3. This will give same query as give in above case.
    >>> df3.show_query()
    'select * from (select skey,street_shape from (select skey AS skey, street_name AS street_name, street_shape AS street_shape, skey + skey AS temp_column from "sample_streets") as temp_table) as temp_table where street_shape.ST_IsValid() = 1'
    >>>
    # Executing intermediate GeoDataFrame df2
    >>> df2
                      street_shape
    skey
    1     LINESTRING (12 12,18 17)
    1     LINESTRING (2 2,3 2,4 1)
    >>>
    # Show query with default option on df3. This will give query with respect
    # to view/table created by the latest executed GeoDataFrame in the workflow (df2 in this scenario).
    # This is the query teradataml internally uses to retrieve data for GeoDataFrame df4, if executed
    # at this point.
    >>> df3.show_query()
    'select * from "ALICE"."ml__select__1646760722889302" where street_shape.ST_IsValid() = 1'
    >>>
    # Show query with full_query option on df3. This will still give the same full
    # query upto base GeoDataFrame(df)
    >>> df3.show_query(full_query = True)
    'select * from (select skey,street_shape from (select skey AS skey, street_name AS street_name, street_shape AS street_shape, skey + skey AS temp_column from "sample_streets") as temp_table) as temp_table where street_shape.ST_IsValid() = 1'
    >>>