You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (JIRA)" <ji...@apache.org> on 2018/08/27 07:27:00 UTC

[jira] [Created] (CALCITE-2489) Order of fields in JavaTypeFactoryImpl#createStructType is unstable

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)