Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-4737

Incorrect work of left join statement

    Details

    • Steps to Reproduce:
      Hide

      1. In postgresql create the tbl_1 table by the following script:

      create table test_tables.public.test_emails(email varchar(4000));
      
      insert into test_tables.public.test_emails values ('Test1@mail.com');
      insert into test_tables.public.test_emails values ('test2@mail.com');
      insert into test_tables.public.test_emails values ('test3@mail.com');
      

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

      <datasource jndi-name="java:/test_tables" pool-name="test_tables" enabled="true" use-java-context="true">
                          <connection-url>jdbc:postgresql://localhost:5432/test_tables?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>postgres</user-name>
                              <password>xxxxxx</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_pg configured in previous step as datasource:

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

      4. Configure in test-vdb.xml the following virtual view:

      <model visible = "true" type = "VIRTUAL" name = "views">
              <metadata type = "DDL"><![CDATA[
                CREATE virtual view test_view_emails as SELECT 'test1@mail.com' as email
              ]]>
              </metadata>
      </model>
      

      5. Run the test query mentioned in description field:

      SELECT a.email, b.email, lower(a.email), lower(b.email) FROM test_tables.test_emails as a left join views.test_view_emails as b on lower(a.email)=lower(b.email);
      

      and compare results gotten via teiid and PostgreSQL.

      Show
      1. In postgresql create the tbl_1 table by the following script: create table test_tables. public .test_emails(email varchar (4000)); insert into test_tables. public .test_emails values ( 'Test1@mail.com' ); insert into test_tables. public .test_emails values ( 'test2@mail.com' ); insert into test_tables. public .test_emails values ( 'test3@mail.com' ); 2. Add postgresql database configuration in standalone-teiid.xml <datasource jndi-name= "java:/test_tables" pool-name= "test_tables" enabled= "true" use-java-context= "true" > <connection-url> jdbc:postgresql://localhost:5432/test_tables?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> postgres </user-name> <password> xxxxxx </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_pg configured in previous step as datasource: <model name= "test_tables" > <property name= "importer.useFullSchemaName" value= "false" /> <property name= "importer.tableTypes" value= "TABLE,VIEW" /> <property name= "importer.importKeys" value= "false" /> <source name= "test_tables" translator-name= "myPg" connection-jndi name= "java:/test_tables" /> </model> 4. Configure in test-vdb.xml the following virtual view: <model visible = "true" type = "VIRTUAL" name = "views" > <metadata type = "DDL" > <![CDATA[ CREATE virtual view test_view_emails as SELECT 'test1@mail.com' as email ]]> </metadata> </model> 5. Run the test query mentioned in description field: SELECT a .email, b.email, lower ( a .email), lower (b.email) FROM test_tables.test_emails as a left join views.test_view_emails as b on lower ( a .email)= lower (b.email); and compare results gotten via teiid and PostgreSQL.
    • Bugzilla Update:
      Perform

      Description

      the following query:

      SELECT a.email, b.email, lower(a.email), lower(b.email) FROM test_tables.test_emails as a left join views.test_view_emails as b on lower(a.email)=lower(b.email)
      

      leads to the following results:

      though running the same query on PostgreSQL leads to the following results:

      so this query mentioned above must work as on PostgreSQL putting null values for the b field table where conditions can't be performed.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: