4 Replies Latest reply on May 15, 2013 8:37 AM by jamit

    How to access ResultSetMetadata in the delegate translator?

    jamit

      Hi Ramesh and Team,

       

      I am using Teiid 8.3 Final, and implementing a delegate translator by extending the BaseDelegatingExecutionFactory.

      Also there a class in my code which implements the ResultSetExecution,and I override the execute() and the next() method.

      Control Flow is like this : MyDelegateQueryExecution delgates/intercepts calls to (JDBCQueryExecution or MyQueryExecution ) depending on the translator used underneath .

       

      Now I need to do some changes to the values in the resultset, in the next() method,before its returned from the next() of delegating translator.

      The next method returns a List<?> , in my case objects(which have values from the resultset)...But I see no api from where I can get the resultset or its metadata to map the values to the column names.

      The resultset or the ResultSetMetadata is inaccessible beacuse the JDBCQueryExecution has resultset as protected and has no public api.

       

      1) Is there a way to get ResultSetMetadata  in the delegating translator?

       

      2) Can we have an api published in the ResultSetExecution like getResultsetMetadata which each translator's QueryExecution class would implement?

           I suppose that would be an enhancement to be made on the Teiid side and published out as a patch in Teiid8.3.

       

      Other than 1 and 2

      the "time being" approach that I plan to do this mapping is to:

      a) get the projectedquery from the command.

      b) Get the column name if its only one (Say Select Name from Employee) or list of columns from RuntimeMetadata in case(Select * from Employees) and map the columnName to Value list returned by the next() method of the actual translator class (Say JDBCQueryExecution).

       

      Thanks

      Amit

        • 1. Re: How to access ResultSetMetadata in the delegate translator?
          shawkins

          Amit,

           

          1) Generally this doesn't sound like something you would want to use delegation for.  Getting at a translator specific implementation detail doesn't seem appropriate for a delegation pattern.

          2) Do you mean the JDBC ResultSetMetaData or just want is expected to be projected by the source command?  The latter can just be obtained from QueryExpression.getProjectedQuery().getDerivedColumns and the associated types/metadata.

           

          Steve

          • 2. Re: How to access ResultSetMetadata in the delegate translator?
            jamit

            Thanks Steven,

             

            2) Yes I meant JDBC ResultSetMetaData in case of JDBCQueryExecution and customResultSetMetadata in case of CustomQueryExecution.

            So that would mean to provide an api say getResultSetMetadata() in the ResultSetExecution interface which each translator would override to provide the metadata of their resultset.

            • 3. Re: How to access ResultSetMetadata in the delegate translator?
              shawkins

              Just to be clear from the perspective of Teiid, the source command itself conveys the result metadata (types, column names, additional metadata through the metadata objects, etc.).  To specifically need the JDBC ResultSetMetaData seems like something you'd need to address with a JDBC translator extension and not something that we would modify the api for to address with a delegation pattern.

               

              Steve

              • 4. Re: How to access ResultSetMetadata in the delegate translator?
                jamit

                Thanks a lot Steve.

                The implementation has just started becomming clearer to me after using the getProjectedQuery().getDerivedColumns.:)