Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1496#discussion_r177136840
--- Diff: core/sql/sqludr/SqlUdrPredefSeries.cpp ---
@@ -0,0 +1,112 @@
+// @@@ 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 @@@
+
+#include "sqludr.h"
+
+using namespace tmudr;
+
+// sample invocation of the SERIES TMUDF:
+//
+// SELECT * FROM UDF(series(1, 100, 2));
+// SELECT * FROM UDF(series(100, 1, -2));
+// SELECT * FROM UDF(series(1, 100));
+
+/* Step 1: derive a class from tmudr::UDR*/
+
+class series : public UDR
+{
+public:
+ // determine output columns dynamically at compile time
+ void describeParamsAndColumns(UDRInvocationInfo &info);
+
+ // override the runtime method
+ virtual void processData(UDRInvocationInfo &info,
+ UDRPlanInfo &plan);
+};
+
+/* Step 2: Create a factory method*/
+
+extern "C" UDR * SERIES()
+{
+ return new series();
+}
+
+/* Step 3: Write the actual UDF code*/
+void series::describeParamsAndColumns(
+ UDRInvocationInfo &info)
+{
+ // We always expect one input parameter
+ int paramCount = info.par().getNumColumns();
+ if (paramCount != 2 && paramCount != 3)
+ throw UDRException(38001,
+ "Expecting two or three input parameters");
+
+ if (info.par().getType(0).getSQLTypeClass() !=
info.par().getType(1).getSQLTypeClass())
+ throw UDRException(38001,
+ "The data type of the first two parameters should
be same");
+
+ if (info.par().getType(0).getSQLTypeClass() != TypeInfo::NUMERIC_TYPE)
+ throw UDRException(38001,
+ "Only support to generate series for exact numerics
type");
--- End diff --
Slightly better English might be "Only exact numeric types are supported"
---