AMashenkov commented on code in PR #1623:
URL: https://github.com/apache/ignite-3/pull/1623#discussion_r1105749328
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/type/IgniteTypeFactory.java:
##########
@@ -353,14 +419,70 @@ public Charset getDefaultCharset() {
return super.toSql(type);
}
+ /** {@inheritDoc} **/
+ @Override
+ public RelDataType createTypeWithNullability(RelDataType type, boolean
nullable) {
+ if (type instanceof IgniteCustomType) {
+ return canonize(((IgniteCustomType)
type).createWithNullability(nullable));
+ } else {
+ return super.createTypeWithNullability(type, nullable);
+ }
+ }
+
/** {@inheritDoc} */
@Override public RelDataType createType(Type type) {
if (type == Duration.class || type == Period.class || type ==
LocalDate.class || type == LocalDateTime.class
|| type == LocalTime.class) {
return createJavaType((Class<?>) type);
+ } else if (customDataTypes.javaTypes.contains(type)) {
+ throw new IllegalArgumentException("Custom data type should not be
created via createType call: " + type);
+ } else {
+ return super.createType(type);
+ }
+ }
+
+ /** {@inheritDoc} **/
+ @Override
+ public RelDataType createJavaType(Class clazz) {
+ if (customDataTypes.javaTypes.contains(clazz)) {
+ throw new IllegalArgumentException("Custom data type should not be
created via createJavaType call: " + clazz);
+ } else {
+ return super.createJavaType(clazz);
+ }
+ }
+
+ /**
+ * Creates a custom data type with the given {@code typeName} and
precision.
+ *
+ * @param typeName type name.
+ * @param precision precision if supported.
+ * @return a custom data type.
+ */
+ public RelDataType createCustomType(String typeName, int precision) {
+ MakeCustomType makeCustomType =
customDataTypes.typeConstructors.get(typeName);
+ if (makeCustomType == null) {
+ throw new IllegalArgumentException("Unexpected custom data type: "
+ typeName);
}
- return super.createType(type);
+ // By default a type must not be nullable.
+ // See SqlTypeFactory::createSqlType.
+ //
+ // Set nullable to false and uncomment the assertion when
https://issues.apache.org/jira/browse/IGNITE-18753
Review Comment:
It will be better to refer to Ignite ticket in TODO.
Here is a ticket "IGNITE-18752: Sql. Bump calcite version to 1.33.0"
https://issues.apache.org/jira/browse/IGNITE-18752
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]