MSCCP0001
The following subquery matches at least one of the patterns considered invalid and may produce compilation errors
Severity
Description
Code Example
Input Code:
CREATE TABLE tableA
(
col3 INTEGER,
col4 VARCHAR(50)
);
create table tableB
(
col3 INTEGER,
col4 VARCHAR(50)
);
INSERT INTO tableA VALUES(59, 'Hello');
INSERT INTO tableA VALUES(200, 'Bye');
INSERT INTO tableB VALUES(200, 'Bye');
INSERT INTO tableB VALUES(500, 'Testing');
-- This subquery is considerd correlated non-scalar by Snowflake and will generate unsupported subquery error
SELECT col2 FROM tableA WHERE col1 = (SELECT col3 FROM tableB WHERE col2 = col4);
-- This subquery is considered correlated scalar so its safe
SELECT col2 FROM tableA WHERE col1 = (SELECT AVG(col3) FROM tableB WHERE col2 = col4);Output Code:
Recommendations
Last updated
