Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-56164

Analytics DATE_TRUNC_STR returns null for WEEK, DAY_OF_WEEK, DAY_OF_YEAR, TIMEZONE, TIMEZONE_HOUR, TIMEZONE_MINUTE

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Major
    • Morpheus
    • 7.1.0
    • analytics
    • 0

    Description

      https://forums.couchbase.com/t/date-trunc-str-with-week-not-working-in-analytics-query/35794

      https://github.com/couchbase/cbas-core/blob/54f1f3c8cd584c92ec5a4ccb65f38ab2e8ccd68c/cbas/cbas-connector/src/main/java/com/couchbase/analytics/functions/temporal/DateComponent.java#L317

         boolean trunc(boolean typeWithTimezone, long chrononIn, int timeZoneOffset, TimeZone timeZone,
                  AMutableInt64 chrononOut, AMutableInt32 timeZoneOffsetOut, TimeZoneHelper tzHelper) {
              GregorianCalendarSystem cal = GregorianCalendarSystem.getInstance();
              long chrononInAtTz = typeWithTimezone ? cal.adjustChrononByTimezone(chrononIn, timeZoneOffset) : chrononIn;
       
              int year = cal.getYear(chrononInAtTz);
              int month = cal.getMonthOfYear(chrononInAtTz, year);
              int day = cal.getDayOfMonthYear(chrononInAtTz, year, month);
              int hour = cal.getHourOfDay(chrononInAtTz);
              int minute = cal.getMinOfHour(chrononInAtTz);
              int second = cal.getSecOfMin(chrononInAtTz);
              int millis = cal.getMillisOfSec(chrononInAtTz);
       
              switch (this) {
                  case MILLENNIUM:
                  case CENTURY:
                  case DECADE:
                      int y = monthsDuration / GregorianCalendarSystem.MONTHS_IN_A_YEAR;
                      year = year / y * y;
                      // fall thru to 'YEAR'
                  case YEAR:
                      month = 1;
                      // fall thru to 'QUARTER'
                  case QUARTER:
                      month = ((month - 1) / QUARTER.monthsDuration * QUARTER.monthsDuration) + 1;
                      // fall thru to 'MONTH'
                  case MONTH:
                      day = 1;
                      // fall thru to 'DAY'
                  case DAY:
                      hour = 0;
                      // fall thru to 'HOUR'
                  case HOUR:
                      minute = 0;
                      // fall thru to 'MINUTE'
                  case MINUTE:
                      second = 0;
                      // fall thru to 'SECOND'
                  case SECOND:
                      millis = 0;
                      // fall thru to 'MILLISECOND'
                  case MILLISECOND:
                      break;
       
                  case WEEK:
                  case DAY_OF_YEAR:
                  case DAY_OF_WEEK:
                  case TIMEZONE:
                  case TIMEZONE_HOUR:
                  case TIMEZONE_MINUTE:
                  default:
                      return false;
              }   
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Hussain.Towaileb Hussain Towaileb
              michael.reiche Michael Reiche
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty