Dwh.dev documentation
  • What is Dwh.dev?
  • Features
    • Data catalog
      • PIPEs
      • Fancy SQL Highlight
    • Data Lineage
      • Object-level lineage
      • Column-level Lineage
      • In-query lineage
      • Navigation
      • JOIN and WHERE
      • Equals column lineage
      • Strong and Weak dependencies
      • Default and Virtual Columns
      • Implicit Types casting
      • Circle dependencies
      • Argument forwarding
    • TASKs
  • Integrations
    • Snowflake
      • Offline mode
      • Secured online mode
      • Snowflake Marketplace
    • DBT
    • ETL
    • BI
      • Looker
      • Other
    • API
  • Snowflake SQL Syntax and Behavior
    • Identifiers
    • Reusing column aliases
    • SELECT * ILIKE EXCLUDE REPLACE RENAME
    • Scalar functions name resolution special behavior
    • Functions overloading
    • CTE as an expression alias
    • ASOF Join
    • UDF named arguments
    • Objects auto renaming
    • Columns auto renaming
Powered by GitBook
On this page

Was this helpful?

  1. Snowflake SQL Syntax and Behavior

SELECT * ILIKE EXCLUDE REPLACE RENAME

PreviousReusing column aliasesNextScalar functions name resolution special behavior

Last updated 8 months ago

Was this helpful?

Database vendors are competing to see who can come up with the most features for SELECT *. Snowflake is not lagging and supports as many as 4 modifiers for SELECT *: ILIKE EXCLUDE REPLACE RENAME

We all know that SELECT * is bad. Now it's 4 times worse :) Ok, 3. You can't use them all together (either ILIKE or EXCLUDE).

But the most disgusting modifier is REPLACE. It allows you to replace one column with any expression. Good luck debugging, dudes :)

What happens to lineage when using these modifiers? A few examples are collected here:

Take a look at one of them:

CREATE TABLE t19(
  id INT,
  c1 BOOLEAN, 
  c2 BOOLEAN,
  c3 BOOLEAN,
  c4 BOOLEAN,
  c12c BOOLEAN
);
CREATE TABLE t20(
  c5 BOOLEAN, 
  c6 BOOLEAN
);

CREATE VIEW v20 AS
  SELECT
    * 
      ILIKE 'c%'
      REPLACE (a.c1 OR b.$2 AS c1)
      RENAME c1 AS c0
  FROM t19 a, t20 b
;

At , we display it like this:

in 4.select-ilike-exclude-replace-rename.1.sql
Dwh.dev