title: Implicit conversion of UUID to character varying when using TEIID with postgres
body: <p>I have a VDB containing a view with a UUID column with this definition</p>
  <pre><code>&lt;vdb name=&quot;_GENERATED_users_info&quot; version=&quot;6&quot;&gt;
      &lt;import-vdb name=&quot;_INTERNAL_internal&quot; version=&quot;1&quot;/&gt;
      &lt;model name=&quot;GEN_view&quot; type=&quot;VIRTUAL&quot;&gt;
          &lt;metadata type=&quot;DDL&quot;&gt;
              &lt;![CDATA[ CREATE VIEW &quot;_view_workflow_data&quot; (&quot;uuid&quot; VARCHAR, &quot;email&quot; VARCHAR) OPTIONS (UPDATABLE 'true') AS SELECT &quot;public&quot;.&quot;security_users_info&quot;.&quot;uuid&quot; AS &quot;uuid&quot;, &quot;public&quot;.&quot;security_users_info&quot;.&quot;email&quot; AS &quot;email&quot; FROM &quot;public&quot;.&quot;security_users_info&quot; ]]&gt;&lt;/metadata&gt;
      &lt;/model&gt;
  &lt;/vdb&gt;
  </code></pre>
  <p>Column <code>security_users_info.uuid</code> is of type <code>UUID</code>.
  When I try to execute a query
  <code>SELECT &quot;uuid&quot;, &quot;email&quot; FROM &quot;_view_workflow_data&quot; WHERE (&quot;uuid&quot; IN (?''718e52dd-058a-4306-9213-c999181163c7') AND 1 = 1)</code>
  I get an error <strong>org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = character varying</strong>. The error doesn't come from the query I sent but from a query generated by TEIID executed on the physical table</p>
  <p><code>TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0.&quot;uuid&quot; AS varchar), g_0.&quot;email&quot; FROM &quot;public&quot;.&quot;security_users_info&quot; AS g_0 WHERE g_0.&quot;uuid&quot; = ?]</code></p>
  <p>I tried to convert the column in the view definition to varchar like this <code>CONVERT(&quot;public&quot;.&quot;security_users_info&quot;.&quot;uuid&quot;, VARCHAR)  AS &quot;uuid&quot;</code> but I get the same error.</p>
  <p>The failing query works fine directly in postgresql as it implicitly converts the uuid text into a uuid type.</p>
  <p>I'm aware of the section about UID types in <a href="http://teiid.github.io/teiid-documents/master/content/reference/as_jdbc-translators.html" rel="nofollow noreferrer">http://teiid.github.io/teiid-documents/master/content/reference/as_jdbc-translators.html</a> but as the implicit conversion seems to work when I execute the query directly in postgresql, I would expect that section not to apply in this situation.</p>
  <p>I'm using TEIID 16 with postgresql 9.5 and postgres JDBC driver 42.2.</p>
  <p>Am I doing something in a wrong way or is this not supposed to work?</p>
  <p>Whole stacktrace:</p>
  <pre><code>ERROR# - org.jooq.exception.DataAccessException: SQL [select &quot;uuid&quot;, &quot;email&quot; from &quot;_view_workflow_data&quot; where (&quot;uuid&quot; in (?) and 1 = 1)]; TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0.&quot;uuid&quot; AS varchar), g_0.&quot;email&quot; FROM &quot;public&quot;.&quot;security_users_info&quot; AS g_0 WHERE g_0.&quot;uuid&quot; = ?] (c.m.w.c.d.DataObjectVerticle#?)org.jooq.exception.DataAccessException: SQL [select &quot;uuid&quot;, &quot;email&quot; from &quot;_view_workflow_data&quot; where (&quot;uuid&quot; in (?) and 1 = 1)]; TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0.&quot;uuid&quot; AS varchar), g_0.&quot;email&quot; FROM &quot;public&quot;.&quot;security_users_info&quot; AS g_0 WHERE g_0.&quot;uuid&quot; = ?]
      at org.jooq_3.13.0-SNAPSHOT.DEFAULT.debug(Unknown Source)
      at org.jooq.impl.Tools.translate(Tools.java:2717)
      at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)
      at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:382)
      at com.mathesio.workflow.core.dataObject.DataObjectService.lambda$select$16(DataObjectService.java:365)
      at com.mathesio.teiid.Connections.ConnectionManager.lambda$getConnectionJOOQ$0(ConnectionManager.java:187)
      at org.jooq.impl.DefaultDSLContext$3.run(DefaultDSLContext.java:609)
      at org.jooq.impl.DefaultDSLContext$3.run(DefaultDSLContext.java:606)
      at org.jooq.impl.DefaultDSLContext.lambda$transactionResult0$0(DefaultDSLContext.java:537)
      at org.jooq.impl.Tools$12$1.block(Tools.java:4847)
      at java.base/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3128)
      at org.jooq.impl.Tools$12.get(Tools.java:4844)
      at org.jooq.impl.DefaultDSLContext.transactionResult0(DefaultDSLContext.java:589)
      at org.jooq.impl.DefaultDSLContext.transactionResult(DefaultDSLContext.java:506)
      at org.jooq.impl.DefaultDSLContext.transaction(DefaultDSLContext.java:606)
      at com.mathesio.teiid.Connections.ConnectionManager.lambda$getConnectionJOOQ$1(ConnectionManager.java:186)
      at com.mathesio.workflow.core.database.transaction.TransactionJPA.lambda$new$42(TransactionJPA.java:1813)
      at com.mathesio.workflow.core.database.transaction.TransactionJPA.lambda$new$19(TransactionJPA.java:388)
      at com.mathesio.workflow.core.database.transaction.TransactionJPA.runCore(TransactionJPA.java:993)
      at com.mathesio.workflow.core.database.transaction.TransactionJPA.lambda$run$25(TransactionJPA.java:1306)
      at com.mathesio.workflow.core.database.transaction.TransactionJPA$1.call(TransactionJPA.java:755)
      at com.mathesio.workflow.core.database.transaction.TransactionJPA$1.call(TransactionJPA.java:738)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at com.mathesio.workflow.core.database.transaction.PriorityFuture.run(PriorityFuture.java:58)
      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)
  Caused by: org.teiid.jdbc.TeiidSQLException: TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0.&quot;uuid&quot; AS varchar), g_0.&quot;email&quot; FROM &quot;public&quot;.&quot;security_users_info&quot; AS g_0 WHERE g_0.&quot;uuid&quot; = ?]
      at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:131)
      at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:67)
      at org.teiid.jdbc.StatementImpl.postReceiveResults(StatementImpl.java:783)
      at org.teiid.jdbc.StatementImpl.access$100(StatementImpl.java:62)
      at org.teiid.jdbc.StatementImpl$2.onCompletion(StatementImpl.java:581)
      at org.teiid.client.util.ResultsFuture.done(ResultsFuture.java:131)
      at org.teiid.client.util.ResultsFuture.access$200(ResultsFuture.java:36)
      at org.teiid.client.util.ResultsFuture$1.receiveResults(ResultsFuture.java:75)
      at org.teiid.net.socket.SocketServerInstanceImpl.receivedMessage(SocketServerInstanceImpl.java:281)
      at org.teiid.net.socket.SocketServerInstanceImpl.read(SocketServerInstanceImpl.java:333)
      at org.teiid.net.socket.SocketServerInstanceImpl$RemoteInvocationHandler$1.get(SocketServerInstanceImpl.java:423)
      at org.teiid.jdbc.StatementImpl.executeSql(StatementImpl.java:590)
      at org.teiid.jdbc.PreparedStatementImpl.execute(PreparedStatementImpl.java:240)
      at org.jooq.tools.jdbc.DefaultPreparedStatement.execute(DefaultPreparedStatement.java:209)
      at org.jooq.impl.Tools.executeStatementAndGetFirstResultSet(Tools.java:3935)
      at org.jooq.impl.AbstractResultQuery.execute(AbstractResultQuery.java:294)
      at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:368)
      ... 23 common frames omitted
  Caused by: org.teiid.core.TeiidProcessingException: TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0.&quot;uuid&quot; AS varchar), g_0.&quot;email&quot; FROM &quot;public&quot;.&quot;security_users_info&quot; AS g_0 WHERE g_0.&quot;uuid&quot; = ?]
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.exceptionOccurred(DataTierTupleSource.java:397)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.nextTuple(DataTierTupleSource.java:157)
      at org.jboss.teiid@16.0.0//org.teiid.query.processor.relational.AccessNode.nextBatchDirect(AccessNode.java:401)
      at org.jboss.teiid@16.0.0//org.teiid.query.processor.relational.RelationalNode.nextBatch(RelationalNode.java:277)
      at org.jboss.teiid@16.0.0//org.teiid.query.processor.relational.RelationalPlan.nextBatch(RelationalPlan.java:139)
      at org.jboss.teiid@16.0.0//org.teiid.query.processor.QueryProcessor.nextBatchDirect(QueryProcessor.java:147)
      at org.jboss.teiid@16.0.0//org.teiid.query.processor.QueryProcessor.nextBatch(QueryProcessor.java:110)
      at org.jboss.teiid@16.0.0//org.teiid.query.processor.BatchCollector.collectTuples(BatchCollector.java:160)
      at org.jboss.teiid@16.0.0//org.teiid.query.processor.BatchCollector.collectTuples(BatchCollector.java:142)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.RequestWorkItem.processMore(RequestWorkItem.java:491)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.RequestWorkItem.process(RequestWorkItem.java:361)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.AbstractWorkItem.run(AbstractWorkItem.java:43)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.RequestWorkItem.run(RequestWorkItem.java:284)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:283)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:124)
      at org.jboss.teiid@16.0.0//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)
  Caused by: org.teiid.translator.TranslatorException: 0 Remote org.teiid.translator.jdbc.JDBCExecutionException: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0.&quot;uuid&quot; AS varchar), g_0.&quot;email&quot; FROM &quot;public&quot;.&quot;security_users_info&quot; AS g_0 WHERE g_0.&quot;uuid&quot; = ?]
      at org.jboss.teiid.translator.jdbc@16.0.0//org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:127)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:405)
      at jdk.internal.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:228)
      at org.jboss.teiid@16.0.0//com.sun.proxy.$Proxy45.execute(Unknown Source)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:302)
      at org.jboss.teiid@16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.nextTuple(DataTierTupleSource.java:138)
      ... 17 common frames omitted
  Caused by: java.sql.SQLException: Remote org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = character varying
    Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
    Position: 109
      at org.postgresql@42.2.2//org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
      at org.postgresql@42.2.2//org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)
      at org.postgresql@42.2.2//org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
      at org.postgresql@42.2.2//org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
      at org.postgresql@42.2.2//org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
      at org.postgresql@42.2.2//org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
      at org.postgresql@42.2.2//org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118)
      at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504)
      at org.jboss.teiid.translator.jdbc@16.0.0//org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:119)
      ... 25 common frames omitted
  </code></pre>