diff --git a/spark/src/main/scala/io/ddf/spark/etl/DateTimeExtractUDF.scala b/spark/src/main/scala/io/ddf/spark/etl/DateTimeExtractUDF.scala index dac85cc9..6cc53db9 100644 --- a/spark/src/main/scala/io/ddf/spark/etl/DateTimeExtractUDF.scala +++ b/spark/src/main/scala/io/ddf/spark/etl/DateTimeExtractUDF.scala @@ -15,7 +15,6 @@ object DateTimeExtractUDF { case "weekyear" => DateUDF.parseWeekYear(obj) case "weekofyear" => DateUDF.parseWeekOfYear(obj) case "day" => DateUDF.parseDay(obj) - case "dayofmonth" => DateUDF.parseDay(obj) case "dayofweek" => DateUDF.parseDayOfWeek(obj) case "dayofyear" => DateUDF.parseDayOfYear(obj) case "hour" => DateUDF.parseHour(obj) diff --git a/spark/src/main/scala/io/ddf/spark/etl/DateUDFs.scala b/spark/src/main/scala/io/ddf/spark/etl/DateUDFs.scala index 76f7d618..68cc0a1b 100644 --- a/spark/src/main/scala/io/ddf/spark/etl/DateUDFs.scala +++ b/spark/src/main/scala/io/ddf/spark/etl/DateUDFs.scala @@ -175,7 +175,6 @@ object DateUDF { sQLContext.udf.register("weekyear", parseWeekYear) sQLContext.udf.register("weekofyear", parseWeekOfYear) sQLContext.udf.register("day", parseDay) - sQLContext.udf.register("dayofmonth", parseDay) sQLContext.udf.register("dayofweek", parseDayOfWeek) sQLContext.udf.register("dayofweek_text", parseDayOfWeekAsText) sQLContext.udf.register("dayofyear", parseDayOfYear) diff --git a/spark/src/test/java/io/ddf/spark/etl/UDFTest.java b/spark/src/test/java/io/ddf/spark/etl/UDFTest.java index 2efb2263..3c13bdd3 100644 --- a/spark/src/test/java/io/ddf/spark/etl/UDFTest.java +++ b/spark/src/test/java/io/ddf/spark/etl/UDFTest.java @@ -147,10 +147,6 @@ public void testDateTimeExtract() throws DDFException { rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select extract('2015-01-22 20:23 +0000', 'dayofmonth') from @this"); - rows = ddf3.VIEWS.head(1); - Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select extract('2015-01-22 20:23 +0000', 'dayofweek') from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfWeek()); @@ -197,10 +193,6 @@ public void testDateTimeExtract() throws DDFException { rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select extract(1433386800, 'dayofmonth') from @this"); - rows = ddf3.VIEWS.head(1); - Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select extract(1433386800, 'dayofweek') from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfWeek()); @@ -251,10 +243,6 @@ public void testDateTimeExtract() throws DDFException { rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select extract(4147483647, 'dayofmonth') from @this"); - rows = ddf3.VIEWS.head(1); - Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select extract(4147483647, 'dayofweek') from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfWeek()); @@ -281,7 +269,6 @@ public void testDateTimeExtract() throws DDFException { // Support date type dt = new DateTime(new java.sql.Date(1433386800 * 1000L)); - System.out.println(dt.toString("yyyy-MM-dd HH:mm:ss")); ddf3 = ddf.sql2ddf("select extract(to_date(from_unixtime(1433386800)), 'year') from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getYear()); @@ -316,7 +303,6 @@ public void testDateTimeExtract() throws DDFException { ddf3 = ddf.sql2ddf("select extract(to_date(from_unixtime(1433386800)), 'hour') from @this"); rows = ddf3.VIEWS.head(1); - System.out.println(rows.get(0)); Assert.assertTrue(Integer.parseInt(rows.get(0))== 0); ddf3 = ddf.sql2ddf("select extract(to_date(from_unixtime(1433386800)), 'minute') from @this"); @@ -425,10 +411,6 @@ public void testIndividualDateTimeExtractUDFs() throws DDFException { rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0)) == dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select dayofmonth('2015-01-22 20:23 +0000') from @this"); - rows = ddf3.VIEWS.head(1); - Assert.assertTrue(Integer.parseInt(rows.get(0)) == dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select dayofweek('2015-01-22 20:23 +0000') from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0)) == dt.getDayOfWeek()); @@ -515,10 +497,6 @@ public void testIndividualDateTimeExtractUDFs() throws DDFException { rows = ddf3.VIEWS.head(1); Assert.assertTrue(rows.get(0).equalsIgnoreCase(dt.dayOfWeek().getAsShortText())); - ddf3 = ddf.sql2ddf("select dayofmonth(1433386800) from @this"); - rows = ddf3.VIEWS.head(1); - Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select dayofweek(1433386800) from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfWeek()); @@ -581,10 +559,6 @@ public void testIndividualDateTimeExtractUDFs() throws DDFException { rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select dayofmonth(4147483647) from @this"); - rows = ddf3.VIEWS.head(1); - Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfMonth()); - ddf3 = ddf.sql2ddf("select dayofweek(4147483647) from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getDayOfWeek()); @@ -623,7 +597,6 @@ public void testIndividualDateTimeExtractUDFs() throws DDFException { // Support date type dt = new DateTime(new java.sql.Date(1433386800 * 1000L)); - System.out.println(dt.toString("yyyy-MM-dd HH:mm:ss")); ddf3 = ddf.sql2ddf("select year(to_date(from_unixtime(1433386800))) from @this"); rows = ddf3.VIEWS.head(1); Assert.assertTrue(Integer.parseInt(rows.get(0))== dt.getYear()); @@ -682,7 +655,6 @@ public void testIndividualDateTimeExtractUDFs() throws DDFException { ddf3 = ddf.sql2ddf("select hour(to_date(from_unixtime(1433386800))) from @this"); rows = ddf3.VIEWS.head(1); - System.out.println(rows.get(0)); Assert.assertTrue(Integer.parseInt(rows.get(0))== 0); ddf3 = ddf.sql2ddf("select minute(to_date(from_unixtime(1433386800))) from @this");