-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
We rely on CalciteUtils.sqlTypeWithAutoCast [1] to handle certain type mappings (Java -> Calcite) that Calcite doesn't know about. Instead of relying on sqlTypeWithAutoCast, we should have our own type factory with these mappings, so we don't have to make sure sqlTypeWithAutoCast is called everywhere (otherwise, it could result in subtle typing bugs).
Once a type factory was implemented, however, it would be difficult to plug in because of the way connections are initialized. Currently the type factory is initialized to a default [2]. Some methods have an argument for the type factory in Driver [3], but they are not public. And some necessary logic [4] can't just be copied verbatim into Beam, since it depends on CalciteConnectionImpl, which is also not public. So we'd probably have to create a root schema as well as a type factory.
[1]
Lines 291 to 294 in 54934dc
| if (type instanceof Class && AbstractInstant.class.isAssignableFrom((Class<?>) type)) { | |
| return typeFactory.createJavaType(Date.class); | |
| } else if (type instanceof Class && ByteString.class.isAssignableFrom((Class<?>) type)) { | |
| return typeFactory.createJavaType(byte[].class); |
Imported from Jira BEAM-12274. Original Jira may contain additional context.
Reported by: ibzib.