Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
Description
Method {{SqlTypeUtil#equalSansNullability(RelDataTypeFactory, RelDataType, RelDataType) is on the hot path for many scenarios, as it compare types with nullability ignored.
In the implementation, the expensive operations are RelDataType#equals(Object) and RelDataTypeFactory#createTypeWithNullability, especially for types with multiple sub-fields.
For the current implementation, the RelDataType#equals(Object) is called at least once, and RelDataTypeFactory#createTypeWithNullability is called whenever the nullability values are different.
We can improve the implementation so that RelDataType#equals(Object) is called exactly once, and the call to RelDataTypeFactory#createTypeWithNullability can be avoided if the types are totally different (with different type names, and nullability values)
if (type1.isNullable() == type2.isNullable()) { return type1.equals(type2); } else { return type1.equals( factory.createTypeWithNullability(type2, type1.isNullable())); }
Attachments
Issue Links
- links to