private boolean compareFieldTypes(RelDataType outputFieldType, SqlFieldSchema sqlFieldSchema,
      RelDataType selectQueryFieldType, RelSchemaProvider outputRelSchemaProvider) {

    SqlTypeName outputSqlType = outputFieldType.getSqlTypeName();
    SqlTypeName projectSqlType = selectQueryFieldType.getSqlTypeName();

    if (projectSqlType == SqlTypeName.ANY || outputSqlType == SqlTypeName.ANY) {
      return true;
    } else if (outputSqlType != SqlTypeName.ROW && outputSqlType == projectSqlType) {
      return true;
    }

    switch (outputSqlType) {
      case CHAR:
        return projectSqlType == SqlTypeName.VARCHAR;
      case VARCHAR:
        return projectSqlType == SqlTypeName.CHAR;
      case BIGINT:
        return projectSqlType == SqlTypeName.INTEGER;
      case INTEGER:
        return projectSqlType == SqlTypeName.BIGINT;
      case FLOAT:
        return projectSqlType == SqlTypeName.DOUBLE;
      case DOUBLE:
        return projectSqlType == SqlTypeName.FLOAT;
      case ROW:
        try {
          validateOutputRecords(sqlFieldSchema.getRowSchema(), (RelRecordType) outputFieldType,
              (RelRecordType) selectQueryFieldType, outputRelSchemaProvider);
        } catch (SamzaSqlValidatorException e) {
          LOG.error("A field in select query does not match with the output schema.", e);
          return false;
        }
        return true;
      default:
        return false;
    }
  }
Determine if validation needs to be done on Calcite plan based on the schema provider and schema converter.
@param relRoot
@param sink
@param outputSchemaProvider
@param ouputRelSchemaConverter
@return if the validation needs to be skipped
samza-sql/src/main/java/org/apache/samza/sql/planner/SamzaSqlValidator.java