4 Replies Latest reply on Jun 7, 2011 8:47 AM by calebwc

    Issue retrieving INET column from PostgreSQL

    calebwc

      Hi,

         I am using Teiid 7.3.0 Final and there seems to be an issue when retrieving INET values from a Postgres database.  When I try to utilize a VDB that contains an INET mapping, I receive a:

      "[TransformationException] Invalid conversion from type org.postgresql.util.PGobject with value '###.###.###.###' to type class java.lang.Object". 

       

      When going through the debug process, it appears that this occurs while attempting to retrieve a transformation object from a map within Teiid's DataTypeManager class.  The problem is there is no "object to object" mapping, so, null is returned.  My guess is that this issue may occur for any "unknown" types that Teiid maps to an object and more than just INET columns (I could be wrong.) 

       

      The exception is created and thrown in the DataTypeManager.transformValue(Object value, Class sourceType, Class<T> targetClass) method.  This method makes a call to DataTypeManager.getTransform(Class sourceType, Class<T> targetClass).  While attempting to get the Transform object a call is made to DataTypeManager.getDataTypeName("org.postgresql.util.PGobject") which is responsible for returning a datatype name from the given string.  PGobject is not found in the map, so, the Teiid code defaults the return value to "object".  From there, a call is made to the DataTypeManager's getTransformFromMaps method passing in the values of {"object", "object"} which it does not find in the tranform map, so a null value is returned to the transformValue method which is then throwing an exception since there is no Transform object being returned.

       

      Currently, we work around this by adding a secondary column that stores the INET value as text within the Postgres database (which for obvious reasons is not ideal.)  Am I utilizing this incorrectly, or is this a bug?  Also, is Teiid looking into mapping INET columns to java.net.Inet4Address and java.netInet6Address objects at any point in the near future?

       

      Thanks for your time and I appreciate the work that you all have put into this project!

       

      Regards,

         Caleb

        • 1. Re: Issue retrieving INET column from PostgreSQL
          shawkins

          Caleb,

           

          You should be able to use the any value as the object type.  This issue was addressed with a fix under the https://issues.jboss.org/browse/TEIID-1011 JIRA.  See http://source.jboss.org/browse/Teiid/trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java#3094.  That fix is in 7.4 or later.

           

          With that fix, you can use those objects as they are returned from PG.  As for adding a native type for InetAddresses, that is something that could be requested through a JIRA.  I don't think we've had it come up before now.

           

          Steve

          • 2. Re: Issue retrieving INET column from PostgreSQL
            calebwc

            Steve,

               Thanks for your prompt response.  I will try to pull down the 7.4 baseline and try again.  Thanks again for your assistance.  Take care.

                 Regards,

                    Caleb

             

            P.S.  I'm sure I will have a lot more questions in the not so distant future as we start utilizing Teiid more.

            • 3. Re: Issue retrieving INET column from PostgreSQL
              calebwc

              Steve,

                 O.k., I've attempted to migrate from Teiid 7.3 to 7.4 to no avail thus far.  I've found a lot of the dependent jar files within the JBoss distribution under "deployers/teiid.deployer/" (such as the engine, core api, and runtime)  After removing all my 7.3 associations and replacing them with 7.4; creating a brand new JBoss 5.1.0 with a Teiid 7.4 overlay; and redeploying all the VDBs and their dependencies I get a NullPointerException thrown when in org.teiid.query.sql.navigator.DeepPreOrderNavigator's doVisit method.  where it tries to call acceptVisitor on a LanguageObject that is passed into the doVisit method.  Unfortunately, this object is null for one of the calls.  I haven't had a lot of time to fully debug this to see what mapping object is having issues (I will be spending a little time doing that now.)  The pertinent portion of the stacktrace is as follows:

               

              Caused by: java.lang.NullPointerException

                   at org.teiid.query.sql.navigator.DeepPreOrderNavigator.doVisit(DeepPreOrderNavigator.java:44)

                   at org.teiid.query.optimizer.xml.QueryUtil.markBindingsAsNonExternal(QueryUtil.java:175)

                   at org.teiid.query.optimizer.xml.SourceNodePlannerVisitor.visit(SourceNodePlannerVisitor.java:175)

                   ... 39 more

               

              The first part of the stacktrace doesn't seem useful: Unexpected exception for request <request id>  nullnull

              • 4. Re: Issue retrieving INET column from PostgreSQL
                calebwc

                Update...

                 

                Something weird must have been going on behind the scenes (JBoss, Teiid, not really sure.)  After deleting the view model and rebuilding it from the XSD, I was able to successfully run against Teiid 7.4 on a PostgreSQL INET column (converting it into a string.)  It seemed like the NPE (null pointer exception) was thrown when it encountered it's first convert statement, can't validate this, but, this is what it appeared to be when I debugged the Teiid server instance when the problem was still occurring.  Thanks for your assistance.

                    Caleb