Example: Nullified EXPAND Operation - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-05
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantage™

This example shows how when an expanded column is not specified in the select list of a query, but a DISTINCT operator is specified, the EXPAND operation is nullified.

     CREATE SET TABLE df2.t1, NO FALLBACK, NO BEFORE JOURNAL,
                              NO AFTER JOURNAL, CHECKSUM = DEFAULT,
                              DEFAULT MERGEBLOCKRATIO (
       i  INTEGER,
       j  INTEGER,
       pd PERIOD(DATE) FORMAT 'yyyy-mm-dd')
     PRIMARY INDEX (i);

The first SELECT statement in this example does not specify the DISTINCT operator.

     EXPLAIN SELECT i,j
             FROM t1
             EXPAND ON pd AS expd BY INTERVAL '1' DAY;

An EXPLAIN shows an EXPAND ON t1.pd.

The following SELECT statement specifies the DISTINCT operator.

     SELECT DISTINCT i,j
             FROM t1
             EXPAND ON pd AS expd BY INTERVAL '1' day;

An EXPLAIN shows a SORT and elimination of duplicate rows. The DISTINCT operator makes the EXPAND ON step unnecessary.