This is an automated email from the ASF dual-hosted git repository.

danny0405 pushed a commit to branch cosmetic-change
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 56b51632476b682eefe1d07c33307ccc252a9462
Author: yuzhao.cyz <[email protected]>
AuthorDate: Mon Oct 28 15:51:42 2019 +0800

    Cosmetic changes
---
 .../org/apache/calcite/schema/ColumnStrategy.java    |  3 ++-
 .../org/apache/calcite/sql/SqlBasicTypeNameSpec.java | 15 ++++++++-------
 .../calcite/sql/SqlCollectionTypeNameSpec.java       | 20 +++++++++++---------
 .../org/apache/calcite/sql/SqlRowTypeNameSpec.java   | 11 ++++++-----
 .../java/org/apache/calcite/sql/SqlTypeNameSpec.java |  9 +++++----
 .../calcite/sql/SqlUserDefinedTypeNameSpec.java      |  5 +++--
 .../main/java/org/apache/calcite/sql/SqlUtil.java    |  1 +
 .../apache/calcite/sql/validate/SqlValidator.java    | 19 +++++++++++--------
 .../calcite/sql/validate/SqlValidatorImpl.java       |  3 ++-
 .../calcite/sql/validate/SqlValidatorUtil.java       |  2 +-
 .../sql/validate/implicit/AbstractTypeCoercion.java  | 16 ++++++++--------
 .../calcite/sql/validate/implicit/TypeCoercion.java  |  1 +
 .../sql/validate/implicit/TypeCoercionImpl.java      |  3 ++-
 .../org/apache/calcite/test/TypeCoercionTest.java    |  2 +-
 14 files changed, 62 insertions(+), 48 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/schema/ColumnStrategy.java 
