Snowpark Migration Accelerator: Distinct

描述

Select all unique rows from the referenced tables. (Databricks SQL Language Reference SELECT (https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select.html))

DISTINCT removes duplicate rows from your query results. (Snowflake SQL Language Reference SELECT)

语法

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

示例源模式

设置数据

Databricks

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

Snowflake

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

模式代码

Databricks

SELECT DISTINCT c FROM number1;

c

3

1

2

4

Snowflake

SELECT DISTINCT c FROM number1;

c

3

1

2

4

已知问题

未发现任何问题