Details
-
Bug
-
Status: In Progress
-
Major
-
Resolution: Unresolved
-
1.17.0
-
None
Description
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.
Attachments
Issue Links
- is related to
-
CALCITE-4503 Order of fields in records should follow that of the SQL types
- Closed
- links to