Vladimir Sitnikov created CALCITE-2489:
------------------------------------------

             Summary: Order of fields in JavaTypeFactoryImpl#createStructType 
is unstable
                 Key: CALCITE-2489
                 URL: https://issues.apache.org/jira/browse/CALCITE-2489
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.17.0
            Reporter: Vladimir Sitnikov
            Assignee: Julian Hyde


{{JavaTypeFactoryImpl#createStructType}} relies on 
{{java.lang.Class#getFields}} to get public fields, however it does not sort 
elements.

That might produce confusing results since Calcite relies on field order.
That might result in flaky tests as well (as execution plans rely on field 
order).

There are other {{#getFields}} usages.
For instance: {{org.apache.calcite.rel.type.RelDataTypeFactoryImpl#fieldsOf}}, 
{{org.apache.calcite.interpreter.TableScanNode#createQueryable}}, etc.

It looks like we should implement Calcite-specific sort of the fields, and 
avoid adding new usages {{getFields}} to Calcite code.

For instance:
a) We might want to sort the fields from the super class to derived class. That 
is derived fields should come after the fields of a base class.
b) When annotation is missing, we might want to sort fields on field 
names/field types (so the order is consistent)
c) Add field-level annotation {{@CalciteField(int order)}}
d) We might want to exclude certain fields by flagging with annotation as well 
(e.g. {{@CalciteField(exclude=true)}}

Note: {{a}} and {{b}} are enough to get consistent field order.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to