trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] trafodion pull request #1622: [TRAFODION-3118] Improve on parts of EXTRACT
Date Mon, 02 Jul 2018 23:53:39 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1622#discussion_r199651226
  
    --- Diff: core/sql/optimizer/SynthType.cpp ---
    @@ -4470,15 +4489,31 @@ const NAType *Extract::synthesizeType()
       else if (getExtractField() == REC_DATE_YEARWEEK_EXTRACT ||
                getExtractField() == REC_DATE_YEARWEEK_D_EXTRACT)
         prec = 6;					// YEARMWEEK is yyyyww
    +  else if (getExtractField() == REC_DATE_DECADE ||
    +           getExtractField() == REC_DATE_DOY)
    +    prec = 3;
    +  else if (getExtractField() == REC_DATE_QUARTER ||
    +           getExtractField() == REC_DATE_DOW)
    +    prec = 1;
    +  else if (getExtractField() == REC_DATE_EPOCH)
    +    prec = 10;
       else
         prec = 2;					// else max of 12, 31, 24, 59
       if (getExtractField() == REC_DATE_SECOND) {
         prec  += dti.getFractionPrecision();
         scale += dti.getFractionPrecision();
       }
    +  if (getExtractField() == REC_DATE_EPOCH)
    +    {
    +      prec  += dti.getFractionPrecision();
    +      scale += dti.getFractionPrecision();
    +    }
    +  NABoolean bNegValue = FALSE;
    +  if ( getExtractField() >= REC_DATE_CENTURY && extractStartField <= REC_DATE_WOM
)
    +    bNegValue = TRUE;
    --- End diff --
    
    I'm confused. From this code, it looks like all of the new options can yield negative
values. Yet, earlier, for example, QUARTER is limited to a precision of 1. I could imagine
QUARTER being negative if it were with respect to the first quarter of year 1 AD. But since
the precision is 1, I'm guessing that QUARTER is always with respect to the current year,
so it only takes the values 1, 2, 3 or 4. I'm wondering what DECADE, DOM, DOY and WOM are;
what are they relative to? And can they be negative?


---

Mime
View raw message