SELECT

Translation specification for the SELECT statement in BigQuery

Description

The select statement scans one or more tables or expressions and returns the computed result rows (Query syntax BigQuery documentation)

Syntax

[ WITH [ RECURSIVE ] { non_recursive_cte | recursive_cte }[, ...] ]
  { select | ( query_expr ) | set_operation }
  [ ORDER BY expression [{ ASC | DESC }] [, ...] ]
  [ LIMIT count [ OFFSET skip_rows ] ]

select:
  SELECT
    [ WITH differential_privacy_clause ]
    [ { ALL | DISTINCT } ]
    [ AS { STRUCT | VALUE } ]
    select_list
  [ FROM from_clause[, ...] ]
  [ WHERE bool_expression ]
  [ GROUP BY group_by_specification ]
  [ HAVING bool_expression ]
  [ QUALIFY bool_expression ]
  [ WINDOW window_clause ]
  
select_list:
  { select_all | select_expression } [, ...]

select_all:
  [ expression. ]*
  [ EXCEPT ( column_name [, ...] ) ]
  [ REPLACE ( expression [ AS ] column_name [, ...] ) ]

select_expression:
  expression [ [ AS ] alias ]

Sample Source Patterns

Setup data

BigQuery

Snowflake

WITH cte

BigQuery

Snowflake

WITH RECURSIVE cte

BigQuery

Snowflake

UNION ALL

BigQuery

Snowflake

UNION DISTINCT

BigQuery

Snowflake

INTERSECT

BigQuery

Snowflake

EXCEPT

BigQuery

Snowflake

ORDER BY

BigQuery

Snowflake

LIMIT

BigQuery

Snowflake

SELECT ALL

BigQuery

Snowflake

SELECT DISTINCT

BigQuery

Snowflake

WHERE

BigQuery

Snowflake

GROUP BY

BigQuery

Snowflake

HAVING

BigQuery

Snowflake

QUALIFY

BigQuery

Snowflake

Known Issues

1. Differential privacy clause not supported

BigQuery allows applying differential privacy over some statistical functions to introduce noise in the data, difficulting the subtraction of information about individuals when analyzing the query results.

Snowflake does not support applying differential privacy to the results of a SELECT query, the user will be warned about this everytime the clause is found.

2. WINDOW clause not supported

Snowflake does not support declaring window variables to use it in window functions, the user will be warned about this everytime the clause is found.

  1. MSC-BQ0006: Snowflake does not support differential privacy

  2. MSC-BQ0007: Snowflake does not support named windows

Last updated

Was this helpful?