Laurent Goujon commented on CALCITE-1442:

The issue surfaced when testing a change in Drill in the view system, where the 
schema is serialized/deserialized and during deserialization the types are not 
matching anymore:

Maybe this method is doing the right thing, but why then:
- the name of the method starts with {{getFractionalSecondPrecision}}?
- {{getFractionalSecondPrecision(RelDataTypeSystem)}} returns 
{{fractionalSecondPrecision}}, and not {{startPrecision}}
- what's the difference then with {{getStartPrecisionPreservingDefault()}}?

The two places where I saw this method used is in Drill, and in static method 
{{combineFractionalSecondPrecisionPreservingDefault}}, where this method is 
used to combine {{IntervalSqlType}} instances, by storing the result into the 
field fracPrec.

So from the look of it, everything seems to believe this method is supposed to 
return the fractional second precision.

I'm willing to add a test case, but I'm not sure which kind (also calcite 
didn't fail with my patch so I guess it means there's no existing test 
depending on that behaviour)?

> SqlIntervalQualifer#getFractionalSecondPrecisionPreservingDefault() returns 
> the wrong field
> -------------------------------------------------------------------------------------------
>                 Key: CALCITE-1442
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1442
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Laurent Goujon
>            Assignee: Julian Hyde
>            Priority: Minor
> Unless I'm wrong, I believe 
> {{SqlIntervalQualifer#getFractionalSecondPrecisionPreservingDefault()}} 
> returns the wrong field:
> {code:java}
>   public int getFractionalSecondPrecision(RelDataTypeSystem typeSystem) {
>     if (fractionalSecondPrecision == RelDataType.PRECISION_NOT_SPECIFIED) {
>       return typeName().getDefaultScale();
>     } else {
>       return fractionalSecondPrecision;
>     }
>   }
>   public int getFractionalSecondPrecisionPreservingDefault() {
>     if (useDefaultFractionalSecondPrecision()) {
>       return RelDataType.PRECISION_NOT_SPECIFIED;
>     } else {
>       return startPrecision;
>     }
>   }
> {code}

This message was sent by Atlassian JIRA

Reply via email to