[TRAFODION-1581] TMUDF for JDBC queries
Other JIRAs fixed with this commit:
[TRAFODION-1582] Optional Drill install for local hadoop
This new built-in TMUDF takes arguments that describe a
JDBC connection and a list of SQL statements and returns
the result of the one SQL statement in the list that
produces results:
select ... from udf(JDBC(
<name of JDBC driver jar>,
<name of JDBC driver class in the jar>,
<connection string>,
<user name>,
<password>,
<statement_type>,
<sql statement 1>
[ , <sql statements 2 ...n> ] )) ...
The first 7 arguments are required and must be
string literals that are available at compile
time.
Statement type:
'source': This statement produces a result
(only type allowed at this time)
(may support "target" to insert
into a table via JDBC later)
Note that only one of the SQL statements can be
a select or other result-producing statements.
The others can perform setup and cleanup
operations, if necessary (e.g. create table,
insert, select, drop table).
For an example, see file
core/sql/regress/udr/TEST002.
Note that this UDF is still a prototype, it needs more
testing.
Other small fixes:
- install_local_hadoop now picks ports in the non-ephemeral
range when doing install_local_hadoop -p fromDisplay.
Port number range starts at 24000 + 200*display number.
Stay below 42 for your display to avoid the ephemeral range
and pick a different display # if you run into port conflicts.
- Setupdir step (this includes building libhdfs, if needed)
now logs its output with a suffix ##(setupdir) like most
other components
core/Makefile
- Fixed a bug causing a core when a TMUDF produced no
output columns and another bug with a VARCHAR parameter
at the beginning of a parameter list.
core/optimizer/UdfDllInteraction.cpp
- Fixed a bug in parsing two consecutive patterns in sqlci
input, like $$a$$$$b$$
core/sqlci/SqlCmd.cpp
- Small fixes to doxygen documentation: With the new web
page structure, make doxygen version match the Trafodion
version (at least the initial release that applies), also
fix links to wiki to point to the Apache wiki.
core/sql/sqludr/doxygen_tmudr.1.6.config
core/sql/sqludr/sqludr.cpp
core/sql/sqludr/sqludr.h
- Make hive-exec dependency for SQL explicit (would sometimes
produce an error depending on the sequence in which things
are built)
core/sql/pom.xml
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit:
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/a3477192
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/a3477192
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/a3477192
Branch: refs/heads/master
Commit: a34771927c1afd3348fb4609b4c2944f5c47507a
Parents: 849de1a
Author: Hans Zeller <[email protected]>
Authored: Wed Dec 9 17:17:25 2015 +0000
Committer: Hans Zeller <[email protected]>
Committed: Wed Dec 9 17:31:11 2015 +0000
----------------------------------------------------------------------
core/Makefile | 4 +-
core/sqf/sql/scripts/install_local_drill | 114 +++
core/sqf/sql/scripts/install_local_hadoop | 41 +-
core/sql/bin/SqlciErrors.txt | 1 +
core/sql/common/ExprNode.cpp | 1 +
core/sql/common/OperTypeEnum.h | 1 +
core/sql/optimizer/RelRoutine.cpp | 55 +-
core/sql/optimizer/UdfDllInteraction.cpp | 10 +-
core/sql/pom.xml | 5 +
core/sql/regress/tools/runregr_udr.ksh | 7 +
core/sql/regress/udr/EXPECTED002 | 48 +-
core/sql/regress/udr/TEST002 | 18 +
core/sql/sqlci/SqlCmd.cpp | 1 +
core/sql/sqludr/doxygen_tmudr.1.6.config | 4 +-
core/sql/sqludr/sqludr.cpp | 2 +-
core/sql/sqludr/sqludr.h | 16 +-
.../trafodion/sql/udr/UDRInvocationInfo.java | 17 +-
.../org/trafodion/sql/udr/predef/JDBCUDR.java | 690 +++++++++++++++++++
18 files changed, 972 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/Makefile
----------------------------------------------------------------------
diff --git a/core/Makefile b/core/Makefile
index ab62c49..b947b1a 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -101,7 +101,7 @@ cleantests:
cd ../dcs/src/test/pytests && $(RM) -r odbc* tox.ini config.ini .tox
.testrep* env.sh test_p2.pyc
cd ../dcs/src/test/jdbc_test && $(RM) -r jdbcprop pom.xml target
cd ../tests/phx && $(RM) -r jdbcprop *.log pom.xml target
-
+
clean: sqroot
cd $(MPI_TARGET) && $(MAKE) clean-local
cd $(SEAMONSTER_TARGET)/src && $(MAKE) clean
@@ -158,7 +158,7 @@ version:
# create links and files needed as prerequisite for the build
sqroot:
./bldenvchk.sh;
- cd sqf && $(MAKE) setupdir
+ cd sqf && $(MAKE) setupdir 2>&1 | sed -e "s/$$/ ##(setupdir)/";exit
$${PIPESTATUS[0]}
# Check for absolute filenames used as dynamic linked libraries
find-absolute-dlls:
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sqf/sql/scripts/install_local_drill
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/install_local_drill
b/core/sqf/sql/scripts/install_local_drill
new file mode 100755
index 0000000..bc2b3ca
--- /dev/null
+++ b/core/sqf/sql/scripts/install_local_drill
@@ -0,0 +1,114 @@
+#!/bin/sh
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+#
+##############################################################################
+##
+## Install a sand-boxed version of Apache Drill, to be used together
+## with the setup created in install_local_hadoop.
+## This will share the zookeeper instance with HBase and it will
+## use custom ports determined by install_local_hadoop.
+##
+##############################################################################
+
+# location of local Hadoop components, we will add Drill here
+MY_SW_ROOT=$MY_SQROOT/sql/local_hadoop
+
+# Download info for Drill
+DRILL_VERSION=1.2.0
+DRILL_MIRROR_URL=http://archive.apache.org/dist/drill/drill-${DRILL_VERSION}
+DRILL_ID=apache-drill-${DRILL_VERSION}
+DRILL_TAR=${DRILL_ID}.tar.gz
+
+if [[ -d ${MY_SW_ROOT}/${DRILL_TAR} ]]; then
+ echo "Drill is already downloaded to ${MY_SW_ROOT}/${DRILL_TAR}, exiting..."
+ exit 0
+fi
+
+if [[ ! -d "$MY_SW_ROOT" ]]; then
+ echo "Could not find directory $MY_SW_ROOT"
+ exit 1
+fi
+
+cd $MY_SW_ROOT
+
+if [ -f $MY_LOCAL_SW_DIST/${DRILL_TAR} ]; then
+ cp $MY_LOCAL_SW_DIST/${DRILL_TAR} .
+ echo "Copied Drill tar file from: $MY_LOCAL_SW_DIST/${DRILL_TAR}"
+else
+ wget ${DRILL_MIRROR_URL}/${DRILL_TAR}
+ echo "Downloaded Drill tar file: ${DRILL_MIRROR_URL}/${DRILL_TAR}"
+fi
+
+if [[ ! -f $DRILL_TAR ]]; then
+ echo "Unable to download Drill tar file ${DRILL_MIRROR_URL}/${DRILL_TAR}"
+ exit 1
+fi
+
+tar -xzf ${DRILL_TAR}
+ln -s ${DRILL_ID} drill
+
+cat <<EOF >${MY_SQROOT}/sql/scripts/swdrill
+#!/bin/sh
+$MY_SW_ROOT/drill/bin/drill-conf "\$@"
+EOF
+
+cat <<EOF >${MY_SQROOT}/sql/scripts/swstartdrill
+#!/bin/sh
+${MY_SW_ROOT}/drill/bin/drillbit.sh --config $MY_SW_ROOT/drill/conf start
+EOF
+
+cat <<EOF >${MY_SQROOT}/sql/scripts/swstopdrill
+#!/bin/sh
+${MY_SW_ROOT}/drill/bin/drillbit.sh --config $MY_SW_ROOT/drill/conf stop
+EOF
+
+chmod +x ${MY_SQROOT}/sql/scripts/sw*drill
+
+# pick up environment variables with the relevant port numbers
+. ${MY_SQROOT}/sql/scripts/sw_env.sh
+
+# customize the embedded Drill configuration to use custom
+# port numbers and files local to ${MY_SW_ROOT}
+cd $MY_SW_ROOT/drill/conf
+mv drill-override.conf drill-override.conf.orig
+cat <<EOF >drill-override.conf
+drill.exec: {
+ cluster-id: "local_hadoop_drill",
+ zk.connect: "localhost:${MY_HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT_NUM}",
+ sys.store.provider.local.path: "${MY_SW_ROOT}/data/drill",
+ sys.store.provider.zk.blobroot: "file://${MY_SW_ROOT}/data/drill/blobroot",
+ tmp.directories: "${MY_SW_ROOT}/data/drill/tmp",
+ trace.directory: "${MY_SW_ROOT}/data/drill/log",
+ http.port: "${MY_DRILL_INFO_PORT_NUM}",
+ rpc.user.server.port: "${MY_DRILL_RPC_PORT_NUM}",
+ rpc.bit.server.port: "${MY_DRILL_BIT_PORT_NUM}"
+}
+EOF
+
+# copy the Drill JDBC driver into the external_libs folder for UDRs
+mkdir -p ${MY_SQROOT}/udr/external_libs
+cp ${MY_SW_ROOT}/drill/jars/jdbc-driver/drill-jdbc-all-${DRILL_VERSION}.jar
${MY_SQROOT}/udr/external_libs
+
+echo "Installed a local copy of Drill. Start a drillbit with the"
+echo "swstartdrill command, connect with swdrill."
+
+exit 0
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sqf/sql/scripts/install_local_hadoop
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/install_local_hadoop
b/core/sqf/sql/scripts/install_local_hadoop
index 97d9976..951f417 100755
--- a/core/sqf/sql/scripts/install_local_hadoop
+++ b/core/sqf/sql/scripts/install_local_hadoop
@@ -385,10 +385,13 @@ else
# display :34.0 would result in starting port 53400 (instead of default
50000 range)
MY_START_PORT=${DISPLAY/*:/}
MY_START_PORT=${MY_START_PORT/.*/}
- MY_START_PORT=`expr 50000 + $MY_START_PORT '*' 100`
+ # Pick a port range starting at 24000 + 200 * display number.
+ # Choose a display number of up to 42 to stay below the
+ # ephemeral port range which typically starts at 32768.
+ MY_START_PORT=`expr 24000 + $MY_START_PORT '*' 200`
elif [ $MY_START_PORT == "rand" ]; then
- # pick a random number between 9000 and 49000 that is divisible by 200
- MY_START_PORT=`expr $RANDOM '%' 200 '*' 200 + 9000`
+ # pick a random number between 12000 and 24000 that is divisible by 200
+ MY_START_PORT=`expr $RANDOM '%' 50 '*' 200 + 12000`
fi
echo "# Using non-standard port range from MY_START_PORT env var:
$MY_START_PORT..."
fi
@@ -445,6 +448,12 @@ if [ $USE_DEFAULT_PORTS == 'yes' ]; then
MY_DB_MGR_PORT=4205
# database.mgr.secure.port
MY_DB_MGR_SECURE_PORT=4206
+ # drill.exec.http.port
+ MY_DRILL_INFO_PORT_NUM=8047
+ # drill.exec.rpc.user.server.port
+ MY_DRILL_RPC_PORT_NUM=31010
+ # drill.exec.rpc.bit.server.port
+ MY_DRILL_BIT_PORT_NUM=31011
else
# fs.default.name
MY_HADOOP_HDFS_PORT_NUM=$MY_START_PORT
@@ -475,6 +484,11 @@ else
MY_REST_SERVER_SECURE_PORT=`expr $MY_START_PORT + 194`
MY_DB_MGR_PORT=`expr $MY_START_PORT + 195`
MY_DB_MGR_SECURE_PORT=`expr $MY_START_PORT + 196`
+
+ # Apache Drill, embedded configuration
+ MY_DRILL_INFO_PORT_NUM=`expr $MY_START_PORT + 147`
+ MY_DRILL_RPC_PORT_NUM=`expr $MY_START_PORT + 148`
+ MY_DRILL_BIT_PORT_NUM=`expr $MY_START_PORT + 149`
fi
# handle ports in the range of 50000 to 50199
@@ -695,6 +709,9 @@ export MY_REST_SERVER_PORT=${MY_REST_SERVER_PORT}
export MY_REST_SERVER_SECURE_PORT=${MY_REST_SERVER_SECURE_PORT}
export MY_DB_MGR_PORT=${MY_DB_MGR_PORT}
export MY_DB_MGR_SECURE_PORT=${MY_DB_MGR_SECURE_PORT}
+export MY_DRILL_INFO_PORT_NUM=${MY_DRILL_INFO_PORT_NUM}
+export MY_DRILL_RPC_PORT_NUM=${MY_DRILL_RPC_PORT_NUM}
+export MY_DRILL_BIT_PORT_NUM=${MY_DRILL_BIT_PORT_NUM}
EOF
# now source in this script
@@ -796,7 +813,7 @@ EOF
# command to run hadoop
. $MY_SW_SCRIPTS_DIR/sw_env.sh
-${MY_SW_ROOT}/hadoop/bin/hadoop \$*
+${MY_SW_ROOT}/hadoop/bin/hadoop "\$@"
EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/swyarn
@@ -804,7 +821,7 @@ EOF
# command to run yarn
. $MY_SW_SCRIPTS_DIR/sw_env.sh
-${MY_SW_ROOT}/hadoop/bin/yarn \$*
+${MY_SW_ROOT}/hadoop/bin/yarn "\$@"
EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/swhdfs
@@ -812,7 +829,7 @@ EOF
# command to run hadoop
. $MY_SW_SCRIPTS_DIR/sw_env.sh
-${MY_SW_ROOT}/hadoop/bin/hdfs \$*
+${MY_SW_ROOT}/hadoop/bin/hdfs "\$@"
EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/swmysql
@@ -820,7 +837,7 @@ EOF
# command to run mysql
. $MY_SW_SCRIPTS_DIR/sw_env.sh
-${MY_SW_ROOT}/mysql/bin/mysql --defaults-file=${MY_SQL_CONFIG_FILE}
--user=${MY_SQL_USER} --password=${MY_SQL_USER_PASSWD}
--database=${MY_SQL_METASTORE_DB} \$*
+${MY_SW_ROOT}/mysql/bin/mysql --defaults-file=${MY_SQL_CONFIG_FILE}
--user=${MY_SQL_USER} --password=${MY_SQL_USER_PASSWD}
--database=${MY_SQL_METASTORE_DB} "\$@"
EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/swmysqladmin
@@ -828,7 +845,7 @@ EOF
# command to run mysqladmin as root user
. $MY_SW_SCRIPTS_DIR/sw_env.sh
-${MY_SW_ROOT}/mysql/bin/mysqladmin --defaults-file=${MY_SQL_CONFIG_FILE}
--user=${MY_SQL_ADMIN} --password=${MY_SQL_ADMIN_PASSWD} \$*
+${MY_SW_ROOT}/mysql/bin/mysqladmin --defaults-file=${MY_SQL_CONFIG_FILE}
--user=${MY_SQL_ADMIN} --password=${MY_SQL_ADMIN_PASSWD} "\$@"
EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/swhive
@@ -838,7 +855,7 @@ EOF
# Pick up MySQL JDBC driver
. $MY_SW_SCRIPTS_DIR/sw_env.sh
export HADOOP_HOME=${MY_SW_ROOT}/hadoop
-${MY_SW_ROOT}/hive/bin/hive \$*
+${MY_SW_ROOT}/hive/bin/hive "\$@"
EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/swhbase
@@ -846,7 +863,7 @@ EOF
# command to run hbase shell
. $MY_SW_SCRIPTS_DIR/sw_env.sh
-${MY_SW_ROOT}/hbase/bin/hbase shell \$*
+${MY_SW_ROOT}/hbase/bin/hbase shell "\$@"
EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/swuninstall_local_hadoop
@@ -882,6 +899,7 @@ EOF
<a href="http://${MY_HOST_1}:${MY_YARN_HTTP_PORT_NUM}">Yarn</a>
<a href="http://${MY_HOST_1}:${MY_HBASE_MASTER_INFO_PORT_NUM}">HBase Master</a>
<a href="http://${MY_HOST_1}:${MY_DCS_MASTER_INFO_PORT}">DCS Master</a>
+<a href="http://${MY_HOST_1}:${MY_DRILL_INFO_PORT_NUM}">Drill Web Console
(while shell is running)</a>
</pre>
</BODY>
</HTML>
@@ -1251,6 +1269,9 @@ else
echo "Unpacking MySQL JDBC tar file ${MYSQL_JDBC_TAR} ..."
tar -xf ${MYSQL_JDBC_TAR}
ln -s `dirname mysql-connector-java-*/mysql-connector-java-*.jar`
mysql-connector-java
+ # copy the MySQL JDBC driver to the udr directory, so UDRs can use it
+ mkdir -p ${MY_SQROOT}/udr/external_libs
+ cp ${MY_SW_ROOT}/mysql-connector-java/mysql-connector-java*.jar
${MY_SQROOT}/udr/external_libs
fi
# end of MySQL JDBC setup
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index f012c2e..de0959f 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -2033,6 +2033,7 @@ drop the default context
11152 ZZZZZ 99999 BEGINNER MINOR LOGONLY Unable to convert TypeInfo $0~int0
for column or parameter number $1~int1 from UDF compiler interface into an SQL
internal type. Details: $2~string0.
11153 ZZZZZ 99999 BEGINNER MINOR LOGONLY Unable to produce a query plan. This
could be related to a TMUDF that failed to negotiate a query plan with the
optimizer. One possible reason: $0~string0.
11154 ZZZZZ 99999 BEGINNER MINOR LOGONLY Ordinal number $0~int0 used in
$1~string0 clause of a UDF must be an integer ranging from 1 to the number of
columns ($2~int1 in this case).
+11155 ZZZZZ 99999 BEGINNER MINOR LOGONLY A TMUDF must produce at least one
output column.
11200 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU -----First Language Manager Error
-----
11201 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Language Manager initialization
failed. Details: Errors occurred while loading Java class $0~String0.
11202 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Language Manager initialization
failed. Details: Unable to initialize the Java virtual machine. $0~string0
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sql/common/ExprNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/ExprNode.cpp b/core/sql/common/ExprNode.cpp
index fce46c9..7c96759 100644
--- a/core/sql/common/ExprNode.cpp
+++ b/core/sql/common/ExprNode.cpp
@@ -685,6 +685,7 @@ NABoolean OperatorType::match(OperatorTypeEnum wildcard)
const
case REL_TABLE_MAPPING_UDF:
case REL_TABLE_MAPPING_BUILTIN_LOG_READER:
case REL_TABLE_MAPPING_BUILTIN_TIMESERIES:
+ case REL_TABLE_MAPPING_BUILTIN_JDBC:
return TRUE;
default:
return FALSE;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index 6e5d2ae..12cc0cf 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -92,6 +92,7 @@ enum OperatorTypeEnum {
REL_TABLE_MAPPING_UDF,
REL_TABLE_MAPPING_BUILTIN_LOG_READER,
REL_TABLE_MAPPING_BUILTIN_TIMESERIES,
+ REL_TABLE_MAPPING_BUILTIN_JDBC,
REL_ANY_TABLE_MAPPING_UDF,
REL_ISOLATED_NON_TABLE_UDR,
REL_ISOLATED_SCALAR_UDF,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sql/optimizer/RelRoutine.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelRoutine.cpp
b/core/sql/optimizer/RelRoutine.cpp
index f430e79..b7a0385 100644
--- a/core/sql/optimizer/RelRoutine.cpp
+++ b/core/sql/optimizer/RelRoutine.cpp
@@ -1032,6 +1032,8 @@ OperatorTypeEnum
PredefinedTableMappingFunction::nameIsAPredefinedTMF(const Corr
return REL_TABLE_MAPPING_BUILTIN_LOG_READER;
else if (funcName == "TIMESERIES")
return REL_TABLE_MAPPING_BUILTIN_TIMESERIES;
+ else if (funcName == "JDBC")
+ return REL_TABLE_MAPPING_BUILTIN_JDBC;
else
// none of the built-in names matched, so it must be a UDF
return REL_TABLE_MAPPING_UDF;
@@ -1045,6 +1047,8 @@ const NAString PredefinedTableMappingFunction::getText()
const
return "event_log_reader";
case REL_TABLE_MAPPING_BUILTIN_TIMESERIES:
return "timeseries";
+ case REL_TABLE_MAPPING_BUILTIN_JDBC:
+ return "jdbc_udf";
default:
CMPASSERT(0);
@@ -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-";
+ libraryPath += getenv("TRAFODION_VER");
+ libraryPath += ".jar";
break;
default:
@@ -1118,9 +1126,18 @@ NARoutine *
PredefinedTableMappingFunction::getRoutineMetadata(
return NULL;
}
- // by default, predefined UDRs share a DLL
-
- result->setFile("libudr_predef.so");
+ // 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());
+ result->setExternalName(externalName);
+ result->setLanguage(lang);
+ result->setRoutineType(COM_TABLE_UDF_TYPE);
+ result->setParamStyle(paramStyle);
+ result->setFile(libraryFileName);
result->setExternalPath(libraryPath);
return result;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sql/optimizer/UdfDllInteraction.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/UdfDllInteraction.cpp
b/core/sql/optimizer/UdfDllInteraction.cpp
index edeebe3..939c3ce 100644
--- a/core/sql/optimizer/UdfDllInteraction.cpp
+++ b/core/sql/optimizer/UdfDllInteraction.cpp
@@ -205,6 +205,12 @@ NABoolean TMUDFDllInteraction::describeParamsAndMaxOutputs(
bindWA->setErrStatus();
return FALSE;
}
+ if (outColArray->entries() == 0)
+ {
+ *(CmpCommon::diags()) << DgSqlCode(-11155);
+ bindWA->setErrStatus();
+ return FALSE;
+ }
tmudfNode->setOutputParams(outColArray);
@@ -1037,8 +1043,8 @@ tmudr::UDRInvocationInfo
*TMUDFInternalSetup::createInvocationInfoFromRelExpr(
constVal->getOffsetsInBuffer(nullIndOffset, vcLenOffset, dataOffset);
result->nonConstActualParameters().getColumn(i).getType().setOffsets(
- (nullIndOffset > 0 ? nextOffset + nullIndOffset : -1),
- (vcLenOffset > 0 ? nextOffset + vcLenOffset : -1),
+ (nullIndOffset >= 0 ? nextOffset + nullIndOffset : -1),
+ (vcLenOffset >= 0 ? nextOffset + vcLenOffset : -1),
nextOffset + dataOffset);
nextOffset += totalSize;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sql/pom.xml
----------------------------------------------------------------------
diff --git a/core/sql/pom.xml b/core/sql/pom.xml
index 579a3ab..50616e4 100755
--- a/core/sql/pom.xml
+++ b/core/sql/pom.xml
@@ -64,6 +64,11 @@
<version>${hive.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-exec</artifactId>
+ <version>${hive.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>${thrift.version}</version>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a3477192/core/sql/regress/tools/runregr_udr.ksh
----------------------------------------------------------------------
diff --git a/core/sql/regress/tools/runregr_udr.ksh
b/core/sql/regress/tools/runregr_udr.ksh
index e2c1a47..5852c15 100755
--- a/core/sql/regress/tools/runregr_udr.ksh
+++ b/core/sql/regress/tools/runregr_udr.ksh
@@ -850,6 +850,13 @@ if [ $LINUX -ne 0 ]; then
export CLASSPATH=$MY_SQROOT/export/lib/hpt4jdbc.jar:$CLASSPATH:.
fi
+export JDBC_T4_URL="jdbc:t4jdbc://localhost:23400/:"
+if [ -r $MY_SQROOT/sql/scripts/swenv.sh ]; then
+ # use a custom port for the JDBC Type 4 driver
+ . $MY_SQROOT/sql/scripts/swenv.sh
+ export JDBC_T4_URL="jdbc:t4jdbc://localhost:${MY_DCS_MASTER_PORT}/:"
+fi
+
# if the regressions are running on NSK, start the ODBC server if
# we are not running diffs_only
if [ $USE_NDCS -ne 0 -a $DIFFS_ONLY -eq 0 -a $SEABASE_REGRESS -eq 0 ]; then