apache / apache/beam

Create and use an extension of JavaTypeFactoryImpl.

Open
#20,832 0 comments 0 reactions 0 assignees View on GitHub
dsl P3 sql wish
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

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] [https://github.com/apache/beam/blob/54934dce5b439e3f9f83ef84ac32e38b3d318158/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java#L291-L294](https://github.com/apache/beam/blob/54934dce5b439e3f9f83ef84ac32e38b3d318158/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java#L291-L294)

 

[2] [https://github.com/apache/calcite/blob/350802b59fa68ef1ee074b78af17bf1b2c435e13/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java#L145](https://github.com/apache/calcite/blob/350802b59fa68ef1ee074b78af17bf1b2c435e13/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java#L145)

[3] [https://github.com/apache/calcite/blob/350802b59fa68ef1ee074b78af17bf1b2c435e13/core/src/main/java/org/apache/calcite/jdbc/Driver.java#L171-L185](https://github.com/apache/calcite/blob/350802b59fa68ef1ee074b78af17bf1b2c435e13/core/src/main/java/org/apache/calcite/jdbc/Driver.java#L171-L185)

[4] [https://github.com/apache/calcite/blob/350802b59fa68ef1ee074b78af17bf1b2c435e13/core/src/main/java/org/apache/calcite/jdbc/Driver.java#L91-L157](https://github.com/apache/calcite/blob/350802b59fa68ef1ee074b78af17bf1b2c435e13/core/src/main/java/org/apache/calcite/jdbc/Driver.java#L91-L157)

 

Imported from Jira [BEAM-12274](https://issues.apache.org/jira/browse/BEAM-12274). Original Jira may contain additional context.
Reported by: ibzib.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.