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

Salesforce: an implementation restriction when querying ContentDocumentLink table

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 14.0
    • Salesforce Connector
    • None
    • DV Sprint 66
    • 0.5
    • Hide

      1. add salesforce resource adapter in standalone-teiid.xml:

                      <resource-adapter id="salesforce-34">
                          <module slot="main" id="org.jboss.teiid.resource-adapter.salesforce-34"/>
                          <connection-definitions>
                              <connection-definition class-name="org.teiid.resource.adapter.salesforce.SalesForceManagedConnectionFactory" jndi-name="java:/salesforce34" enabled="true" use-java-context="true" pool-name="sfDS34">
                                 <config-property name="URL">
                                    https://login.salesforce.com/services/Soap/u/34.0
                                 </config-property>
                                 <config-property name="username">
                                    xxxxx
                                 </config-property>
                                 <config-property name="password">
                                    xxxxx
                                 </config-property>
                              </connection-definition>
                          </connection-definitions>
                      </resource-adapter>
      

      2. add sf34 model:

          <model visible="true" name="sf34">
              <source name="sf34" translator-name="mySalesforce-34" connection-jndi-name="java:/salesforce34"/>    
          </model>
          <translator name="mySalesforce-34" type="salesforce-34">
              <property name="SupportsNativeQueries" value="true"/>
          </translator>
      

      3. run the following queries and compare results:

       SELECT "Id", "LinkedEntityId", "ContentDocumentId", "IsDeleted", "ShareType", "Visibility"
      FROM "sf34.ContentDocumentLink"
      WHERE "ContentDocumentId" = '0691t000002aeKaAAI' ;;
      
      select w.* from (call sf34.native('search;SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, ShareType, Visibility FROM ContentDocumentLink WHERE ContentDocumentId = ''0691t000002aeKaAAI''', null)) as w ;;
      Show
      1. add salesforce resource adapter in standalone-teiid.xml: <resource-adapter id= "salesforce-34" > <module slot= "main" id= "org.jboss.teiid.resource-adapter.salesforce-34" /> <connection-definitions> <connection-definition class-name= "org.teiid.resource.adapter.salesforce.SalesForceManagedConnectionFactory" jndi-name= "java:/salesforce34" enabled= "true" use-java-context= "true" pool-name= "sfDS34" > <config-property name= "URL" > https://login.salesforce.com/services/Soap/u/34.0 </config-property> <config-property name= "username" > xxxxx </config-property> <config-property name= "password" > xxxxx </config-property> </connection-definition> </connection-definitions> </resource-adapter> 2. add sf34 model: <model visible= "true" name= "sf34" > <source name= "sf34" translator-name= "mySalesforce-34" connection-jndi-name= "java:/salesforce34" /> </model> <translator name= "mySalesforce-34" type= "salesforce-34" > <property name= "SupportsNativeQueries" value= "true" /> </translator> 3. run the following queries and compare results: SELECT "Id" , "LinkedEntityId" , "ContentDocumentId" , "IsDeleted" , "ShareType" , "Visibility" FROM "sf34.ContentDocumentLink" WHERE "ContentDocumentId" = '0691t000002aeKaAAI' ;; select w.* from ( call sf34.native( ' search ; SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, ShareType, Visibility FROM ContentDocumentLink WHERE ContentDocumentId = ' '0691t000002aeKaAAI' '', null )) as w ;;

      when running the following query:

      SELECT "Id", "LinkedEntityId", "ContentDocumentId", "IsDeleted", "ShareType", "Visibility"
      FROM "sf34.ContentDocumentLink"
      WHERE "ContentDocumentId" = '0691t000002aeKaAAI' ;; 

       Teiid throws out the stack trace:

       2020-08-10 14:11:56,721 WARN  [org.teiid.CONNECTOR] (Worker2_QueryProcessorQueue33) SSrs8BwlD5AI Connector worker process failed for atomic-request=SSrs8BwlD5AI.14.0.0: org.teiid.translator.TranslatorException                                                                                                                                                                   at org.teiid.salesforce.BaseSalesforceConnection.query(BaseSalesforceConnection.java:198)                                                                                             at org.teiid.translator.salesforce.execution.QueryExecutionImpl.execute(QueryExecutionImpl.java:249)                                                                                  at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:402)                                                                                               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)                                                                                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                                                                              at java.lang.reflect.Method.invoke(Method.java:498)                                                                                                                                   at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:228)                                                                                                at com.sun.proxy.$Proxy46.execute(Unknown Source)                                                                                                                                     at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:302)                                                                                        at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108)                                                                                            at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:104)                                                                                            at java.util.concurrent.FutureTask.run(FutureTask.java:266)                                                                                                                           at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:59)                                                                                                                  at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:281)                                                                                                at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:124)                                                                               at org.teiid.dqp.internal.process.ThreadReuseExecutor$2.run(ThreadReuseExecutor.java:212)                                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)                                                                                                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)                                                                                                    at java.lang.Thread.run(Thread.java:745)                                                                                                                                      Caused by: [MalformedQueryFault [ApiQueryFault [ApiFault  exceptionCode='MALFORMED_QUERY'                                                                                              exceptionMessage='Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id's using the IN operator.'                                                                                                                                                               ]                                                                                                                                                                                      row='-1'                                                                                                                                                                              column='-1'                                                                                                                                                                          ]                                                                                                                                                                                     ]                                                                                                                                                                                                                                                                                                                                                                                   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)                                                                                                              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)                                                                                       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)                                                                               at java.lang.reflect.Constructor.newInstance(Constructor.java:423)                                                                                                                    at java.lang.Class.newInstance(Class.java:442)                                                                                                                                        at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:652)                                                                                                                      at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:529)                                                                                                                      at com.sforce.ws.transport.SoapConnection.parseDetail(SoapConnection.java:230)                                                                                                        at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:204)                                                                                                    at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:150)                                                                                                            at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)                                                                                                                at com.sforce.soap.partner.PartnerConnection.query(PartnerConnection.java:1078)                                                                                                       at org.teiid.salesforce.BaseSalesforceConnection.query(BaseSalesforceConnection.java:193)                                                                                             ... 19 more

      though the native query works:

      select w.* from (call sf34.native('search;SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, ShareType, Visibility FROM ContentDocumentLink WHERE ContentDocumentId = ''0691t000002aeKaAAI''', null)) as w ;; 

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

                Created:
                Updated:
                Resolved: