Redshift select selected returns duplicate values

I have a database where each property of an object is stored on a separate line. The attached query does not return individual values โ€‹โ€‹in the redshift database, but works as expected when testing in any mysql compatible database.

SELECT DISTINCT distinct_value 
FROM
( 
  SELECT
    uri,
    ( SELECT DISTINCT value_string 
      FROM `test_organization__app__testsegment` AS X 
      WHERE X.uri = parent.uri AND name = 'hasTestString' AND parent.value_string IS NOT NULL ) AS distinct_value 
  FROM `test_organization__app__testsegment` AS parent 
  WHERE     
    uri IN ( SELECT uri 
             FROM `test_organization__app__testsegment` 
             WHERE name = 'types' AND value_uri_multivalue = 'Document'
           )
) AS T 
WHERE distinct_value IS NOT NULL
ORDER BY distinct_value ASC
LIMIT 10000 OFFSET 0
+4
source share
2 answers

This is not a mistake, and the behavior is deliberate, although not straightforward.

Redshift , Redshift , .. , . , SELECT DISTINCT , , , . , .

? Redshift , , . , , , ETL , .

+3

, , . , 1, 1, 2, - .

- !!

select distinct table1.col1 from table1 left outer join table2 on table1.col1 = table2.col1

, 1 dublicates

0

Source: https://habr.com/ru/post/1609709/


All Articles