Snowpark Migration Accelerator: Distinct¶

Description¶


Select all matching rows from the table references after removing duplicates in results. (Databricks SQL Language Reference SELECT)

DISTINCT eliminates duplicate values from the result set. (Snowflake SQL Language Reference SELECT)

Syntax¶

SELECT [ DISTINCT ] { named_expression | star_clause } [, ...]
  FROM table_reference
Copy
SELECT [ DISTINCT ]
       {
         [{<object_name>|<alias>}.]<col_name>
         | [{<object_name>|<alias>}.]$<col_position>
         | <expr>
       }
       [ [ AS ] <col_alias> ]
       [ , ... ]
[ ... ]
Copy

Sample Source Patterns¶

Setup data¶

Databricks¶

CREATE TEMPORARY VIEW number1(c) AS VALUES (3), (1), (2), (2), (3), (4);
Copy

Snowflake¶

CREATE TEMPORARY TABLE number1(c int);
INSERT INTO number1 VALUES (3), (1), (2), (2), (3), (4);
Copy

Pattern code¶

Databricks¶

SELECT DISTINCT c FROM number1;
Copy

c

3

1

2

4

Snowflake¶

SELECT DISTINCT c FROM number1;
Copy

c

3

1

2

4

Known Issues¶

No issues were found