Index: ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (revision 189586) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (working copy) @@ -68,6 +68,7 @@ registerUDF("trim", UDFTrim.class, OperatorType.PREFIX, false); registerUDF("ltrim", UDFLTrim.class, OperatorType.PREFIX, false); registerUDF("rtrim", UDFRTrim.class, OperatorType.PREFIX, false); + registerUDF("concat_ws", UDFConcatWS.class, OperatorType.PREFIX, false); registerUDF("like", UDFLike.class, OperatorType.INFIX, true); registerUDF("rlike", UDFRegExp.class, OperatorType.INFIX, true); Index: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFConcatWS.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFConcatWS.java (revision 0) +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFConcatWS.java (revision 0) @@ -0,0 +1,50 @@ +/** + * 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. + */ + +package org.apache.hadoop.hive.ql.udf; + +import org.apache.hadoop.hive.ql.exec.UDF; + + +public class UDFConcatWS implements UDF { + + public UDFConcatWS() { + } + + public String evaluate(String sep, String... strs) { + if (sep == null) { + return sep; + } + String result = ""; + boolean first = true; + for (String str : strs) { + if (first) { + first = false; + } else { + if (str != null) { + result += ","; + } + } + if (str != null) { + result += str; + } + } + return result; + } + +} Property changes on: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFConcatWS.java ___________________________________________________________________ Added: svn:executable + *