julianhyde commented on code in PR #3947:
URL: https://github.com/apache/calcite/pull/3947#discussion_r1744667636


##########
core/src/main/java/org/apache/calcite/util/rtti/RuntimeTypeInformation.java:
##########
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.util.rtti;
+
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.linq4j.tree.Expressions;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+
+import java.util.AbstractMap;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * This class represents the type of a SQL expression at runtime.
+ * Normally SQL is a statically-typed language, and there is no need for
+ * runtime-type information.  However, the VARIANT data type is actually
+ * a dynamically-typed value, and needs this kind of information.
+ * We cannot use the very similar RelDataType type since it carries extra
+ * baggage, like the type system, which is not available at runtime. */
+public abstract class RuntimeTypeInformation {
+  /** Names of SQL types as represented at runtime. */
+  public enum RuntimeSqlTypeName {
+    BOOLEAN(false),
+    TINYINT(false),
+    SMALLINT(false),
+    INTEGER(false),
+    BIGINT(false),
+    DECIMAL(false),
+    FLOAT(false),
+    REAL(false),
+    DOUBLE(false),
+    DATE(false),
+    TIME(false),
+    TIME_WITH_LOCAL_TIME_ZONE(false),
+    TIME_TZ(false),
+    TIMESTAMP(false),
+    TIMESTAMP_WITH_LOCAL_TIME_ZONE(false),
+    TIMESTAMP_TZ(false),
+    INTERVAL_LONG(false),
+    INTERVAL_SHORT(false),
+    CHAR(false),
+    VARCHAR(false),
+    BINARY(false),
+    VARBINARY(false),
+    NULL(false),
+    MULTISET(true),
+    ARRAY(true),
+    MAP(true),
+    ROW(true),
+    GEOMETRY(false),
+    // used only for VARIANT.null value
+    VARIANT(false);
+
+    private final boolean composite;
+
+    RuntimeSqlTypeName(boolean composite) {
+      this.composite = composite;
+    }
+
+    public boolean isScalar() {
+      return !this.composite;
+    }
+  }
+
+  final RuntimeSqlTypeName typeName;
+
+  protected RuntimeTypeInformation(RuntimeSqlTypeName typeName) {
+    this.typeName = typeName;
+  }
+
+  public abstract String getTypeString();
+
+  public RuntimeSqlTypeName getTypeName() {
+    return this.typeName;
+  }
+
+  public boolean isScalar() {
+    return this.typeName.isScalar();
+  }
+
+  /**
+   * Create and return an expression that creates a runtime type that

Review Comment:
   ... and generally, please follow the best practice of using third-person 
indicative for method javadoc.



-- 
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]

Reply via email to