Details

    • Sprint:
      DV Sprint 62
    • Story Points:
      0.5
    • Steps to Reproduce:
      Hide

      1. In postgresql create the test_1, test_2, and test_3 tables using the following script:

      CREATE TABLE public.test_1
      (
        c1 character varying(4000)
      );
      CREATE TABLE public.test_2
      (
        c1 character varying(4000)
      );
      CREATE TABLE public.test_3
      (
        c1 character varying(4000)
      );
      

      2. Add postgresql database configuration in standalone-teiid.xml:

                      <datasource jndi-name="java:/test_dwh_pg" pool-name="test_dwh_pg" enabled="true" use-java-context="true">
                          <connection-url>jdbc:postgresql://localhost:5432/test_dwh?charSet=utf8</connection-url>
                          <driver-class>org.postgresql.Driver</driver-class>
                          <driver>org.postgresql</driver>
                          <pool>
                              <min-pool-size>2</min-pool-size>
                              <max-pool-size>70</max-pool-size>
                              <prefill>false</prefill>
                              <use-strict-min>false</use-strict-min>
                              <flush-strategy>FailingConnectionOnly</flush-strategy>
                          </pool>
                          <security>
                              <user-name>XXXXX</user-name>
                              <password>XXXXX</password>
                          </security>
                          <validation>
                              <check-valid-connection-sql>select 0</check-valid-connection-sql>
                          </validation>
                          <timeout>
                              <blocking-timeout-millis>120000</blocking-timeout-millis>
                              <idle-timeout-minutes>5</idle-timeout-minutes>
                          </timeout>
                      </datasource>
      

      3. Add in test-vdb.xml java:/test_tables_pg configured in previous step as datasource:

          <model name="test_dwh_pg">
              <property name="importer.useFullSchemaName" value="false"/>
              <property name="importer.tableTypes" value="TABLE,VIEW"/>
              <property name="importer.importKeys" value="false"/>
              <source name="test_dwh_pg" translator-name="myPg" connection-jndi-name="java:/test_dwh_pg"/>
          </model>
      

      4. Fill in Teiid tables created in 1. step by the following data:

      INSERT INTO test_dwh_pg.test_1 SELECT '123';;
      INSERT INTO test_dwh_pg.test_1 SELECT 'abc';;
      INSERT INTO test_dwh_pg.test_2 SELECT '123';;
      INSERT INTO test_dwh_pg.test_2 SELECT 'abc';;
      INSERT INTO test_dwh_pg.test_3 SELECT '123';;
      INSERT INTO test_dwh_pg.test_3 SELECT 'abc';;
      

      5. Run the following queries and compare results:

      -- wrong result
      SELECT *
      FROM test_dwh_pg.test_1 a
          LEFT JOIN ( SELECT x.c1 
                   	FROM test_dwh_pg.test_2 x
                   		LEFT JOIN (SELECT * FROM test_dwh_pg.test_3 WHERE c1 <> '123')  y  ON x.c1 = y.c1 WHERE y.c1 IS NULL
           ) b ON a.c1 = b.c1
      WHERE b.c1 IS NULL;;
       
      -- correct result
      SELECT *
      FROM test_dwh_pg.test_1 a
          LEFT JOIN ( SELECT x.c1 
                   	FROM test_dwh_pg.test_2 x
                   		LEFT JOIN (SELECT * FROM test_dwh_pg.test_3 WHERE c1 <> '123')  y  ON x.c1 = y.c1 WHERE y.c1 IS NULL
                   	LIMIT 1000000000	
           ) b ON a.c1 = b.c1
      WHERE b.c1 IS NULL;;
      
      Show
      1. In postgresql create the test_1, test_2, and test_3 tables using the following script: CREATE TABLE public .test_1 ( c1 character varying (4000) ); CREATE TABLE public .test_2 ( c1 character varying (4000) ); CREATE TABLE public .test_3 ( c1 character varying (4000) ); 2. Add postgresql database configuration in standalone-teiid.xml: <datasource jndi-name= "java:/test_dwh_pg" pool-name= "test_dwh_pg" enabled= "true" use-java-context= "true" > <connection-url> jdbc:postgresql://localhost:5432/test_dwh?charSet=utf8 </connection-url> <driver-class> org.postgresql.Driver </driver-class> <driver> org.postgresql </driver> <pool> <min-pool-size> 2 </min-pool-size> <max-pool-size> 70 </max-pool-size> <prefill> false </prefill> <use-strict-min> false </use-strict-min> <flush-strategy> FailingConnectionOnly </flush-strategy> </pool> <security> <user-name> XXXXX </user-name> <password> XXXXX </password> </security> <validation> <check-valid-connection-sql> select 0 </check-valid-connection-sql> </validation> <timeout> <blocking-timeout-millis> 120000 </blocking-timeout-millis> <idle-timeout-minutes> 5 </idle-timeout-minutes> </timeout> </datasource> 3. Add in test-vdb.xml java:/test_tables_pg configured in previous step as datasource: <model name= "test_dwh_pg" > <property name= "importer.useFullSchemaName" value= "false" /> <property name= "importer.tableTypes" value= "TABLE,VIEW" /> <property name= "importer.importKeys" value= "false" /> <source name= "test_dwh_pg" translator-name= "myPg" connection-jndi-name= "java:/test_dwh_pg" /> </model> 4. Fill in Teiid tables created in 1. step by the following data: INSERT INTO test_dwh_pg.test_1 SELECT '123' ;; INSERT INTO test_dwh_pg.test_1 SELECT 'abc' ;; INSERT INTO test_dwh_pg.test_2 SELECT '123' ;; INSERT INTO test_dwh_pg.test_2 SELECT 'abc' ;; INSERT INTO test_dwh_pg.test_3 SELECT '123' ;; INSERT INTO test_dwh_pg.test_3 SELECT 'abc' ;; 5. Run the following queries and compare results: -- wrong result SELECT * FROM test_dwh_pg.test_1 a LEFT JOIN ( SELECT x.c1 FROM test_dwh_pg.test_2 x LEFT JOIN ( SELECT * FROM test_dwh_pg.test_3 WHERE c1 <> '123' ) y ON x.c1 = y.c1 WHERE y.c1 IS NULL ) b ON a .c1 = b.c1 WHERE b.c1 IS NULL ;; -- correct result SELECT * FROM test_dwh_pg.test_1 a LEFT JOIN ( SELECT x.c1 FROM test_dwh_pg.test_2 x LEFT JOIN ( SELECT * FROM test_dwh_pg.test_3 WHERE c1 <> '123' ) y ON x.c1 = y.c1 WHERE y.c1 IS NULL LIMIT 1000000000 ) b ON a .c1 = b.c1 WHERE b.c1 IS NULL ;;

      Description

      Nested left joins in combination with a where x is null (on a left joined column) return wrong results:

      -- wrong result
      SELECT *
      FROM test_dwh_pg.test_1 a
          LEFT JOIN ( SELECT x.c1 
                   	FROM test_dwh_pg.test_2 x
                   		LEFT JOIN (SELECT * FROM test_dwh_pg.test_3 WHERE c1 <> '123')  y  ON x.c1 = y.c1 WHERE y.c1 IS NULL
           ) b ON a.c1 = b.c1
      WHERE b.c1 IS NULL ;;
       
      -- correct result
      SELECT *
      FROM test_dwh_pg.test_1 a
          LEFT JOIN ( SELECT x.c1 
                   	FROM test_dwh_pg.test_2 x
                   		LEFT JOIN (SELECT * FROM test_dwh_pg.test_3 WHERE c1 <> '123')  y  ON x.c1 = y.c1 WHERE y.c1 IS NULL
                   	LIMIT 1000000000	
           ) b ON a.c1 = b.c1
      WHERE b.c1 IS NULL ;;
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                shawkins Steven Hawkins
                Reporter:
                dalex005 Dmitrii Pogorelov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 3 hours
                  3h
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours
                  3h