File tree Expand file tree Collapse file tree
main/java/com/blazebit/query/impl/calcite
test/java/com/blazebit/query/impl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616import org .apache .calcite .jdbc .CalcitePrepare ;
1717import org .apache .calcite .jdbc .CalciteSchema ;
1818import org .apache .calcite .jdbc .Driver ;
19- import org .apache .calcite .jdbc .JavaTypeFactoryImpl ;
2019import org .apache .calcite .plan .Convention ;
2120import org .apache .calcite .plan .RelOptCluster ;
2221import org .apache .calcite .plan .RelOptPlanner ;
@@ -72,7 +71,7 @@ public boolean shouldConvertRaggedUnionTypesToVarying() {
7271 }
7372 };
7473 }
75- this .typeFactory = new JavaTypeFactoryImpl ( typeSystem );
74+ this .typeFactory = new CustomJavaTypeFactory ( typeSystem );
7675 this .rootSchema = CalciteSchema .createRootSchema ( true );
7776 }
7877
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Blazebit
4+ */
5+ package com .blazebit .query .impl .calcite ;
6+
7+ import org .apache .calcite .jdbc .JavaTypeFactoryImpl ;
8+ import org .apache .calcite .rel .type .RelDataType ;
9+ import org .apache .calcite .rel .type .RelDataTypeSystem ;
10+ import org .apache .calcite .sql .type .BasicSqlType ;
11+ import org .apache .calcite .sql .type .SqlTypeName ;
12+
13+ import java .lang .reflect .Type ;
14+
15+ public class CustomJavaTypeFactory extends JavaTypeFactoryImpl {
16+
17+ public CustomJavaTypeFactory (RelDataTypeSystem typeSystem ) {
18+ super ( typeSystem );
19+ }
20+
21+ @ Override
22+ public Type getJavaClass (RelDataType type ) {
23+ if ( type instanceof BasicSqlType basicSqlType && basicSqlType .getSqlTypeName ().equals ( SqlTypeName .UUID ) ) {
24+ return java .util .UUID .class ;
25+ }
26+
27+ return super .getJavaClass ( type );
28+ }
29+ }
Original file line number Diff line number Diff line change 1919import java .util .HashMap ;
2020import java .util .List ;
2121import java .util .Map ;
22+ import java .util .UUID ;
2223import java .util .function .Supplier ;
2324
2425import com .blazebit .query .QuerySession ;
@@ -62,6 +63,7 @@ public class DataFetcherTable<T> extends AbstractTable implements ScannableTable
6263 javaTypeMappings .put ( ZonedDateTime .class , SqlTypeName .TIMESTAMP );
6364 javaTypeMappings .put ( OffsetDateTime .class , SqlTypeName .TIMESTAMP );
6465 javaTypeMappings .put ( LocalDateTime .class , SqlTypeName .TIMESTAMP );
66+ javaTypeMappings .put ( UUID .class , SqlTypeName .UUID );
6567 javaTypeMappings .put ( LocalDate .class , SqlTypeName .DATE );
6668 javaTypeMappings .put ( OffsetTime .class , SqlTypeName .TIME );
6769 javaTypeMappings .put ( LocalTime .class , SqlTypeName .TIME );
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ public List<Model> fetch(DataFetchContext context) {
109109 " and m.theDuration = interval '1 9:8:7.123456' day to second" +
110110// " and m.theDuration = interval '1 9:8:7.123456789' day to second" +
111111 " and m.thePeriod = interval '1-5' year to month" +
112- // " and m.theUuid = uuid '53886a8a-7082-4879-b430-25cb94415be8'" +
112+ " and m.theUuid = uuid '53886a8a-7082-4879-b430-25cb94415be8'" +
113113 " and m.theEnum = 'VALUE1'" +
114114 " and m.theCustomEnum = 'VALUE1'"
115115 );
You can’t perform that action at this time.
0 commit comments