amansinha100 commented on code in PR #4965: URL: https://github.com/apache/hive/pull/4965#discussion_r1444228077
########## itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java: ########## @@ -610,12 +612,268 @@ public void testNullCast() throws Throwable { testScriptFile(SCRIPT_TEXT, args(), "^(.(?!(NullPointerException)))*$", OutStream.ERR); } + @Test + public void testACTIVITY_COUNTHplSqlFunction() throws Throwable { + String SCRIPT_TEXT = + "DROP TABLE IF EXISTS result;\n" + + "CREATE TABLE result (col1 string);\n" + + "INSERT INTO result VALUES('Alice');\n" + + "INSERT INTO result VALUES('Bob');\n" + + "SELECT * FROM result;\n" + + "SELECT ACTIVITY_COUNT;"; + testScriptFile(SCRIPT_TEXT, args(), "2"); + } + + @Test + public void testCASTHplSqlFunction1() throws Throwable { + String SCRIPT_TEXT = "SELECT CAST('Abc' AS CHAR(1));"; + testScriptFile(SCRIPT_TEXT, args(), "A"); + } + + @Test + public void testCASTHplSqlFunction2() throws Throwable { + String SCRIPT_TEXT = "SELECT CAST(TIMESTAMP '2015-03-12 10:58:34.111' AS CHAR(10));"; + testScriptFile(SCRIPT_TEXT, args(), "2015-03-12"); + } + + @Test + public void testCHARHplSqlFunction() throws Throwable { + String SCRIPT_TEXT = "select CHAR(2023)"; + testScriptFile(SCRIPT_TEXT, args(), "2023"); + } + + @Test + public void testCOALESCEHplSQLFunction() throws Throwable { Review Comment: I notice this test is not the same as what coalesce.sql was covering. That test file's contents have been removed, so don't we want those tests to carry over here ? Are we going to lose any test coverage ? The same applies to some of the other functions such as SUBSTRING, TRIM, FROM_UNIXTIME etc. ########## hplsql/src/main/java/org/apache/hive/hplsql/functions/FunctionDatetime.java: ########## @@ -166,30 +161,6 @@ void toTimestamp(HplsqlParser.Expr_func_paramsContext ctx) { evalNull(); } } - - /** - * FROM_UNIXTIME() function (convert seconds since 1970-01-01 00:00:00 to timestamp) - */ - void fromUnixtime(HplsqlParser.Expr_func_paramsContext ctx) { - int cnt = BuiltinFunctions.getParamCount(ctx); - if (cnt == 0) { - evalNull(); - return; - } - long epoch = evalPop(ctx.func_param(0).expr()).longValue(); - String format = "yyyy-MM-dd HH:mm:ss"; - if (cnt > 1) { - format = evalPop(ctx.func_param(1).expr()).toString(); - } - evalString(new SimpleDateFormat(format).format(new Date(epoch * 1000))); Review Comment: Previously, this was using the SimpleDateFormat. Based on this change, since this function will be forwarded to Hive's built-in function, that one is now defaulting to DateTimeFormatter. We would want to document the change in behavior for the HPL/SQL function. -- 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