b/core/src/main/java/org/apache/calcite/schema/ColumnStrategy.java
index 1f633b8..e77da37 100644
--- a/core/src/main/java/org/apache/calcite/schema/ColumnStrategy.java
+++ b/core/src/main/java/org/apache/calcite/schema/ColumnStrategy.java
@@ -40,7 +40,8 @@ public enum ColumnStrategy {
 
   /**
    * Returns whether you can insert into the column.
-   * @return true if this column can be inserted.
+   *
+   * @return true if this column can be inserted
    */
   public boolean canInsertInto() {
     return this != STORED && this != VIRTUAL;
diff --git 
a/core/src/main/java/org/apache/calcite/sql/SqlBasicTypeNameSpec.java 
b/core/src/main/java/org/apache/calcite/sql/SqlBasicTypeNameSpec.java
index 8b8f1b3..11318a5 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlBasicTypeNameSpec.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlBasicTypeNameSpec.java
@@ -80,12 +80,13 @@ public class SqlBasicTypeNameSpec extends SqlTypeNameSpec {
 
   /**
    * Create a basic sql type name specification.
-   * @param typeName    Type name.
-   * @param precision   Precision of the type name if it is allowed, default 
is -1.
-   * @param scale       Scale of the type name if it is allowed, default is -1.
+   *
+   * @param typeName    Type name
+   * @param precision   Precision of the type name if it is allowed, default 
is -1
+   * @param scale       Scale of the type name if it is allowed, default is -1
    * @param charSetName Char set of the type, only works when the type
-   *                    belong to CHARACTER type family.
-   * @param pos         The parser position.
+   *                    belong to CHARACTER type family
+   * @param pos         The parser position
    */
   public SqlBasicTypeNameSpec(
       SqlTypeName typeName,
@@ -249,8 +250,8 @@ public class SqlBasicTypeNameSpec extends SqlTypeNameSpec {
   /**
    * Remove the local time zone definition of the {@code typeName}.
    *
-   * @param typeName Type name.
-   * @return new type name without local time zone definition.
+   * @param typeName Type name
+   * @return new type name without local time zone definition
    */
   private SqlTypeName stripLocalTimeZoneDef(SqlTypeName typeName) {
     switch (typeName) {
diff --git 
a/core/src/main/java/org/apache/calcite/sql/SqlCollectionTypeNameSpec.java 
b/core/src/main/java/org/apache/calcite/sql/SqlCollectionTypeNameSpec.java
index c657b97..155c661 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlCollectionTypeNameSpec.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlCollectionTypeNameSpec.java
@@ -49,9 +49,10 @@ import java.util.Objects;
  *   &lt;data type&gt; MULTISET
  * </pre></blockquote>
  *
- * <p>This class is intended to be used in nested collection type, it can be 
used as the
- * element type name of {@link SqlDataTypeSpec}. i.e. "int array array" or 
"int array multiset".
- * For simple collection type like "int array", {@link SqlBasicTypeNameSpec} 
is descriptive enough.
+ * <p>This class is intended to describe SQL collection type. It can describe
+ * either simple collection type like "int array" or nested collection type 
like
+ * "int array array" or "int array multiset". For nested collection type, the 
element type
+ * name of this {@code SqlCollectionTypeNameSpec} is also a {@code 
SqlCollectionTypeNameSpec}.
  */
 public class SqlCollectionTypeNameSpec extends SqlTypeNameSpec {
   private final SqlTypeNameSpec elementTypeName;
@@ -60,9 +61,9 @@ public class SqlCollectionTypeNameSpec extends 
SqlTypeNameSpec {
   /**
    * Creates a {@code SqlCollectionTypeNameSpec}.
    *
-   * @param elementTypeName    Type of the collection element.
-   * @param collectionTypeName Collection type name.
-   * @param pos                Parser position, must not be null.
+   * @param elementTypeName    Type of the collection element
+   * @param collectionTypeName Collection type name
+   * @param pos                Parser position, must not be null
    */
   public SqlCollectionTypeNameSpec(SqlTypeNameSpec elementTypeName,
       SqlTypeName collectionTypeName,
@@ -104,10 +105,11 @@ public class SqlCollectionTypeNameSpec extends 
SqlTypeNameSpec {
 
   /**
    * Create collection data type.
-   * @param elementType Type of the collection element.
-   * @param typeFactory Type factory.
+   *
+   * @param elementType Type of the collection element
+   * @param typeFactory Type factory
    * @return The collection data type, or throw exception if the collection
-   *         type name does not belong to {@code SqlTypeName} enumerations.
+   *         type name does not belong to {@code SqlTypeName} enumerations
    */
   private RelDataType createCollectionType(RelDataType elementType,
       RelDataTypeFactory typeFactory) {
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlRowTypeNameSpec.java 
b/core/src/main/java/org/apache/calcite/sql/SqlRowTypeNameSpec.java
index 4eac327..e7807d8 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlRowTypeNameSpec.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlRowTypeNameSpec.java
@@ -45,8 +45,9 @@ import java.util.stream.Collectors;
  *   &lt;field name&gt; &lt;data type&gt;
  * </pre></blockquote>
  *
- * <p>We also support to add a [ NULL | NOT NULL ] suffix for every field 
type, i.e.
- * Row(f0 int null, f1 varchar not null), the default is not nullable.
+ * <p>As a extended syntax to the standard SQL, each field type can have a
+ * [ NULL | NOT NULL ] suffix specification, i.e.
+ * Row(f0 int null, f1 varchar not null). The default is NOT NULL(not 
nullable).
  */
 public class SqlRowTypeNameSpec extends SqlTypeNameSpec {
 
@@ -56,9 +57,9 @@ public class SqlRowTypeNameSpec extends SqlTypeNameSpec {
   /**
    * Creates a row type specification.
    *
-   * @param pos        The parser position.
-   * @param fieldNames The field names.
-   * @param fieldTypes The field data types.
+   * @param pos        The parser position
+   * @param fieldNames The field names
+   * @param fieldTypes The field data types
    */
   public SqlRowTypeNameSpec(
       SqlParserPos pos,
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlTypeNameSpec.java 
b/core/src/main/java/org/apache/calcite/sql/SqlTypeNameSpec.java
index a0be99a..7890d3a 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlTypeNameSpec.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlTypeNameSpec.java
@@ -27,6 +27,7 @@ import org.apache.calcite.util.Litmus;
  *
  * <p>To customize sql node unparsing, override the method
  * {@link #unparse(SqlWriter, int, int)}.
+ *
  * <p>To customize data type deriving, override the method
  * {@link #deriveType(SqlValidator)}.
  */
@@ -37,8 +38,8 @@ public abstract class SqlTypeNameSpec {
   /**
    * Creates a {@code SqlTypeNameSpec}.
    *
-   * @param name Name of the type.
-   * @param pos  Parser position, must not be null.
+   * @param name Name of the type
+   * @param pos  Parser position, must not be null
    */
   public SqlTypeNameSpec(SqlIdentifier name, SqlParserPos pos) {
     this.typeName = name;
@@ -48,9 +49,9 @@ public abstract class SqlTypeNameSpec {
   /**
    * Derive type from this SqlTypeNameSpec.
    *
-   * @param validator The sql validator.
+   * @param validator The sql validator
    * @return the {@code RelDataType} instance, throws exception if we could not
-   *         deduce the type.
+   *         deduce the type
    */
   public abstract RelDataType deriveType(SqlValidator validator);
 
diff --git 
a/core/src/main/java/org/apache/calcite/sql/SqlUserDefinedTypeNameSpec.java 
b/core/src/main/java/org/apache/calcite/sql/SqlUserDefinedTypeNameSpec.java
index 8a6c4ea..c82ff20 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlUserDefinedTypeNameSpec.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlUserDefinedTypeNameSpec.java
@@ -34,8 +34,9 @@ public class SqlUserDefinedTypeNameSpec extends 
SqlTypeNameSpec {
 
   /**
    * Create a SqlUserDefinedTypeNameSpec instance.
-   * @param typeName Type name as SQL identifier.
-   * @param pos The parser position.
+   *
+   * @param typeName Type name as SQL identifier
+   * @param pos The parser position
    */
   public SqlUserDefinedTypeNameSpec(SqlIdentifier typeName, SqlParserPos pos) {
     super(typeName, pos);
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlUtil.java 
b/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
index 8012196..bbd1a6a 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
@@ -315,6 +315,7 @@ public abstract class SqlUtil {
 
   /**
    * Unparse a SqlIdentifier syntax.
+   *
    * @param writer       Writer
    * @param identifier   SqlIdentifier
    * @param asFunctionID Whether this identifier comes from a SqlFunction
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java 
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java
index 981a870..fe44f16 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java
@@ -792,20 +792,23 @@ public interface SqlValidator {
   boolean isLenientOperatorLookup();
 
   /**
-   * Set if implicit type coercion is allowed when the validator does 
validation.
-   * See {@link org.apache.calcite.sql.validate.implicit.TypeCoercionImpl} for 
the details.
-   * @param enabled default as true.
+   * Sets enable or disable implicit type coercion when the validator does 
validation.
+   *
+   * @param enabled if enable the type coercion, default is true
+   *
+   * @see org.apache.calcite.sql.validate.implicit.TypeCoercionImpl 
TypeCoercionImpl
    */
   SqlValidator setEnableTypeCoercion(boolean enabled);
 
-  /** Get if this validator supports implicit type coercion. */
+  /** Returns if this validator supports implicit type coercion. */
   boolean isTypeCoercionEnabled();
 
   /**
-   * Set an instance of type coercion, you can customize the coercion rules to
-   * override the default ones
-   * in {@link org.apache.calcite.sql.validate.implicit.TypeCoercionImpl}.
-   * @param typeCoercion instance of {@link TypeCoercion}.
+   * Sets an instance of type coercion, you can customize the coercion rules to
+   * override the default ones defined in
+   * {@link org.apache.calcite.sql.validate.implicit.TypeCoercionImpl}.
+   *
+   * @param typeCoercion {@link TypeCoercion} instance
    */
   void setTypeCoercion(TypeCoercion typeCoercion);
 
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java 
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index 3540eec..9478384 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -4437,6 +4437,7 @@ public class SqlValidatorImpl implements 
SqlValidatorWithHints {
 
   /**
    * Check the field count of sql insert source and target node row type.
+   *
    * @param node                    target table sql identifier
    * @param table                   target table
    * @param strategies              column strategies of target table
@@ -4447,7 +4448,7 @@ public class SqlValidatorImpl implements 
SqlValidatorWithHints {
    * @param logicalTargetRowType    logical target row type, contains only 
target columns if
    *                                they are specified or if the sql dialect 
allows subset insert,
    *                                make a subset of fields(start from the 
left first field) whose
-   *                                length is equals with the source row type 
fields number.
+   *                                length is equals with the source row type 
fields number
    */
   private void checkFieldCount(SqlNode node, SqlValidatorTable table,
       List<ColumnStrategy> strategies, RelDataType targetRowTypeToValidate,
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java 
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java
index c5d7316..fa96e3e 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java
@@ -1112,7 +1112,7 @@ public class SqlValidatorUtil {
    * @param opTab    operator table to look up
    * @param funName  function name
    * @param funcType function category
-   * @return A sql function if and only if there is one operator matches, else 
null.
+   * @return A sql function if and only if there is one operator matches, else 
null
    */
   public static SqlOperator lookupSqlFunctionByID(SqlOperatorTable opTab,
       SqlIdentifier funName,
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java
 
b/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java
index 16b705d..3070682 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java
@@ -56,12 +56,12 @@ import java.util.Objects;
  * all overridable by derived classes, you can define system specific type 
coercion logic.
  *
  * <p>Caution that these methods may modify the {@link SqlNode} tree, you 
should know what the
- * effect is when using these methods to customize your type coercion 
rules.</p>
+ * effect is when using these methods to customize your type coercion rules.
  *
  * <p>This class also defines the default implementation of the type widening 
strategies, see
  * {@link TypeCoercion} doc and methods: {@link #getTightestCommonType}, 
{@link #getWiderTypeFor},
  * {@link #getWiderTypeForTwo}, {@link #getWiderTypeForDecimal},
- * {@link #commonTypeForBinaryComparison} for the detail strategies.</p>
+ * {@link #commonTypeForBinaryComparison} for the detail strategies.
  */
 public abstract class AbstractTypeCoercion implements TypeCoercion {
   protected SqlValidator validator;
@@ -607,9 +607,9 @@ public abstract class AbstractTypeCoercion implements 
TypeCoercion {
    * We will check the type one by one, that means the 1th type and 1th family,
    * 2th type and 2th family, and the like.
    *
-   * @param types    data type need to check.
-   * @param families desired type families list.
-   * @return true if we can do type coercion.
+   * @param types    data type need to check
+   * @param families desired type families list
+   * @return true if we can do type coercion
    */
   boolean canImplicitTypeCast(List<RelDataType> types, List<SqlTypeFamily> 
families) {
     boolean needed = false;
@@ -635,9 +635,9 @@ public abstract class AbstractTypeCoercion implements 
TypeCoercion {
    * See <a 
href="https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing";>CalciteImplicitCasts</a>
    * for the details.
    *
-   * @param in       inferred operand type.
-   * @param expected expected {@link SqlTypeFamily} of registered SqlFunction.
-   * @return common type of implicit cast, null if we do not find any.
+   * @param in       inferred operand type
+   * @param expected expected {@link SqlTypeFamily} of registered SqlFunction
+   * @return common type of implicit cast, null if we do not find any
    */
   public RelDataType implicitCast(RelDataType in, SqlTypeFamily expected) {
     List<SqlTypeFamily> numericFamilies = ImmutableList.of(
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercion.java 
b/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercion.java
index e6b6cfe..8d9e299 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercion.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercion.java
@@ -43,6 +43,7 @@ import java.util.List;
  * decimal(with default max precision), and yet decimal is more precise than 
double,
  * but in union we would cast the decimal to double).</li>
  * </ul>
+ *
  * <p>REFERENCE: <a 
href="https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-type-conversion-database-engine?";>SQL-SERVER</a>
  * <a 
href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types";>HIVE</a></p>
  */
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
 
b/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
index b5b438d..1800fee 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
@@ -311,7 +311,8 @@ public class TypeCoercionImpl extends AbstractTypeCoercion {
    * Cast "BOOLEAN = NUMERIC" to "NUMERIC = NUMERIC". Expressions like 
1=`expr` and
    * 0=`expr` can be simplified to `expr` and `not expr`, but this better 
happens
    * in {@link org.apache.calcite.rex.RexSimplify}.
-   * There are 2 cases that need type coercion here:
+   *
+   * <p>There are 2 cases that need type coercion here:
    * <ol>
    *   <li>Case1: `boolean expr1` = 1 or `boolean expr1` = 0, replace the 
numeric literal with
    *   `true` or `false` boolean literal.</li>
diff --git a/core/src/test/java/org/apache/calcite/test/TypeCoercionTest.java 
b/core/src/test/java/org/apache/calcite/test/TypeCoercionTest.java
index 25d29ba..acc9e15 100644
--- a/core/src/test/java/org/apache/calcite/test/TypeCoercionTest.java
+++ b/core/src/test/java/org/apache/calcite/test/TypeCoercionTest.java
@@ -415,7 +415,7 @@ public class TypeCoercionTest extends SqlValidatorTestCase {
   }
 
   /** Test case for {@link TypeCoercion#getWiderTypeForTwo}
-   * and {@link TypeCoercion#getWiderTypeFor} */
+   * and {@link TypeCoercion#getWiderTypeFor}. */
   @Test public void testWiderTypeFor() {
     // DECIMAL please see details in 
SqlTypeFactoryImpl#leastRestrictiveSqlType.
     checkWiderType(decimalType(5, 4), decimalType(7, 1), decimalType(10, 4), 
true, true);

Reply via email to