[ 
https://issues.apache.org/jira/browse/TRAFODION-1581?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15049446#comment-15049446
 ] 

ASF GitHub Bot commented on TRAFODION-1581:
-------------------------------------------

Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/218#discussion_r47159004
  
    --- Diff: core/sql/optimizer/RelRoutine.cpp ---
    @@ -1081,33 +1085,37 @@ NARoutine * 
PredefinedTableMappingFunction::getRoutineMetadata(
          BindWA *bindWA)
     {
       NARoutine *result = NULL;
    +  ComRoutineLanguage lang = COM_LANGUAGE_CPP;
    +  ComRoutineParamStyle paramStyle = COM_STYLE_CPP_OBJ;
    +  const char *externalName = NULL;
    +  // By default, predefined UDRs share a DLL.
    +  const char *libraryFileName = "libudr_predef.so";
       NAString libraryPath;
     
       // the libraries for predefined UDRs are in the regular
       // library directory $MY_SQROOT/export/lib${SQ_MBTYPE}
       libraryPath += getenv("MY_SQROOT");
       libraryPath += "/export/lib";
    -  libraryPath += getenv("SQ_MBTYPE");
     
       switch (getOperatorType())
         {
         case REL_TABLE_MAPPING_BUILTIN_LOG_READER:
    +      externalName = "TRAF_CPP_EVENT_LOG_READER";
    +      libraryPath += getenv("SQ_MBTYPE");
    +      break;
    +
         case REL_TABLE_MAPPING_BUILTIN_TIMESERIES:
    -      {
    -        // produce a very simple NARoutine, most of the
    -        // error checking and determination of output
    -        // columns is done by the compiler interface of
    -        // this predefined table mapping function
    -        result = new(bindWA->wHeap()) NARoutine(routineName,
    -                                                bindWA->wHeap());
    -        if (getOperatorType() == REL_TABLE_MAPPING_BUILTIN_LOG_READER)
    -          result->setExternalName("TRAF_CPP_EVENT_LOG_READER");
    -        else
    -          result->setExternalName("TRAF_CPP_TIMESERIES");
    -        result->setLanguage(COM_LANGUAGE_CPP);
    -        result->setRoutineType(COM_TABLE_UDF_TYPE);
    -        result->setParamStyle(COM_STYLE_CPP_OBJ);
    -      }
    +      externalName = "TRAF_CPP_TIMESERIES";
    +      libraryPath += getenv("SQ_MBTYPE");
    +      break;
    +
    +    case REL_TABLE_MAPPING_BUILTIN_JDBC:
    +      lang = COM_LANGUAGE_JAVA;
    +      paramStyle = COM_STYLE_JAVA_OBJ;
    +      externalName = "org.trafodion.sql.udr.predef.JDBCUDR";
    +      libraryPath += "/trafodion-sql-";
    --- End diff --
    
    Yes, for C++ it's a Linux directory, $MY_SQROOT/export/lib${SQ_MBTYPE}. For 
Java it's a jar file, like $MY_SQROOT/export/lib/trafodion-sql-1.3.0.jar.


> Add a TMUDF that can return a JDBC result set as table-valued output
> --------------------------------------------------------------------
>
>                 Key: TRAFODION-1581
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-1581
>             Project: Apache Trafodion
>          Issue Type: Sub-task
>          Components: sql-general
>    Affects Versions: 1.3-incubating
>            Reporter: Hans Zeller
>            Assignee: Hans Zeller
>             Fix For: 2.0-incubating
>
>
> One way to read data from other data sources would be a Trafodion TMUDF that 
> takes a connection string, an SQL statement and other necessary info as an 
> input, connects to a JDBC data source, prepares the statement, and returns 
> the result set as a table-valued output. This would enable a basic connector 
> for many data sources, including Spark, Drill and Kafka.
> Specifically, I would like to add a "predefined" TMUDF to Trafodion that 
> takes the following parameters:
> 1. The name of a jar with a JDBC driver.
> 2. A connection string to use
> 3. The class name of the driver
> 4. A user id
> 5. A password
> 6. The type of processing to do (right now only one type is supported)
> 7. Info depending on the type.
> The first type of processing I would like to add is "source", and it does the 
> following: It accepts a list of SQL statements to execute. Only one of these 
> statements can return a result set. The data in the result set will be 
> returned as table-valued output.
> Future processing types could do a parallel select like ODB does or they 
> could insert into a table on the system identified by the JDBC driver info.
> All parameters need to be compile-time constants, so that the UDF can connect 
> to the data source at compile time and prepare the statement. Based on the 
> prepared statement, it will determine number, names and SQL types of the 
> column(s) of the table-valued result.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to