Skip to content

[FEATURE] Calcite Engine Framework: Date/Time/Timestamp type handling #3341

Closed
@LantaoJin

Description

@LantaoJin

Is your feature request related to a problem?
Calcite uses Linq4j enumerator to execute the Java codegen code. The code generated Java code contains Java type factory to map calcite type to Java type, Ref https://github.com/apache/calcite/blob/130c8dcacd2a2e8e44aa37c3832db063af66dd0f/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java#L173.

For Date/Time/Timestamp types, the generated Java code is Long. But in OpenSearch Date type, it could contain multiple formats, such as strict_date_time_no_millis || strict_date_optional_time || epoch_millis, ref https://opensearch.org/docs/latest/field-types/supported-field-types/date/#default-format. It means the data fetched from OpenSearch could be "2019-03-23T21:34:46-04:00" or 1553391286000.

Now calcite doesn't provide an interface to override its default JavaTypeFactoryImpl, which leads to any OpenSearch date type data (whatever "2019-03-23T21:34:46-04:00" or 1553391286000) have to cast to Long.

What solution would you like?
There are three options

  1. Add an interface to override the default JavaTypeFactoryImpl in Calcite (PR for Calcite)
  2. Classpath Override (Shadow/Shade)
  3. Convert to string by default and add a custom DateString in plan

What alternatives have you considered?
A clear and concise description of any alternative solutions or features you've considered.

Do you have any additional context?
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcalcitecalcite migration releated

Type

No type

Projects

Status

Not Started

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions