soumyakanti3578 commented on code in PR #5196: URL: https://github.com/apache/hive/pull/5196#discussion_r1934792466
########## ql/src/java/org/apache/hadoop/hive/ql/parse/type/RexNodeExprFactory.java: ########## @@ -615,8 +616,9 @@ protected RexNode createConstantExpr(TypeInfo typeInfo, Object constantValue) SqlStdOperatorTable.ROW, operands); } - return rexBuilder.makeLiteral(constantValue, - TypeConverter.convert(typeInfo, rexBuilder.getTypeFactory()), false); + RelDataType finalType = TypeConverter.convert(typeInfo, rexBuilder.getTypeFactory()); + boolean allowCast = finalType.getFamily() == SqlTypeFamily.CHARACTER; + return rexBuilder.makeLiteral(constantValue, finalType, allowCast); Review Comment: If I remember correctly, we need it because of this extra check on `allowCast` in Calcite 1.33 which wasn't present in 1.25: https://github.com/apache/calcite/blame/calcite-1.33.0/core/src/main/java/org/apache/calcite/rex/RexBuilder.java#L1587 Without the above change, we see diffs like this: ``` - HiveFilter(condition=[SEARCH($7, Sarg[_UTF-16LE'Dona Ana County':VARCHAR(30) CHARACTER SET "UTF-16LE", _UTF-16LE'Douglas County':VARCHAR(30) CHARACTER SET "UTF-16LE", _UTF-16LE'Gaines County':VARCHAR(30) CHARACTER SET "UTF-16LE", _UTF-16LE'Richland County':VARCHAR(30) CHARACTER SET "UTF-16LE", _UTF-16LE'Walker County':VARCHAR(30) CHARACTER SET "UTF-16LE"]:VARCHAR(30) CHARACTER SET "UTF-16LE")]) + HiveFilter(condition=[SEARCH(CAST($7):VARCHAR(2147483647) CHARACTER SET "UTF-16LE", Sarg[_UTF-16LE'Dona Ana County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Douglas County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Gaines County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Richland County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Walker County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"]:VARCHAR(2147483647) CHARACTER SET "UTF-16LE")]) ``` where we always see `VARCHAR`s of length INT_MAX. Allowing cast preserves the older behavior because of the check: ``` if (allowCast) { RexNode literalNotNull = makeLiteral(value, typeNotNull, allowCast); return makeAbstractCast(type, literalNotNull); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org