diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index 0f05160..818ff29 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -473,7 +473,6 @@ system.registerGenericUDF("unix_timestamp", GenericUDFUnixTimeStamp.class); system.registerGenericUDF("to_unix_timestamp", GenericUDFToUnixTimeStamp.class); - system.registerGenericUDF("internal_interval", GenericUDFInternalInterval.class); // Generic UDTF's system.registerGenericUDTF("explode", GenericUDTFExplode.class); system.registerGenericUDTF("replicate_rows", GenericUDTFReplicateRows.class); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g index 43fd69e..a002720 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g @@ -76,14 +76,14 @@ rollupOldSyntax @init { gParent.pushMsg("rollup old syntax", state); } @after { gParent.popMsg(state); } : - expressionsNotInParenthese + expr=expressionsNotInParenthese[false] ((rollup=KW_WITH KW_ROLLUP) | (cube=KW_WITH KW_CUBE)) ? (sets=KW_GROUPING KW_SETS LPAREN groupingSetExpression ( COMMA groupingSetExpression)* RPAREN ) ? - -> {rollup != null}? ^(TOK_ROLLUP_GROUPBY expressionsNotInParenthese) - -> {cube != null}? ^(TOK_CUBE_GROUPBY expressionsNotInParenthese) - -> {sets != null}? ^(TOK_GROUPING_SETS expressionsNotInParenthese groupingSetExpression+) - -> ^(TOK_GROUPBY expressionsNotInParenthese) + -> {rollup != null}? ^(TOK_ROLLUP_GROUPBY {$expr.tree}) + -> {cube != null}? ^(TOK_CUBE_GROUPBY {$expr.tree}) + -> {sets != null}? ^(TOK_GROUPING_SETS {$expr.tree} groupingSetExpression+) + -> ^(TOK_GROUPBY {$expr.tree}) ; @@ -127,21 +127,31 @@ havingCondition expression ; -expressionsInParenthese +expressionsInParenthese[boolean isStruct] : - LPAREN! expressionsNotInParenthese RPAREN! + LPAREN! expressionsNotInParenthese[isStruct] RPAREN! ; -expressionsNotInParenthese +expressionsNotInParenthese[boolean isStruct] : - expression (COMMA expression)* -> expression+ + first=expression more=expressionPart[$expression.tree, isStruct]? + -> {more==null}? + {$first.tree} + -> {$more.tree} + ; + +expressionPart[CommonTree t, boolean isStruct] + : + (COMMA expression)+ + -> {isStruct}? ^(TOK_FUNCTION Identifier["struct"] {$t} expression+) + -> {$t} expression+ ; expressions : - (expressionsInParenthese) => expressionsInParenthese + (expressionsInParenthese[false]) => expressionsInParenthese[false] | - expressionsNotInParenthese + expressionsNotInParenthese[false] ; columnRefOrderInParenthese @@ -303,7 +313,9 @@ timeQualifiers constant @init { gParent.pushMsg("constant", state); } @after { gParent.popMsg(state); } - : Number + : + (intervalLiteral) => intervalLiteral + | Number | dateLiteral | timestampLiteral | StringLiteral @@ -349,13 +361,17 @@ timestampLiteral KW_CURRENT_TIMESTAMP -> ^(TOK_FUNCTION KW_CURRENT_TIMESTAMP) ; -intervalExpression +intervalValue : - KW_INTERVAL? k1=(StringLiteral|Number) q1=intervalQualifiers -> - ^(TOK_FUNCTION Identifier["internal_interval"] NumberLiteral[Integer.toString(((CommonTree)q1.getTree()).token.getType())] $k1) - | - KW_INTERVAL? LPAREN k2=expression RPAREN q2=intervalQualifiers -> - ^(TOK_FUNCTION Identifier["internal_interval"] NumberLiteral[Integer.toString(((CommonTree)q2.getTree()).token.getType())] $k2) + StringLiteral | Number + ; + +intervalLiteral + : + KW_INTERVAL? intervalValue qualifiers=intervalQualifiers -> + { + adaptor.create(((CommonTree)qualifiers.getTree()).getType(), $intervalValue.text) + } ; intervalQualifiers @@ -379,8 +395,7 @@ expression atomExpression : - (intervalExpression)=>intervalExpression - | (constant) => constant + (constant) => constant | castExpression | extractExpression | floorExpression @@ -390,7 +405,7 @@ atomExpression -> ^(TOK_SUBQUERY_EXPR TOK_SUBQUERY_OP subQueryExpression) | (function) => function | tableOrColumn - | LPAREN! expression RPAREN! + | expressionsInParenthese[true] ; precedenceFieldExpression @@ -490,15 +505,14 @@ precedenceBitwiseOrExpression ; -// Equal operators supporting NOT prefix -precedenceEqualNegatableOperator +precedenceRegexpOperator : KW_LIKE | KW_RLIKE | KW_REGEXP ; -precedenceEqualOperator +precedenceSimilarOperator : - precedenceEqualNegatableOperator | EQUAL | EQUAL_NS | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN + precedenceRegexpOperator | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN ; subQueryExpression @@ -506,53 +520,64 @@ subQueryExpression LPAREN! selectStatement RPAREN! ; -precedenceEqualExpression +precedenceSimilarExpression : - (precedenceEqualExpressionSingle) => precedenceEqualExpressionSingle + precedenceSimilarExpressionMain + | + KW_EXISTS subQueryExpression -> ^(TOK_SUBQUERY_EXPR ^(TOK_SUBQUERY_OP KW_EXISTS) subQueryExpression) + ; + +precedenceSimilarExpressionMain + : + a=precedenceBitwiseOrExpression part=precedenceSimilarExpressionPart[$precedenceBitwiseOrExpression.tree]? + -> {part == null}? {$a.tree} + -> {$part.tree} + ; + +precedenceSimilarExpressionPart[CommonTree t] + : + (precedenceSimilarOperator equalExpr=precedenceBitwiseOrExpression) + -> ^(precedenceSimilarOperator {$t} $equalExpr) | - precedenceEqualExpressionMutiple + precedenceSimilarExpressionAtom[$t] + | + (KW_NOT^ precedenceSimilarExpressionPartNot[$t]) ; - -precedenceEqualExpressionSingle + +precedenceSimilarExpressionAtom[CommonTree t] : - (left=precedenceBitwiseOrExpression -> $left) - ( - (KW_NOT precedenceEqualNegatableOperator notExpr=precedenceBitwiseOrExpression) - -> ^(KW_NOT ^(precedenceEqualNegatableOperator $precedenceEqualExpressionSingle $notExpr)) - | (precedenceEqualOperator equalExpr=precedenceBitwiseOrExpression) - -> ^(precedenceEqualOperator $precedenceEqualExpressionSingle $equalExpr) - | (KW_NOT KW_IN LPAREN KW_SELECT)=> (KW_NOT KW_IN subQueryExpression) - -> ^(KW_NOT ^(TOK_SUBQUERY_EXPR ^(TOK_SUBQUERY_OP KW_IN) subQueryExpression $precedenceEqualExpressionSingle)) - | (KW_NOT KW_IN expressionsInParenthese) - -> ^(KW_NOT ^(TOK_FUNCTION KW_IN $precedenceEqualExpressionSingle expressionsInParenthese)) - | (KW_IN LPAREN KW_SELECT)=> (KW_IN subQueryExpression) - -> ^(TOK_SUBQUERY_EXPR ^(TOK_SUBQUERY_OP KW_IN) subQueryExpression $precedenceEqualExpressionSingle) - | (KW_IN expressionsInParenthese) - -> ^(TOK_FUNCTION KW_IN $precedenceEqualExpressionSingle expressionsInParenthese) - | ( KW_NOT KW_BETWEEN (min=precedenceBitwiseOrExpression) KW_AND (max=precedenceBitwiseOrExpression) ) - -> ^(TOK_FUNCTION Identifier["between"] KW_TRUE $precedenceEqualExpressionSingle $min $max) - | ( KW_BETWEEN (min=precedenceBitwiseOrExpression) KW_AND (max=precedenceBitwiseOrExpression) ) - -> ^(TOK_FUNCTION Identifier["between"] KW_FALSE $precedenceEqualExpressionSingle $min $max) - )* - | KW_EXISTS subQueryExpression -> ^(TOK_SUBQUERY_EXPR ^(TOK_SUBQUERY_OP KW_EXISTS) subQueryExpression) + KW_IN! precedenceSimilarExpressionIn[$t] + | + KW_BETWEEN (min=precedenceBitwiseOrExpression) KW_AND (max=precedenceBitwiseOrExpression) + -> ^(TOK_FUNCTION Identifier["between"] KW_FALSE {$t} $min $max) ; +precedenceSimilarExpressionIn[CommonTree t] + : + (subQueryExpression) => subQueryExpression -> ^(TOK_SUBQUERY_EXPR ^(TOK_SUBQUERY_OP KW_IN) subQueryExpression {$t}) + | + expr=expressionsInParenthese[false] + -> ^(TOK_FUNCTION Identifier["in"] {$t} {$expr.tree}) + ; -//we transform the (col0, col1) in ((v00,v01),(v10,v11)) into struct(col0, col1) in (struct(v00,v01),struct(v10,v11)) -precedenceEqualExpressionMutiple +precedenceSimilarExpressionPartNot[CommonTree t] : - (LPAREN precedenceBitwiseOrExpression (COMMA precedenceBitwiseOrExpression)+ RPAREN -> ^(TOK_FUNCTION Identifier["struct"] precedenceBitwiseOrExpression+)) - ( (KW_IN LPAREN expressionsToStruct (COMMA expressionsToStruct)* RPAREN) - -> ^(TOK_FUNCTION KW_IN $precedenceEqualExpressionMutiple expressionsToStruct*) - | (KW_NOT KW_IN LPAREN expressionsToStruct (COMMA expressionsToStruct)* RPAREN) - -> ^(KW_NOT ^(TOK_FUNCTION KW_IN $precedenceEqualExpressionMutiple expressionsToStruct*))) + precedenceRegexpOperator notExpr=precedenceBitwiseOrExpression + -> ^(precedenceRegexpOperator {$t} $notExpr) + | + precedenceSimilarExpressionAtom[$t] ; -expressionsToStruct +precedenceEqualOperator : - LPAREN expression (COMMA expression)* RPAREN -> ^(TOK_FUNCTION Identifier["struct"] expression+) + EQUAL | EQUAL_NS | NOTEQUAL ; +precedenceEqualExpression + : + precedenceSimilarExpression (precedenceEqualOperator^ precedenceSimilarExpression)* + ; + precedenceNotOperator : KW_NOT diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInternalInterval.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInternalInterval.java deleted file mode 100644 index fcf291a..0000000 --- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInternalInterval.java +++ /dev/null @@ -1,322 +0,0 @@ -/** - * 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.generic; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -import org.apache.hadoop.hive.common.type.HiveIntervalDayTime; -import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth; -import org.apache.hadoop.hive.ql.exec.Description; -import org.apache.hadoop.hive.ql.exec.UDFArgumentException; -import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; -import org.apache.hadoop.hive.ql.metadata.HiveException; -import org.apache.hadoop.hive.ql.parse.HiveParser; -import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable; -import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable; -import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category; -import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory; -import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; -import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; -import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveGrouping; -import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo; -import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; -import org.apache.hive.common.util.DateUtils; - -/** - * GenericUDF Class for support of "INTERVAL (expression) (DAY|YEAR|...)". - */ -@Description(name = "internal_interval", value = "_FUNC_(intervalType,intervalArg)", - extended = "this method is not designed to be used by directly calling it - it provides internal support for 'INTERVAL (intervalArg) intervalType' constructs") - -public class GenericUDFInternalInterval extends GenericUDF { - - private static Map processorMap; - - private transient IntervalProcessor processor; - private transient PrimitiveObjectInspector inputOI; - - @Override - public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { - - // read operation mode - if (!(arguments[0] instanceof ConstantObjectInspector)) { - throw new UDFArgumentTypeException(0, - getFuncName() + ": may only accept constant as first argument"); - } - Integer operationMode = getConstantIntValue(arguments, 0); - if (operationMode == null) { - throw new UDFArgumentTypeException(0, "must supply operationmode"); - } - - processor = getProcessorMap().get(operationMode); - if (processor == null) { - throw new UDFArgumentTypeException(0, - getFuncName() + ": unsupported operationMode: " + operationMode); - } - - // check value argument - if (arguments[1].getCategory() != Category.PRIMITIVE) { - throw new UDFArgumentTypeException(1, - "The first argument to " + getFuncName() + " must be primitive"); - } - - inputOI = (PrimitiveObjectInspector) arguments[1]; - - PrimitiveCategory inputCategory = inputOI.getPrimitiveCategory(); - - if (!isValidInputCategory(inputCategory)) { - throw new UDFArgumentTypeException(1, "The second argument to " + getFuncName() - + " must be from the string group or numeric group (except:float/double)"); - } - - if (arguments[1] instanceof ConstantObjectInspector) { - // return value as constant in case arg is constant - return PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( - processor.getTypeInfo(), processor.evaluate(getConstantStringValue(arguments, 1))); - } else { - return PrimitiveObjectInspectorFactory - .getPrimitiveWritableObjectInspector(processor.getTypeInfo()); - } - } - - private boolean isValidInputCategory(PrimitiveCategory cat) throws UDFArgumentTypeException { - PrimitiveGrouping inputOIGroup = PrimitiveObjectInspectorUtils.getPrimitiveGrouping(cat); - - if (inputOIGroup == PrimitiveGrouping.STRING_GROUP) { - return true; - } - if (inputOIGroup == PrimitiveGrouping.NUMERIC_GROUP) { - switch (cat) { - case DOUBLE: - case FLOAT: - return false; - default: - return true; - } - } - return false; - } - - @Override - public Object evaluate(DeferredObject[] arguments) throws HiveException { - String argString = PrimitiveObjectInspectorUtils.getString(arguments[1].get(), inputOI); - if (argString == null) { - return null; - } - try { - return processor.evaluate(argString); - } catch (Exception e) { - throw new UDFArgumentTypeException(1, "Error parsing interval " + argString + " using:" - + processor.getClass().getSimpleName()); - } - } - - private static interface IntervalProcessor { - - Integer getKey(); - - PrimitiveTypeInfo getTypeInfo(); - - Object evaluate(String arg) throws UDFArgumentException; - } - - private static abstract class AbstractDayTimeIntervalProcessor implements IntervalProcessor { - private transient HiveIntervalDayTimeWritable intervalResult = - new HiveIntervalDayTimeWritable(); - - @Override - public final PrimitiveTypeInfo getTypeInfo() { - return TypeInfoFactory.intervalDayTimeTypeInfo; - } - - @Override - public final Object evaluate(String arg) throws UDFArgumentException { - intervalResult.set(getIntervalDayTime(arg)); - return intervalResult; - } - - abstract protected HiveIntervalDayTime getIntervalDayTime(String arg); - } - - private static abstract class AbstractYearMonthIntervalProcessor implements IntervalProcessor { - private transient HiveIntervalYearMonthWritable intervalResult = - new HiveIntervalYearMonthWritable(); - - @Override - public final PrimitiveTypeInfo getTypeInfo() { - return TypeInfoFactory.intervalYearMonthTypeInfo; - } - - @Override - public final Object evaluate(String arg) throws UDFArgumentException { - intervalResult.set(getIntervalYearMonth(arg)); - return intervalResult; - } - - abstract protected HiveIntervalYearMonth getIntervalYearMonth(String arg); - } - - private static class IntervalDayLiteralProcessor extends AbstractDayTimeIntervalProcessor { - - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_DAY_LITERAL; - } - - @Override - protected HiveIntervalDayTime getIntervalDayTime(String arg) { - return new HiveIntervalDayTime(Integer.parseInt(arg), 0, 0, 0, 0); - } - } - - private static class IntervalHourLiteralProcessor extends AbstractDayTimeIntervalProcessor { - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_HOUR_LITERAL; - } - - @Override - protected HiveIntervalDayTime getIntervalDayTime(String arg) { - return new HiveIntervalDayTime(0, Integer.parseInt(arg), 0, 0, 0); - } - } - - private static class IntervalMinuteLiteralProcessor extends AbstractDayTimeIntervalProcessor { - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_MINUTE_LITERAL; - } - - @Override - protected HiveIntervalDayTime getIntervalDayTime(String arg) { - return new HiveIntervalDayTime(0, 0, Integer.parseInt(arg), 0, 0); - } - } - - private static class IntervalSecondLiteralProcessor extends AbstractDayTimeIntervalProcessor { - - private static final BigDecimal NANOS_PER_SEC_BD = new BigDecimal(DateUtils.NANOS_PER_SEC); - - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_SECOND_LITERAL; - } - - @Override - protected HiveIntervalDayTime getIntervalDayTime(String arg) { - BigDecimal bd = new BigDecimal(arg); - BigDecimal bdSeconds = new BigDecimal(bd.toBigInteger()); - BigDecimal bdNanos = bd.subtract(bdSeconds); - return new HiveIntervalDayTime(0, 0, 0, bdSeconds.intValueExact(), - bdNanos.multiply(NANOS_PER_SEC_BD).intValue()); - } - } - - private static class IntervalDayTimeLiteralProcessor extends AbstractDayTimeIntervalProcessor { - - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_DAY_TIME_LITERAL; - } - - @Override - protected HiveIntervalDayTime getIntervalDayTime(String arg) { - return HiveIntervalDayTime.valueOf(arg); - } - } - - private static class IntervalYearMonthLiteralProcessor - extends AbstractYearMonthIntervalProcessor { - - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_YEAR_MONTH_LITERAL; - } - - @Override - protected HiveIntervalYearMonth getIntervalYearMonth(String arg) { - return HiveIntervalYearMonth.valueOf(arg); - } - } - - private static class IntervalYearLiteralProcessor extends AbstractYearMonthIntervalProcessor { - - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_YEAR_LITERAL; - } - - @Override - protected HiveIntervalYearMonth getIntervalYearMonth(String arg) { - return new HiveIntervalYearMonth(Integer.parseInt(arg), 0); - } - } - - private static class IntervalMonthLiteralProcessor extends AbstractYearMonthIntervalProcessor { - - @Override - public Integer getKey() { - return HiveParser.TOK_INTERVAL_MONTH_LITERAL; - } - - @Override - protected HiveIntervalYearMonth getIntervalYearMonth(String arg) { - return new HiveIntervalYearMonth(0, Integer.parseInt(arg)); - } - } - - private static Map getProcessorMap() { - - if (processorMap != null) { - return processorMap; - } - - Map ret = new HashMap<>(); - IntervalProcessor ips[]=new IntervalProcessor[]{ - new IntervalDayTimeLiteralProcessor(), - - new IntervalDayLiteralProcessor(), - new IntervalHourLiteralProcessor(), - new IntervalMinuteLiteralProcessor(), - new IntervalSecondLiteralProcessor(), - - new IntervalYearMonthLiteralProcessor(), - - new IntervalYearLiteralProcessor(), - new IntervalMonthLiteralProcessor(), - }; - - for (IntervalProcessor ip : ips) { - ret.put(ip.getKey(), ip); - } - - return processorMap=ret; - } - - @Override - public String getDisplayString(String[] children) { - return String.format("%s(%s)", processor.getClass().getSimpleName(), children[1]); - } - -} diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestParseDriverIntervals.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestParseDriverIntervals.java deleted file mode 100644 index e5db412..0000000 --- a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestParseDriverIntervals.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * 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.parse; - -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.hadoop.hive.ql.lib.Node; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Parameterized.class) -public class TestParseDriverIntervals { - - private String query; - private ParseDriver parseDriver; - - @Parameters(name = "{0}") - public static List getParameters() { - List ret = new ArrayList<>(); - ret.add(new Object[] { "select 1 days" }); - ret.add(new Object[] { "select (1) days" }); - ret.add(new Object[] { "select (1) day" }); - ret.add(new Object[] { "select (1+1) days" }); - ret.add(new Object[] { "select interval 1 days" }); - ret.add(new Object[] { "select interval '1' days" }); - ret.add(new Object[] { "select interval (x) days" }); - ret.add(new Object[] { "select interval (x+1) days" }); - ret.add(new Object[] { "select interval (1+x) days" }); - ret.add(new Object[] { "select interval (1+1) days" }); - ret.add(new Object[] { "select interval (x+1) days" }); - - return ret; - } - - public TestParseDriverIntervals(String query) { - parseDriver = new ParseDriver(); - this.query = query; - } - - @Test - public void parseInterval() throws Exception { - ASTNode root = parseDriver.parse(query); - assertNotNull("failed: " + query, findFunctionNode(root)); - System.out.println(root.dump()); - } - - private ASTNode findFunctionNode(ASTNode n) { - if (n.getType() == HiveParser.TOK_FUNCTION) { - if ("internal_interval".equals(n.getChild(0).getText())) { - return n; - } - } - ArrayList children = n.getChildren(); - if (children != null) { - for (Node c : children) { - ASTNode r = findFunctionNode((ASTNode) c); - if (r != null) - return r; - } - } - return null; - } -} diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFInternalInterval.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFInternalInterval.java deleted file mode 100644 index 8166bc0..0000000 --- a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFInternalInterval.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * 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.generic; - -import org.apache.hadoop.hive.ql.exec.UDFArgumentException; -import org.apache.hadoop.hive.ql.parse.HiveParser; -import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject; -import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject; -import org.apache.hadoop.hive.serde2.io.ByteWritable; -import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable; -import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; -import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; -import org.apache.hadoop.io.IntWritable; -import org.apache.hadoop.io.Text; -import org.junit.Assert; -import org.junit.Test; - -public class TestGenericUDFInternalInterval { - - @Test - public void testDayInterval() throws Exception { - try (GenericUDFInternalInterval udf = new GenericUDFInternalInterval()) { - - ObjectInspector[] inputOIs = - { - PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( - TypeInfoFactory.intTypeInfo, - new IntWritable(HiveParser.TOK_INTERVAL_DAY_LITERAL)), - PrimitiveObjectInspectorFactory.writableStringObjectInspector - }; - - DeferredObject[] args = { - new DeferredJavaObject(new ByteWritable((byte) 4)), - new DeferredJavaObject(new Text("8")) - }; - - PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs); - Assert.assertEquals(TypeInfoFactory.intervalDayTimeTypeInfo, oi.getTypeInfo()); - HiveIntervalDayTimeWritable res = (HiveIntervalDayTimeWritable) udf.evaluate(args); - Assert.assertEquals(8, res.getHiveIntervalDayTime().getDays()); - } - } - - @Test - public void testDayIntervalConstant() throws Exception { - try (GenericUDFInternalInterval udf = new GenericUDFInternalInterval()) { - - ObjectInspector[] inputOIs = { - PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( - TypeInfoFactory.intTypeInfo, new IntWritable(HiveParser.TOK_INTERVAL_DAY_LITERAL)), - PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( - TypeInfoFactory.intTypeInfo, new IntWritable(3)) - }; - - PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs); - Assert.assertEquals(TypeInfoFactory.intervalDayTimeTypeInfo, oi.getTypeInfo()); - ConstantObjectInspector coi = (ConstantObjectInspector) oi; - HiveIntervalDayTimeWritable res = - (HiveIntervalDayTimeWritable) coi.getWritableConstantValue(); - Assert.assertEquals(3, res.getHiveIntervalDayTime().getDays()); - } - } - - @Test(expected = UDFArgumentException.class) - public void testDoubleArgumentIsNotSupported() throws Exception { - try (GenericUDFInternalInterval udf = new GenericUDFInternalInterval()) { - - ObjectInspector[] inputOIs = { - PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( - TypeInfoFactory.intTypeInfo, - new IntWritable(HiveParser.TOK_INTERVAL_DAY_LITERAL)), - PrimitiveObjectInspectorFactory.writableDoubleObjectInspector, - }; - - // should detect double - udf.initialize(inputOIs); - } - } - - @Test(expected = UDFArgumentException.class) - public void testInvalidString() throws Exception { - try (GenericUDFInternalInterval udf = new GenericUDFInternalInterval()) { - - ObjectInspector[] inputOIs = { - PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( - TypeInfoFactory.intTypeInfo, - new IntWritable(HiveParser.TOK_INTERVAL_DAY_LITERAL)), - PrimitiveObjectInspectorFactory.writableStringObjectInspector, - }; - - DeferredObject[] args = { - new DeferredJavaObject(new ByteWritable((byte) 4)), - new DeferredJavaObject(new Text("invalid")) - }; - - PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs); - Assert.assertEquals(TypeInfoFactory.intervalDayTimeTypeInfo, oi.getTypeInfo()); - // should emit an exception - udf.evaluate(args); - } - } - - @Test - public void testNullBypass() throws Exception { - try (GenericUDFInternalInterval udf = new GenericUDFInternalInterval()) { - - ObjectInspector[] inputOIs = { - PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( - TypeInfoFactory.intTypeInfo, - new IntWritable(HiveParser.TOK_INTERVAL_DAY_LITERAL)), - PrimitiveObjectInspectorFactory.writableStringObjectInspector - }; - DeferredObject[] args = { - new DeferredJavaObject(new ByteWritable((byte) 4)), - new DeferredJavaObject(null) - }; - - PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs); - Assert.assertEquals(TypeInfoFactory.intervalDayTimeTypeInfo, oi.getTypeInfo()); - HiveIntervalDayTimeWritable res = (HiveIntervalDayTimeWritable) udf.evaluate(args); - Assert.assertEquals(null, res); - } - } - -} diff --git a/ql/src/test/queries/clientpositive/interval_alt.q b/ql/src/test/queries/clientpositive/interval_alt.q deleted file mode 100644 index a4fbe9f..0000000 --- a/ql/src/test/queries/clientpositive/interval_alt.q +++ /dev/null @@ -1,36 +0,0 @@ - -select - (1) second, - 2 seconds, - (1) minute, - 2 minutes, - (1) hour, - 2 hours, - (1) day, - 2 days, - (1) month, - 2 months, - (1) year, - 2 years; - -select date '2012-01-01' + 30 days; -select date '2012-01-01' - 30 days; - -create table t (dt int); -insert into t values (1),(2); - --- expressions/columnref -explain -select - date '2012-01-01' + (-dt*dt) day, - date '2012-01-01' - interval (-dt*dt) day, - date '2012-01-01' + 1 day + '2' days, - date '2012-01-01' + (dt || '-1') year to month - from t; - -select - date '2012-01-01' + (-dt*dt) day, - date '2012-01-01' - interval (-dt*dt) day, - date '2012-01-01' + 1 day + '2' days, - date '2012-01-01' + (dt || '-1') year to month - from t; diff --git a/ql/src/test/queries/clientpositive/parenthese.q b/ql/src/test/queries/clientpositive/parenthese.q new file mode 100644 index 0000000..60a2b5b --- /dev/null +++ b/ql/src/test/queries/clientpositive/parenthese.q @@ -0,0 +1,80 @@ +drop table airports; +create table airports (airport string); + +SELECT * FROM airports +WHERE (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((`airports`.`airport` = "Thigpen" + OR `airports`.`airport` = "Astoria Regional") + OR `airports`.`airport` = "Warsaw Municipal") + OR `airports`.`airport` = "John F Kennedy Memorial") + OR `airports`.`airport` = "Hall-Miller Municipal") + OR `airports`.`airport` = "Atqasuk") + OR `airports`.`airport` = "William B Hartsfield-Atlanta Intl") + OR `airports`.`airport` = "Artesia Municipal") + OR `airports`.`airport` = "Outagamie County Regional") + OR `airports`.`airport` = "Watertown Municipal") + OR `airports`.`airport` = "Augusta State") + OR `airports`.`airport` = "Aurora Municipal") + OR `airports`.`airport` = "Alakanuk") + OR `airports`.`airport` = "Austin Municipal") + OR `airports`.`airport` = "Auburn Municipal") + OR `airports`.`airport` = "Auburn-Opelik") + OR `airports`.`airport` = "Austin-Bergstrom International") + OR `airports`.`airport` = "Wausau Municipal") + OR `airports`.`airport` = "Mecklenburg-Brunswick Regional") + OR `airports`.`airport` = "Alva Regional") + OR `airports`.`airport` = "Asheville Regional") + OR `airports`.`airport` = "Avon Park Municipal") + OR `airports`.`airport` = "Wilkes-Barre/Scranton Intl") + OR `airports`.`airport` = "Marana Northwest Regional") + OR `airports`.`airport` = "Catalina") + OR `airports`.`airport` = "Washington Municipal") + OR `airports`.`airport` = "Wainwright") + OR `airports`.`airport` = "West Memphis Municipal") + OR `airports`.`airport` = "Arlington Municipal") + OR `airports`.`airport` = "Algona Municipal") + OR `airports`.`airport` = "Chandler") + OR `airports`.`airport` = "Altus Municipal") + OR `airports`.`airport` = "Neil Armstrong") + OR `airports`.`airport` = "Angel Fire") + OR `airports`.`airport` = "Waycross-Ware County") + OR `airports`.`airport` = "Colorado City Municipal") + OR `airports`.`airport` = "Hazelhurst") + OR `airports`.`airport` = "Kalamazoo County") + OR `airports`.`airport` = "Granville") + OR `airports`.`airport` = "Silver Springs") + OR `airports`.`airport` = "Whitford") + OR `airports`.`airport` = "Biddeford Municipal") + OR `airports`.`airport` = "Sugarloaf Regional") + OR `airports`.`airport` = "Barnes Municipal") + OR `airports`.`airport` = "Columbus Municipal") + OR `airports`.`airport` = "Battle Mountain") + OR `airports`.`airport` = "Huron County Memorial") + OR `airports`.`airport` = "New Braunfels Municipal") + OR `airports`.`airport` = "Benson Municipal") + OR `airports`.`airport` = "Curtis") + OR `airports`.`airport` = "Marlboro County") + OR `airports`.`airport` = "Broken Bow Municipal") + OR `airports`.`airport` = "Virginia Tech") + OR `airports`.`airport` = "Bryce Canyon") + OR `airports`.`airport` = "Black River Falls Area") + OR `airports`.`airport` = "Boca Raton") + OR `airports`.`airport` = "Birchwood") + OR `airports`.`airport` = "Baudette International") + OR `airports`.`airport` = "Blanding Muni") + OR `airports`.`airport` = "Bradley International") + OR `airports`.`airport` = "Morrilton Municipal") + OR `airports`.`airport` = "Igor I Sikorsky Memorial") + OR `airports`.`airport` = "Broadus") + OR `airports`.`airport` = "Laurence G Hanscom") + OR `airports`.`airport` = "Southwest Michigan Regional") + OR `airports`.`airport` = "Bethel") + OR `airports`.`airport` = "Bradford Reg") + OR `airports`.`airport` = "Scotts Bluff County") + OR `airports`.`airport` = "Boeing Field/King County Intl") + OR `airports`.`airport` = "Buffalo Municipal") + OR `airports`.`airport` = "Meadows") + OR `airports`.`airport` = "Mobile Downtown") + OR `airports`.`airport` = "Virgil I Grissom Municipal") + OR `airports`.`airport` = "Silver Bay Municipal"); + + diff --git a/ql/src/test/queries/clientpositive/udf_in.q b/ql/src/test/queries/clientpositive/udf_in.q index a7ce3c6..f54d963 100644 --- a/ql/src/test/queries/clientpositive/udf_in.q +++ b/ql/src/test/queries/clientpositive/udf_in.q @@ -5,11 +5,11 @@ SELECT 1 IN (1, 2, 3), array(1,2,3) IN (array(1,2,3)), "bee" IN("aee", "bee", "cee", 1), "dee" IN("aee", "bee", "cee"), - 1 = 1 IN(true, false), + (1 = 1) IN(true, false), true IN (true, false) = true, 1 IN (1, 2, 3) OR false IN(false), NULL IN (1, 2, 3), 4 IN (1, 2, 3, NULL), (1+3) IN (5, 6, (1+2) + 1) FROM src tablesample (1 rows); -SELECT key FROM src WHERE key IN ("238", 86); \ No newline at end of file +SELECT key FROM src WHERE key IN ("238", 86); diff --git a/ql/src/test/queries/clientpositive/udf_notop.q b/ql/src/test/queries/clientpositive/udf_notop.q index dceab7e..5cf918c 100644 --- a/ql/src/test/queries/clientpositive/udf_notop.q +++ b/ql/src/test/queries/clientpositive/udf_notop.q @@ -2,7 +2,7 @@ set hive.fetch.task.conversion=more; SELECT 1 NOT IN (1, 2, 3), 4 NOT IN (1, 2, 3), - 1 = 2 NOT IN (true, false), + (1 = 2) NOT IN (true, false), "abc" NOT LIKE "a%", "abc" NOT LIKE "b%", "abc" NOT RLIKE "^ab", diff --git a/ql/src/test/results/clientnegative/char_pad_convert_fail2.q.out b/ql/src/test/results/clientnegative/char_pad_convert_fail2.q.out index 2d08fb3..2780b7c 100644 --- a/ql/src/test/results/clientnegative/char_pad_convert_fail2.q.out +++ b/ql/src/test/results/clientnegative/char_pad_convert_fail2.q.out @@ -40,4 +40,4 @@ POSTHOOK: query: load data local inpath '../../data/files/over1k' into table ove POSTHOOK: type: LOAD #### A masked pattern was here #### POSTHOOK: Output: default@over1k -FAILED: ParseException line 7:7 cannot recognize input near 'lpad' '(' '{' in expression specification +FAILED: ParseException line 7:11 cannot recognize input near 'lpad' '(' '{' in expression specification diff --git a/ql/src/test/results/clientnegative/invalid_select_expression.q.out b/ql/src/test/results/clientnegative/invalid_select_expression.q.out index 3650ca7..63a682a 100644 --- a/ql/src/test/results/clientnegative/invalid_select_expression.q.out +++ b/ql/src/test/results/clientnegative/invalid_select_expression.q.out @@ -1 +1 @@ -FAILED: ParseException line 1:26 cannot recognize input near 'foo' '>' '.' in expression specification +FAILED: ParseException line 1:32 cannot recognize input near '.' 'foo' '' in expression specification diff --git a/ql/src/test/results/clientnegative/ptf_negative_DistributeByOrderBy.q.out b/ql/src/test/results/clientnegative/ptf_negative_DistributeByOrderBy.q.out index a0f3fe2..e8e8580 100644 --- a/ql/src/test/results/clientnegative/ptf_negative_DistributeByOrderBy.q.out +++ b/ql/src/test/results/clientnegative/ptf_negative_DistributeByOrderBy.q.out @@ -1 +1 @@ -FAILED: ParseException line 3:0 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification +FAILED: ParseException line 3:3 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification diff --git a/ql/src/test/results/clientnegative/ptf_negative_PartitionBySortBy.q.out b/ql/src/test/results/clientnegative/ptf_negative_PartitionBySortBy.q.out index a0f3fe2..e8e8580 100644 --- a/ql/src/test/results/clientnegative/ptf_negative_PartitionBySortBy.q.out +++ b/ql/src/test/results/clientnegative/ptf_negative_PartitionBySortBy.q.out @@ -1 +1 @@ -FAILED: ParseException line 3:0 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification +FAILED: ParseException line 3:3 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification diff --git a/ql/src/test/results/clientnegative/ptf_window_boundaries.q.out b/ql/src/test/results/clientnegative/ptf_window_boundaries.q.out index 3808f2c..c9c1c6d 100644 --- a/ql/src/test/results/clientnegative/ptf_window_boundaries.q.out +++ b/ql/src/test/results/clientnegative/ptf_window_boundaries.q.out @@ -1 +1 @@ -FAILED: ParseException line 2:4 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification +FAILED: ParseException line 2:7 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification diff --git a/ql/src/test/results/clientnegative/ptf_window_boundaries2.q.out b/ql/src/test/results/clientnegative/ptf_window_boundaries2.q.out index 3808f2c..c9c1c6d 100644 --- a/ql/src/test/results/clientnegative/ptf_window_boundaries2.q.out +++ b/ql/src/test/results/clientnegative/ptf_window_boundaries2.q.out @@ -1 +1 @@ -FAILED: ParseException line 2:4 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification +FAILED: ParseException line 2:7 cannot recognize input near 'sum' '(' 'p_retailprice' in expression specification diff --git a/ql/src/test/results/clientnegative/subquery_missing_from.q.out b/ql/src/test/results/clientnegative/subquery_missing_from.q.out index eaf7735..b09a8e3 100644 --- a/ql/src/test/results/clientnegative/subquery_missing_from.q.out +++ b/ql/src/test/results/clientnegative/subquery_missing_from.q.out @@ -1,3 +1,3 @@ FAILED: SemanticException Line 0:-1 Invalid SubQuery expression 'key' in definition of SubQuery sq_1 [ src.key in (select key) -] used as sq_1 at Line 1:32: From clause is missing in SubQuery. +] used as sq_1 at Line 0:-1: From clause is missing in SubQuery. diff --git a/ql/src/test/results/clientnegative/subquery_subquery_chain.q.out b/ql/src/test/results/clientnegative/subquery_subquery_chain.q.out index e661e1b..e08b86c 100644 --- a/ql/src/test/results/clientnegative/subquery_subquery_chain.q.out +++ b/ql/src/test/results/clientnegative/subquery_subquery_chain.q.out @@ -1 +1 @@ -FAILED: SemanticException [Error 10249]: org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Line 5:14 Unsupported SubQuery Expression 'key': IN/NOT IN subqueries are not allowed in LHS +FAILED: ParseException line 5:39 missing EOF at 'in' near ')' diff --git a/ql/src/test/results/clientnegative/subquery_with_or_cond.q.out b/ql/src/test/results/clientnegative/subquery_with_or_cond.q.out index 4a9cc45..9e41a41 100644 --- a/ql/src/test/results/clientnegative/subquery_with_or_cond.q.out +++ b/ql/src/test/results/clientnegative/subquery_with_or_cond.q.out @@ -1 +1 @@ -FAILED: SemanticException [Error 10249]: org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Line 4:14 Unsupported SubQuery Expression 'key': Only SubQuery expressions that are top level conjuncts are allowed +FAILED: SemanticException org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException: Line 0:-1 Unsupported SubQuery Expression 'key': Only SubQuery expressions that are top level conjuncts are allowed diff --git a/ql/src/test/results/clientnegative/udf_in.q.out b/ql/src/test/results/clientnegative/udf_in.q.out index 773230b..c032ee4 100644 --- a/ql/src/test/results/clientnegative/udf_in.q.out +++ b/ql/src/test/results/clientnegative/udf_in.q.out @@ -1 +1 @@ -FAILED: SemanticException [Error 10014]: Line 1:9 Wrong arguments '3': The arguments for IN should be the same type! Types are: {int IN (array)} +FAILED: SemanticException Line 0:-1 Wrong arguments '3': The arguments for IN should be the same type! Types are: {int IN (array)} diff --git a/ql/src/test/results/clientpositive/llap/vector_between_in.q.out b/ql/src/test/results/clientpositive/llap/vector_between_in.q.out index 74384a4..fcef2d4 100644 --- a/ql/src/test/results/clientpositive/llap/vector_between_in.q.out +++ b/ql/src/test/results/clientpositive/llap/vector_between_in.q.out @@ -317,7 +317,7 @@ STAGE PLANS: alias: decimal_date_test Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Filter Operator - predicate: cdate NOT BETWEEN 1968-05-01 AND 1971-09-01 (type: boolean) + predicate: (not cdate BETWEEN 1968-05-01 AND 1971-09-01) (type: boolean) Statistics: Num rows: 10923 Data size: 2193503 Basic stats: COMPLETE Column stats: NONE Select Operator expressions: cdate (type: date) @@ -427,7 +427,7 @@ STAGE PLANS: alias: decimal_date_test Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Filter Operator - predicate: cdecimal1 NOT BETWEEN -2000 AND 4390.1351351351 (type: boolean) + predicate: (not cdecimal1 BETWEEN -2000 AND 4390.1351351351) (type: boolean) Statistics: Num rows: 10923 Data size: 2193503 Basic stats: COMPLETE Column stats: NONE Select Operator Statistics: Num rows: 10923 Data size: 2193503 Basic stats: COMPLETE Column stats: NONE @@ -957,7 +957,7 @@ STAGE PLANS: alias: decimal_date_test Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Select Operator - expressions: cdecimal1 NOT BETWEEN -2000 AND 4390.1351351351 (type: boolean) + expressions: (not cdecimal1 BETWEEN -2000 AND 4390.1351351351) (type: boolean) outputColumnNames: _col0 Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Group By Operator diff --git a/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out b/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out index 391c775..b394105 100644 --- a/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out +++ b/ql/src/test/results/clientpositive/llap/vector_interval_arithmetic.q.out @@ -502,7 +502,7 @@ STAGE PLANS: Tez #### A masked pattern was here #### Edges: - Reducer 2 <- Map 1 (SIMPLE_EDGE) + Reducer 2 <- Map 1 (CUSTOM_SIMPLE_EDGE) #### A masked pattern was here #### Vertices: Map 1 @@ -513,8 +513,7 @@ STAGE PLANS: Select Operator Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE Reduce Output Operator - key expressions: CAST( 5-5 AS INTERVAL YEAR TO MONTH) (type: interval_year_month) - sort order: + + sort order: Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE TopN Hash Memory Usage: 0.1 Execution mode: vectorized, llap diff --git a/ql/src/test/results/clientpositive/parenthese.q.out b/ql/src/test/results/clientpositive/parenthese.q.out new file mode 100644 index 0000000..e7eae5a --- /dev/null +++ b/ql/src/test/results/clientpositive/parenthese.q.out @@ -0,0 +1,168 @@ +PREHOOK: query: drop table airports +PREHOOK: type: DROPTABLE +POSTHOOK: query: drop table airports +POSTHOOK: type: DROPTABLE +PREHOOK: query: create table airports (airport string) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@airports +POSTHOOK: query: create table airports (airport string) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@airports +PREHOOK: query: SELECT * FROM airports +WHERE (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((`airports`.`airport` = "Thigpen" + OR `airports`.`airport` = "Astoria Regional") + OR `airports`.`airport` = "Warsaw Municipal") + OR `airports`.`airport` = "John F Kennedy Memorial") + OR `airports`.`airport` = "Hall-Miller Municipal") + OR `airports`.`airport` = "Atqasuk") + OR `airports`.`airport` = "William B Hartsfield-Atlanta Intl") + OR `airports`.`airport` = "Artesia Municipal") + OR `airports`.`airport` = "Outagamie County Regional") + OR `airports`.`airport` = "Watertown Municipal") + OR `airports`.`airport` = "Augusta State") + OR `airports`.`airport` = "Aurora Municipal") + OR `airports`.`airport` = "Alakanuk") + OR `airports`.`airport` = "Austin Municipal") + OR `airports`.`airport` = "Auburn Municipal") + OR `airports`.`airport` = "Auburn-Opelik") + OR `airports`.`airport` = "Austin-Bergstrom International") + OR `airports`.`airport` = "Wausau Municipal") + OR `airports`.`airport` = "Mecklenburg-Brunswick Regional") + OR `airports`.`airport` = "Alva Regional") + OR `airports`.`airport` = "Asheville Regional") + OR `airports`.`airport` = "Avon Park Municipal") + OR `airports`.`airport` = "Wilkes-Barre/Scranton Intl") + OR `airports`.`airport` = "Marana Northwest Regional") + OR `airports`.`airport` = "Catalina") + OR `airports`.`airport` = "Washington Municipal") + OR `airports`.`airport` = "Wainwright") + OR `airports`.`airport` = "West Memphis Municipal") + OR `airports`.`airport` = "Arlington Municipal") + OR `airports`.`airport` = "Algona Municipal") + OR `airports`.`airport` = "Chandler") + OR `airports`.`airport` = "Altus Municipal") + OR `airports`.`airport` = "Neil Armstrong") + OR `airports`.`airport` = "Angel Fire") + OR `airports`.`airport` = "Waycross-Ware County") + OR `airports`.`airport` = "Colorado City Municipal") + OR `airports`.`airport` = "Hazelhurst") + OR `airports`.`airport` = "Kalamazoo County") + OR `airports`.`airport` = "Granville") + OR `airports`.`airport` = "Silver Springs") + OR `airports`.`airport` = "Whitford") + OR `airports`.`airport` = "Biddeford Municipal") + OR `airports`.`airport` = "Sugarloaf Regional") + OR `airports`.`airport` = "Barnes Municipal") + OR `airports`.`airport` = "Columbus Municipal") + OR `airports`.`airport` = "Battle Mountain") + OR `airports`.`airport` = "Huron County Memorial") + OR `airports`.`airport` = "New Braunfels Municipal") + OR `airports`.`airport` = "Benson Municipal") + OR `airports`.`airport` = "Curtis") + OR `airports`.`airport` = "Marlboro County") + OR `airports`.`airport` = "Broken Bow Municipal") + OR `airports`.`airport` = "Virginia Tech") + OR `airports`.`airport` = "Bryce Canyon") + OR `airports`.`airport` = "Black River Falls Area") + OR `airports`.`airport` = "Boca Raton") + OR `airports`.`airport` = "Birchwood") + OR `airports`.`airport` = "Baudette International") + OR `airports`.`airport` = "Blanding Muni") + OR `airports`.`airport` = "Bradley International") + OR `airports`.`airport` = "Morrilton Municipal") + OR `airports`.`airport` = "Igor I Sikorsky Memorial") + OR `airports`.`airport` = "Broadus") + OR `airports`.`airport` = "Laurence G Hanscom") + OR `airports`.`airport` = "Southwest Michigan Regional") + OR `airports`.`airport` = "Bethel") + OR `airports`.`airport` = "Bradford Reg") + OR `airports`.`airport` = "Scotts Bluff County") + OR `airports`.`airport` = "Boeing Field/King County Intl") + OR `airports`.`airport` = "Buffalo Municipal") + OR `airports`.`airport` = "Meadows") + OR `airports`.`airport` = "Mobile Downtown") + OR `airports`.`airport` = "Virgil I Grissom Municipal") + OR `airports`.`airport` = "Silver Bay Municipal") +PREHOOK: type: QUERY +PREHOOK: Input: default@airports +#### A masked pattern was here #### +POSTHOOK: query: SELECT * FROM airports +WHERE (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((`airports`.`airport` = "Thigpen" + OR `airports`.`airport` = "Astoria Regional") + OR `airports`.`airport` = "Warsaw Municipal") + OR `airports`.`airport` = "John F Kennedy Memorial") + OR `airports`.`airport` = "Hall-Miller Municipal") + OR `airports`.`airport` = "Atqasuk") + OR `airports`.`airport` = "William B Hartsfield-Atlanta Intl") + OR `airports`.`airport` = "Artesia Municipal") + OR `airports`.`airport` = "Outagamie County Regional") + OR `airports`.`airport` = "Watertown Municipal") + OR `airports`.`airport` = "Augusta State") + OR `airports`.`airport` = "Aurora Municipal") + OR `airports`.`airport` = "Alakanuk") + OR `airports`.`airport` = "Austin Municipal") + OR `airports`.`airport` = "Auburn Municipal") + OR `airports`.`airport` = "Auburn-Opelik") + OR `airports`.`airport` = "Austin-Bergstrom International") + OR `airports`.`airport` = "Wausau Municipal") + OR `airports`.`airport` = "Mecklenburg-Brunswick Regional") + OR `airports`.`airport` = "Alva Regional") + OR `airports`.`airport` = "Asheville Regional") + OR `airports`.`airport` = "Avon Park Municipal") + OR `airports`.`airport` = "Wilkes-Barre/Scranton Intl") + OR `airports`.`airport` = "Marana Northwest Regional") + OR `airports`.`airport` = "Catalina") + OR `airports`.`airport` = "Washington Municipal") + OR `airports`.`airport` = "Wainwright") + OR `airports`.`airport` = "West Memphis Municipal") + OR `airports`.`airport` = "Arlington Municipal") + OR `airports`.`airport` = "Algona Municipal") + OR `airports`.`airport` = "Chandler") + OR `airports`.`airport` = "Altus Municipal") + OR `airports`.`airport` = "Neil Armstrong") + OR `airports`.`airport` = "Angel Fire") + OR `airports`.`airport` = "Waycross-Ware County") + OR `airports`.`airport` = "Colorado City Municipal") + OR `airports`.`airport` = "Hazelhurst") + OR `airports`.`airport` = "Kalamazoo County") + OR `airports`.`airport` = "Granville") + OR `airports`.`airport` = "Silver Springs") + OR `airports`.`airport` = "Whitford") + OR `airports`.`airport` = "Biddeford Municipal") + OR `airports`.`airport` = "Sugarloaf Regional") + OR `airports`.`airport` = "Barnes Municipal") + OR `airports`.`airport` = "Columbus Municipal") + OR `airports`.`airport` = "Battle Mountain") + OR `airports`.`airport` = "Huron County Memorial") + OR `airports`.`airport` = "New Braunfels Municipal") + OR `airports`.`airport` = "Benson Municipal") + OR `airports`.`airport` = "Curtis") + OR `airports`.`airport` = "Marlboro County") + OR `airports`.`airport` = "Broken Bow Municipal") + OR `airports`.`airport` = "Virginia Tech") + OR `airports`.`airport` = "Bryce Canyon") + OR `airports`.`airport` = "Black River Falls Area") + OR `airports`.`airport` = "Boca Raton") + OR `airports`.`airport` = "Birchwood") + OR `airports`.`airport` = "Baudette International") + OR `airports`.`airport` = "Blanding Muni") + OR `airports`.`airport` = "Bradley International") + OR `airports`.`airport` = "Morrilton Municipal") + OR `airports`.`airport` = "Igor I Sikorsky Memorial") + OR `airports`.`airport` = "Broadus") + OR `airports`.`airport` = "Laurence G Hanscom") + OR `airports`.`airport` = "Southwest Michigan Regional") + OR `airports`.`airport` = "Bethel") + OR `airports`.`airport` = "Bradford Reg") + OR `airports`.`airport` = "Scotts Bluff County") + OR `airports`.`airport` = "Boeing Field/King County Intl") + OR `airports`.`airport` = "Buffalo Municipal") + OR `airports`.`airport` = "Meadows") + OR `airports`.`airport` = "Mobile Downtown") + OR `airports`.`airport` = "Virgil I Grissom Municipal") + OR `airports`.`airport` = "Silver Bay Municipal") +POSTHOOK: type: QUERY +POSTHOOK: Input: default@airports +#### A masked pattern was here #### diff --git a/ql/src/test/results/clientpositive/perf/query14.q.out b/ql/src/test/results/clientpositive/perf/query14.q.out index 21cabbc..051d837 100644 --- a/ql/src/test/results/clientpositive/perf/query14.q.out +++ b/ql/src/test/results/clientpositive/perf/query14.q.out @@ -1,9 +1,9 @@ +Warning: Shuffle Join MERGEJOIN[914][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 61' is a cross product +Warning: Shuffle Join MERGEJOIN[915][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 62' is a cross product Warning: Shuffle Join MERGEJOIN[916][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 114' is a cross product Warning: Shuffle Join MERGEJOIN[917][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 115' is a cross product Warning: Shuffle Join MERGEJOIN[912][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product Warning: Shuffle Join MERGEJOIN[913][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 6' is a cross product -Warning: Shuffle Join MERGEJOIN[914][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 61' is a cross product -Warning: Shuffle Join MERGEJOIN[915][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 62' is a cross product PREHOOK: query: explain with cross_items as (select i_item_sk ss_item_sk diff --git a/ql/src/test/results/clientpositive/show_functions.q.out b/ql/src/test/results/clientpositive/show_functions.q.out index 3c9bb4a..d3ae958 100644 --- a/ql/src/test/results/clientpositive/show_functions.q.out +++ b/ql/src/test/results/clientpositive/show_functions.q.out @@ -117,7 +117,6 @@ index initcap inline instr -internal_interval isnotnull isnull java_method diff --git a/ql/src/test/results/clientpositive/spark/vector_between_in.q.out b/ql/src/test/results/clientpositive/spark/vector_between_in.q.out index 07af2a3..acd95c3 100644 --- a/ql/src/test/results/clientpositive/spark/vector_between_in.q.out +++ b/ql/src/test/results/clientpositive/spark/vector_between_in.q.out @@ -306,7 +306,7 @@ STAGE PLANS: alias: decimal_date_test Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Filter Operator - predicate: cdate NOT BETWEEN 1968-05-01 AND 1971-09-01 (type: boolean) + predicate: (not cdate BETWEEN 1968-05-01 AND 1971-09-01) (type: boolean) Statistics: Num rows: 10923 Data size: 2193503 Basic stats: COMPLETE Column stats: NONE Select Operator expressions: cdate (type: date) @@ -412,7 +412,7 @@ STAGE PLANS: alias: decimal_date_test Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Filter Operator - predicate: cdecimal1 NOT BETWEEN -2000 AND 4390.1351351351 (type: boolean) + predicate: (not cdecimal1 BETWEEN -2000 AND 4390.1351351351) (type: boolean) Statistics: Num rows: 10923 Data size: 2193503 Basic stats: COMPLETE Column stats: NONE Select Operator Statistics: Num rows: 10923 Data size: 2193503 Basic stats: COMPLETE Column stats: NONE @@ -934,7 +934,7 @@ STAGE PLANS: alias: decimal_date_test Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Select Operator - expressions: cdecimal1 NOT BETWEEN -2000 AND 4390.1351351351 (type: boolean) + expressions: (not cdecimal1 BETWEEN -2000 AND 4390.1351351351) (type: boolean) outputColumnNames: _col0 Statistics: Num rows: 12288 Data size: 2467616 Basic stats: COMPLETE Column stats: NONE Group By Operator diff --git a/ql/src/test/results/clientpositive/udf_between.q.out b/ql/src/test/results/clientpositive/udf_between.q.out index 5b01554..2bb7264 100644 --- a/ql/src/test/results/clientpositive/udf_between.q.out +++ b/ql/src/test/results/clientpositive/udf_between.q.out @@ -81,7 +81,7 @@ STAGE PLANS: alias: src Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE Filter Operator - predicate: (UDFToDouble(key) + 100.0) NOT BETWEEN 100 AND 200 (type: boolean) + predicate: (not (UDFToDouble(key) + 100.0) BETWEEN 100 AND 200) (type: boolean) Statistics: Num rows: 445 Data size: 4727 Basic stats: COMPLETE Column stats: NONE Select Operator expressions: key (type: string), value (type: string) diff --git a/ql/src/test/results/clientpositive/udf_in.q.out b/ql/src/test/results/clientpositive/udf_in.q.out index da07f61..85ee951 100644 --- a/ql/src/test/results/clientpositive/udf_in.q.out +++ b/ql/src/test/results/clientpositive/udf_in.q.out @@ -3,7 +3,7 @@ PREHOOK: query: SELECT 1 IN (1, 2, 3), array(1,2,3) IN (array(1,2,3)), "bee" IN("aee", "bee", "cee", 1), "dee" IN("aee", "bee", "cee"), - 1 = 1 IN(true, false), + (1 = 1) IN(true, false), true IN (true, false) = true, 1 IN (1, 2, 3) OR false IN(false), NULL IN (1, 2, 3), @@ -17,7 +17,7 @@ POSTHOOK: query: SELECT 1 IN (1, 2, 3), array(1,2,3) IN (array(1,2,3)), "bee" IN("aee", "bee", "cee", 1), "dee" IN("aee", "bee", "cee"), - 1 = 1 IN(true, false), + (1 = 1) IN(true, false), true IN (true, false) = true, 1 IN (1, 2, 3) OR false IN(false), NULL IN (1, 2, 3), diff --git a/ql/src/test/results/clientpositive/udf_notop.q.out b/ql/src/test/results/clientpositive/udf_notop.q.out index 25483c7..e8b57e5 100644 --- a/ql/src/test/results/clientpositive/udf_notop.q.out +++ b/ql/src/test/results/clientpositive/udf_notop.q.out @@ -1,6 +1,6 @@ PREHOOK: query: SELECT 1 NOT IN (1, 2, 3), 4 NOT IN (1, 2, 3), - 1 = 2 NOT IN (true, false), + (1 = 2) NOT IN (true, false), "abc" NOT LIKE "a%", "abc" NOT LIKE "b%", "abc" NOT RLIKE "^ab", @@ -13,7 +13,7 @@ PREHOOK: Input: default@src #### A masked pattern was here #### POSTHOOK: query: SELECT 1 NOT IN (1, 2, 3), 4 NOT IN (1, 2, 3), - 1 = 2 NOT IN (true, false), + (1 = 2) NOT IN (true, false), "abc" NOT LIKE "a%", "abc" NOT LIKE "b%", "abc" NOT RLIKE "^ab", diff --git a/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out b/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out index dd4b7d1..cdf6255 100644 --- a/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out +++ b/ql/src/test/results/clientpositive/vector_interval_arithmetic.q.out @@ -480,8 +480,7 @@ STAGE PLANS: Select Operator Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE Reduce Output Operator - key expressions: CAST( 5-5 AS INTERVAL YEAR TO MONTH) (type: interval_year_month) - sort order: + + sort order: Statistics: Num rows: 50 Data size: 800 Basic stats: COMPLETE Column stats: COMPLETE TopN Hash Memory Usage: 0.1 Execution mode: vectorized