-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor IDataType with Generic Type constraint #247
Comments
Yes i think this is great. |
Sound good. MySQL is using the same of mechanism. |
UpdatedWe found significant performance downgrade at least in JDBC interface, and I will do some profile in next couple days to determine the most expensive time cost process. An alternative approach is abandon single root Generic Type constraint on IDataType but spilt it into several primitive interfaces to avoid box/unbox overhead, I will open another GH-ISSUE to talk this. |
Background
IDataType
is the bridge between ClickHouse type system and JDBC type system, and we find there are some limitations in current implementation, the most important one I think is the lack of Generic Type constraint. Without this constraint,serializeBinary
can only acceptObject
, anddeserializeBinary
can only returnObject
, which causes all static type checks lose effectiveness.The root cause here is that JDBC type and ClickHouse type are not a 1:1 mapping, and we mixed the
UIntX
andIntX
in oneDataTypeIntX
make things worse. Because Java Generic Type system not support MixIn(or Hybrid) Type constraint,Object
is the only option.Another thing is that we found some JDBC-GUI Tools like DataGrip will call
ResultSet#getString
to render the value and display it. The temporary solution in codebase is roughly returnobject#toString
.Based on above, I think we need to refactor
IDataType
.Proposal
IDataType
type and JDBC type;IDataType
with the property Java type, i.e.DateTime
map toDataTypeDateTime
(ZonedDateTime
);IDataType
and JDBC interface type, thusDataTypeDateTime
(ZonedDateTime
) can map tojava.sql.Date
,Timestamp
,Calendar
;DataTypeIntX
intoDataTypeUIntX
andDataTypeIntX
;String
for display inIDataType
.After this, it will be easier to implement features like #265.
Consider this change is a bit large, it will not included in release v2.5.0.
@sundy-li @sbouchex Please let me know what you guys thinking of this proposal.
Updated
This proposal has been almost implemented in #295, and the followup PR will coming soon.
The text was updated successfully, but these errors were encountered: