Skip to content

Commit

Permalink
remove dayofmonth UDF; remove println statements
Browse files Browse the repository at this point in the history
Change-Id: If7a922bd403168da79d755a797b00b5d3bffd8a8
  • Loading branch information
nhanitvn committed Mar 7, 2016
1 parent 6a98400 commit 1c38c95
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion spark/src/main/scala/io/ddf/spark/etl/DateUDFs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 0 additions & 28 deletions spark/src/test/java/io/ddf/spark/etl/UDFTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 1c38c95

Please sign in to comment.