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

NPE on reading from view with hasRole()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 15.0.2, 16.0.1, 17.0
    • 15.0.1
    • Query Engine
    • None
    • Hide

      1. Add MySQL (in my case I use adventureworks test database) database configuration in standalone-teiid.xml (adventureworks):

                      <datasource jndi-name="java:/adventureworks" pool-name="adventureworks" enabled="true" use-java-context="true">
                          <connection-url>jdbc:mysql://localhost:3306/adventureworks?zeroDateTimeBehavior=convertToNull</connection-url>
                          <driver>mysql</driver>
                          <new-connection-sql>set SESSION sql_mode = 'ANSI'</new-connection-sql>
                          <pool>
                              <min-pool-size>2</min-pool-size>
                              <max-pool-size>70</max-pool-size>
                          </pool>
                          <security>
                              <user-name>XXXX</user-name>
                              <password>XXXX</password>
                          </security>
                          <validation>
                              <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                              <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                          </validation>
                          <timeout>
                              <blocking-timeout-millis>120000</blocking-timeout-millis>
                              <idle-timeout-minutes>5</idle-timeout-minutes>
                          </timeout>
                      </datasource>
      

      2. Add in test-vdb.xml java:/adventureworks configured in previous step as a data source:

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

      3. Configure in the test-vdb.xml the following virtual views:

          <model visible = "true" type = "VIRTUAL" name = "views">
              <metadata type = "DDL"><![CDATA[
                create view v1
      as
      select
          "carriertrackingnumber"
          ,"rowguid"
          ,"salesorderid"
      from
          "adventureworks.salesorderdetail"
      where hasRole('data','a_role2')
      union all
      select
          "carriertrackingnumber"
          ,"rowguid"
          ,"salesorderid"
      from
          "adventureworks.salesorderdetail"
      where hasRole('data','a_role2');
      create view v2a as
      select a.salesOrderId
      from
          "views.v1" a
          join "adventureworks.salesorderdetail" b on a.salesorderid=b.salesorderid
              ]]>
              </metadata>
          </model>
      

      4. Run the query:

      select 1
      from
          "views.v2a" a
          join "views.v2a" b on a.salesorderid=b.salesorderid ;;
      
      Show
      1. Add MySQL (in my case I use adventureworks test database) database configuration in standalone-teiid.xml (adventureworks): <datasource jndi-name= "java:/adventureworks" pool-name= "adventureworks" enabled= "true" use-java-context= "true" > <connection-url> jdbc:mysql://localhost:3306/adventureworks?zeroDateTimeBehavior=convertToNull </connection-url> <driver> mysql </driver> <new-connection-sql> set SESSION sql_mode = 'ANSI' </new-connection-sql> <pool> <min-pool-size> 2 </min-pool-size> <max-pool-size> 70 </max-pool-size> </pool> <security> <user-name> XXXX </user-name> <password> XXXX </password> </security> <validation> <valid-connection-checker class-name= "org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker" /> <exception-sorter class-name= "org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter" /> </validation> <timeout> <blocking-timeout-millis> 120000 </blocking-timeout-millis> <idle-timeout-minutes> 5 </idle-timeout-minutes> </timeout> </datasource> 2. Add in test-vdb.xml java:/adventureworks configured in previous step as a data source: <model name= "adventureworks" > <property name= "importer.useFullSchemaName" value= "false" /> <property name= "importer.tableTypes" value= "TABLE,VIEW" /> <property name= "importer.importKeys" value= "false" /> <source name= "adventureworks" translator-name= "mylobs" connection-jndi-name= "java:/adventureworks" /> </model> 3. Configure in the test-vdb.xml the following virtual views: <model visible = "true" type = "VIRTUAL" name = "views" > <metadata type = "DDL" > <![CDATA[ create view v1 as select "carriertrackingnumber" , "rowguid" , "salesorderid" from "adventureworks.salesorderdetail" where hasRole( 'data' , 'a_role2' ) union all select "carriertrackingnumber" , "rowguid" , "salesorderid" from "adventureworks.salesorderdetail" where hasRole( 'data' , 'a_role2' ); create view v2a as select a.salesOrderId from "views.v1" a join "adventureworks.salesorderdetail" b on a.salesorderid=b.salesorderid ]]> </metadata> </model> 4. Run the query: select 1 from "views.v2a" a join "views.v2a" b on a .salesorderid=b.salesorderid ;;
    • Undefined

      When running the following query:

      select 1
      from
          "views.v2a" a
          join "views.v2a" b on a.salesorderid=b.salesorderid ;;
      

      Teiid generates the stacktrace with NPE:

      2020-12-23 15:08:44,089 ERROR [org.teiid.PROCESSOR] (Worker0_QueryProcessorQueue18) umCFWbQBUi+j TEIID30019 Unexpected exception for request umCFWbQBUi+j.7: java.lang.NullPointerException                                                                                                                                                                                         at org.jboss.teiid@15.0.1//org.teiid.query.optimizer.relational.rules.RuleMergeVirtual.doMerge(RuleMergeVirtual.java:188)                                                             at org.jboss.teiid@15.0.1//org.teiid.query.optimizer.relational.rules.RuleRaiseNull.raiseNullNode(RuleRaiseNull.java:213)                                                             at org.jboss.teiid@15.0.1//org.teiid.query.optimizer.relational.rules.RuleRaiseNull.execute(RuleRaiseNull.java:66)                                                                    at org.jboss.teiid@15.0.1//org.teiid.query.optimizer.relational.RelationalPlanner.executeRules(RelationalPlanner.java:1101)                                                           at org.jboss.teiid@15.0.1//org.teiid.query.optimizer.relational.RelationalPlanner.optimize(RelationalPlanner.java:235)                                                                at org.jboss.teiid@15.0.1//org.teiid.query.optimizer.QueryOptimizer.optimizePlan(QueryOptimizer.java:181)                                                                             at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.Request.generatePlan(Request.java:488)                                                                                      at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.Request.processRequest(Request.java:516)                                                                                    at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.RequestWorkItem.processNew(RequestWorkItem.java:671)                                                                        at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.RequestWorkItem.process(RequestWorkItem.java:350)                                                                           at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.AbstractWorkItem.run(AbstractWorkItem.java:43)                                                                              at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.RequestWorkItem.run(RequestWorkItem.java:284)                                                                               at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:283)                                                                        at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:124)                                                       at org.jboss.teiid@15.0.1//org.teiid.dqp.internal.process.ThreadReuseExecutor$2.run(ThreadReuseExecutor.java:212)                                                                     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)                                                                                          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)                                                                                          at java.base/java.lang.Thread.run(Thread.java:834)
      

              rhn-engineering-shawkins Steven Hawkins
              dalex005 Dmitrii Pogorelov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: