cgivre commented on code in PR #2689: URL: https://github.com/apache/drill/pull/2689#discussion_r1005766201
########## contrib/udfs/src/main/java/org/apache/drill/exec/udfs/DateFunctions.java: ########## @@ -140,8 +143,77 @@ public void eval() { java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern(format); java.time.LocalDateTime dateTime = java.time.LocalDateTime.parse(inputDate, formatter); - java.time.LocalDateTime td = org.apache.drill.exec.udfs.NearestDateUtils.getDate(dateTime, intervalString); + java.time.LocalDateTime td = DateConversionUtils.getDate(dateTime, intervalString); out.value = td.atZone(java.time.ZoneId.of("UTC")).toInstant().toEpochMilli(); } } + + @FunctionTemplate(names = {"yearweek","year_week"}, + scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) + public static class YearWeekFunction implements DrillSimpleFunc { + @Param + VarCharHolder inputHolder; + + @Output + IntHolder out; + + @Override + public void setup() { + // noop + } + + @Override + public void eval() { + String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(inputHolder.start, inputHolder.end, inputHolder.buffer); + java.time.LocalDateTime dt = org.apache.drill.exec.udfs.DateUtilFunctions.getTimestampFromString(input); + int week = dt.get(java.time.temporal.IsoFields.WEEK_OF_WEEK_BASED_YEAR); + int year = dt.getYear(); + out.value = (year * 100) + week; + } + } + + @FunctionTemplate(names = {"yearweek","year_week"}, Review Comment: Basically, what I was hoping to do was follow this as a guide: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html. Many of these functions have Drill equivalents so I'm not going to bother with that. But a lot don't... -- 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: dev-unsubscr...@drill.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org