Print log in case schema doesn't match!.

@param tableInfo
the table info
@param metadata
the metadata
@param value_types
the value_types
@param originalMetadata
the original metadata
@throws CharacterCodingException
the character coding exception
190185
private void onLog(TableInfo tableInfo, CqlMetadata metadata, Map<ByteBuffer, String> value_types,
            CqlMetadata originalMetadata) throws CharacterCodingException
    {
        System.out.format("Persisted Schema for " + tableInfo.getTableName());
        System.out.format("\n");

        System.out.format("Column Name: \t\t  Column name type");
        System.out.format("\n");

        printInfo(originalMetadata);

        System.out.format("\n");
        System.out.format("Mapped schema for " + tableInfo.getTableName());

        System.out.format("\n");
        System.out.format("Column Name: \t\t  Column name type");
        System.out.format("\n");
        printInfo(metadata);
    }
954465
public void setIdentifierMetadata(IdentifierMetadata identifierMetadata) {
    if (this.identifierMetadata != null) {
      String format = "Class %s has at least two fields, %s and %s, marked with %s annotation. "
          + "Only one field can be marked as an identifier. ";
      String message = String.format(format, entityClass.getName(),
          this.identifierMetadata.getName(), identifierMetadata.getName(),
          Identifier.class.getName());
      throw new EntityManagerException(message);
    }
    this.identifierMetadata = identifierMetadata;
  }
324278
protected void descriminateType(
      EntityDesc entityDesc, EntityPropertyDesc propertyDesc, ColumnMeta columnMeta) {
    String defaultClassName = dialect.getMappedPropertyClassName(columnMeta);
    if (Byte.class.getName().equals(defaultClassName)
        || Short.class.getName().equals(defaultClassName)
        || Integer.class.getName().equals(defaultClassName)
        || Long.class.getName().equals(defaultClassName)
        || Float.class.getName().equals(defaultClassName)
        || Double.class.getName().equals(defaultClassName)
        || BigInteger.class.getName().equals(defaultClassName)
        || BigDecimal.class.getName().equals(defaultClassName)
        || byte.class.getName().equals(defaultClassName)
        || short.class.getName().equals(defaultClassName)
        || int.class.getName().equals(defaultClassName)
        || long.class.getName().equals(defaultClassName)
        || float.class.getName().equals(defaultClassName)
        || double.class.getName().equals(defaultClassName)) {
      propertyDesc.setNumber(true);
    } else if (Time.class.getName().equals(defaultClassName)
        || LocalTime.class.getName().equals(defaultClassName)) {
      propertyDesc.setTime(true);
    } else if (Date.class.getName().equals(defaultClassName)
        || LocalDate.class.getName().equals(defaultClassName)) {
      propertyDesc.setDate(true);
    } else if (Timestamp.class.getName().equals(defaultClassName)
        || java.util.Date.class.getName().equals(defaultClassName)
        || LocalDateTime.class.getName().equals(defaultClassName)) {
      propertyDesc.setTimestamp(true);
    }
  }
142175
public void register(String table, String column, Type<?> type) {
        javaTypeMapping.setType(table, column, type);
        hasTableColumnTypes = true;
    }
935591
public void write(RowOutputInterface out,
                      ResultMetaData meta) throws IOException {

        beforeFirst();
        out.writeLong(id);
        out.writeInt(size);
        out.writeInt(0);    // offset
        out.writeInt(size);

        while (hasNext()) {
            Object[] data = getNext();

            out.writeData(meta.getColumnCount(), meta.columnTypes, data, null,
                          null);
        }

        beforeFirst();
    }
930292
static TypeInformation schemaToTypeInfo(TypeDescription schema) {
		switch (schema.getCategory()) {
			case BOOLEAN:
				return BasicTypeInfo.BOOLEAN_TYPE_INFO;
			case BYTE:
				return BasicTypeInfo.BYTE_TYPE_INFO;
			case SHORT:
				return BasicTypeInfo.SHORT_TYPE_INFO;
			case INT:
				return BasicTypeInfo.INT_TYPE_INFO;
			case LONG:
				return BasicTypeInfo.LONG_TYPE_INFO;
			case FLOAT:
				return BasicTypeInfo.FLOAT_TYPE_INFO;
			case DOUBLE:
				return BasicTypeInfo.DOUBLE_TYPE_INFO;
			case DECIMAL:
				return BasicTypeInfo.BIG_DEC_TYPE_INFO;
			case STRING:
			case CHAR:
			case VARCHAR:
				return BasicTypeInfo.STRING_TYPE_INFO;
			case DATE:
				return SqlTimeTypeInfo.DATE;
			case TIMESTAMP:
				return SqlTimeTypeInfo.TIMESTAMP;
			case BINARY:
				return PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
			case STRUCT:
				List<TypeDescription> fieldSchemas = schema.getChildren();
				TypeInformation[] fieldTypes = new TypeInformation[fieldSchemas.size()];
				for (int i = 0; i < fieldSchemas.size(); i++) {
					fieldTypes[i] = schemaToTypeInfo(fieldSchemas.get(i));
				}
				String[] fieldNames = schema.getFieldNames().toArray(new String[]{});
				return new RowTypeInfo(fieldTypes, fieldNames);
			case LIST:
				TypeDescription elementSchema = schema.getChildren().get(0);
				TypeInformation<?> elementType = schemaToTypeInfo(elementSchema);
				// arrays of primitive types are handled as object arrays to support null values
				return ObjectArrayTypeInfo.getInfoFor(elementType);
			case MAP:
				TypeDescription keySchema = schema.getChildren().get(0);
				TypeDescription valSchema = schema.getChildren().get(1);
				TypeInformation<?> keyType = schemaToTypeInfo(keySchema);
				TypeInformation<?> valType = schemaToTypeInfo(valSchema);
				return new MapTypeInfo<>(keyType, valType);
			case UNION:
				throw new UnsupportedOperationException("UNION type is not supported yet.");
			default:
				throw new IllegalArgumentException("Unknown type " + schema);
		}
	}
1307418
public void validate(CFMetaData metadata) {
        for (Map.Entry<String, ColumnMapper> entry : columnMappers.entrySet()) {

            String name = entry.getKey();
            ColumnMapper columnMapper = entry.getValue();
            ByteBuffer columnName = UTF8Type.instance.decompose(name);

            ColumnDefinition columnDefinition = metadata.getColumnDefinition(columnName);
            if (columnDefinition == null) {
                throw new RuntimeException("No column definition for mapper " + name);
            }

            if (columnDefinition.isStatic()) {
                throw new RuntimeException("Lucene indexes are not allowed on static columns as " + name);
            }

            AbstractType<?> type = columnDefinition.type;
            if (!columnMapper.supports(type)) {
                throw new RuntimeException(String.format("Type '%s' is not supported by mapper '%s'", type, name));
            }
        }
    }
1307454
private void alterColumnType(TableInfo tableInfo, CQLTranslator translator, ColumnInfo column) throws Exception
    {
        StringBuilder alterColumnTypeQuery = new StringBuilder("ALTER TABLE ");
        translator.ensureCase(alterColumnTypeQuery, tableInfo.getTableName(), false);
        alterColumnTypeQuery.append(" ALTER ");
        translator.ensureCase(alterColumnTypeQuery, column.getColumnName(), false);
        alterColumnTypeQuery.append(" TYPE "
                + translator.getCQLType(CassandraValidationClassMapper.getValidationClass(column.getType(),
                        isCql3Enabled(tableInfo))));
        cassandra_client.execute_cql3_query(ByteBuffer.wrap(alterColumnTypeQuery.toString().getBytes()),
                Compression.NONE, ConsistencyLevel.ONE);

        KunderaCoreUtils.printQuery(alterColumnTypeQuery.toString(), showQuery);
    }
393092
@Override
    public void characters(char ch[], int start, int length) {
        if (debug) logger.debug(new String(ch, start, length));
        conv.characterData(xpath, ch, start, length);
    }
771795
private void writeMetadata() throws SQLException {
        LOGGER.info("Writing metadata...");
        PreparedStatement pStmtMetadata = this.conn.prepareStatement(DbConstants.INSERT_METADATA_STATEMENT);

        // Bounds
        pStmtMetadata.setString(1, DbConstants.METADATA_BOUNDS);
        BoundingBox bb = this.configuration.getBboxConfiguration();
        if (bb == null) {
            // Calculate bounding box from poi coordinates
            Statement stmt = this.conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT MIN(minLat), MIN(minLon), MAX(maxLat), MAX(maxLon) FROM poi_index;");
            rs.next();
            bb = new BoundingBox(rs.getDouble(1), rs.getDouble(2), rs.getDouble(3), rs.getDouble(4));
        }
        pStmtMetadata.setString(2, bb.minLatitude + "," + bb.minLongitude + "," + bb.maxLatitude + "," + bb.maxLongitude);
        pStmtMetadata.addBatch();

        // Comment
        pStmtMetadata.setString(1, DbConstants.METADATA_COMMENT);
        if (this.configuration.getComment() != null) {
            pStmtMetadata.setString(2, this.configuration.getComment());
        } else {
            pStmtMetadata.setNull(2, Types.NULL);
        }
        pStmtMetadata.addBatch();

        // Date
        pStmtMetadata.setString(1, DbConstants.METADATA_DATE);
        pStmtMetadata.setLong(2, System.currentTimeMillis());
        pStmtMetadata.addBatch();

        // Language
        pStmtMetadata.setString(1, DbConstants.METADATA_LANGUAGE);
        if (!this.configuration.isAllTags() && this.configuration.getPreferredLanguage() != null) {
            pStmtMetadata.setString(2, this.configuration.getPreferredLanguage());
        } else {
            pStmtMetadata.setNull(2, Types.NULL);
        }
        pStmtMetadata.addBatch();

        // Version
        pStmtMetadata.setString(1, DbConstants.METADATA_VERSION);
        pStmtMetadata.setInt(2, this.configuration.getFileSpecificationVersion());
        pStmtMetadata.addBatch();

        // Ways
        pStmtMetadata.setString(1, DbConstants.METADATA_WAYS);
        pStmtMetadata.setString(2, Boolean.toString(this.configuration.isWays()));
        pStmtMetadata.addBatch();

        // Writer
        pStmtMetadata.setString(1, DbConstants.METADATA_WRITER);
        pStmtMetadata.setString(2, this.configuration.getWriterVersion());
        pStmtMetadata.addBatch();

        pStmtMetadata.executeBatch();
        this.conn.commit();
    }
812704
public void init(String tableName, ResultSet columnMetaRs) throws SQLException {
		this.tableName = tableName;

		this.name = columnMetaRs.getString("COLUMN_NAME");
		this.type = columnMetaRs.getInt("DATA_TYPE");
		this.size = columnMetaRs.getInt("COLUMN_SIZE");
		this.isNullable = columnMetaRs.getBoolean("NULLABLE");
		this.comment = columnMetaRs.getString("REMARKS");
	}
1088341
function (tableName, opts) {
            var m = this.outputIdentifierFunc, im = this.inputIdentifierFunc, self = this;
            return this.metadataDataset.withSql("DESCRIBE ?", sql.identifier(im(tableName))).map(function (row) {
                var ret = {};
                var e = row[m("Extra")];
                var allowNull = row[m("Null")];
                var key = row[m("Key")];
                ret.autoIncrement = e.match(/auto_increment/i) !== null;
                ret.allowNull = allowNull.match(/Yes/i) !== null;
                ret.primaryKey = key.match(/PRI/i) !== null;
                var defaultValue = row[m("Default")];
                ret["default"] = Buffer.isBuffer(defaultValue) ? defaultValue.toString() : defaultValue;
                if (isEmpty(row["default"])) {
                    row["default"] = null;
                }
                ret.dbType = row[m("Type")];
                if (Buffer.isBuffer(ret.dbType)) {
                    //handle case for field type being returned at 252  (i.e. BLOB)
                    ret.dbType = ret.dbType.toString();
                }
                ret.type = self.schemaColumnType(ret.dbType.toString("utf8"));
                var fieldName = m(row[m("Field")]);
                return [fieldName, ret];
            });
        }
796713
private static void validate(@NotNull EntityMetadata entityMetadata) {
        if (StringUtils.isEmpty(entityMetadata.getTableName())) {
            throw new MetadataException(String.format("Invalid table name: \"%s\"", entityMetadata.getTableName()));
        }

        if (entityMetadata.getPartitionKeySize() < 1) {
            throw new MetadataException(String.format("Entity \"%s\"must contains primary key", entityMetadata.getTableName()));
        }
    }
511968
public StringBuffer markdown(SchemaMetadata meta, boolean include_input_fields, boolean include_output_fields) {
    MarkdownBuilder builder = new MarkdownBuilder();

    builder.comment("Preview with http://jbt.github.io/markdown-editor");
    builder.heading1("schema ", this.getClass().getSimpleName());
    builder.hline();
    // builder.paragraph(metadata.summary);

    // TODO: refactor with Route.markdown():

    // fields
    boolean first; // don't print the table at all if there are no rows

    try {
      if (include_input_fields) {
        first = true;
        builder.heading2("input fields");

        for (SchemaMetadata.FieldMetadata field_meta : meta.fields) {
          if (field_meta.direction == API.Direction.INPUT || field_meta.direction == API.Direction.INOUT) {
            if (first) {
              builder.tableHeader("name", "required?", "level", "type", "schema?", "schema", "default", "description", "values", "is member of frames", "is mutually exclusive with");
              first = false;
            }
            builder.tableRow(
                field_meta.name,
                String.valueOf(field_meta.required),
                field_meta.level.name(),
                field_meta.type,
                String.valueOf(field_meta.is_schema),
                field_meta.is_schema ? field_meta.schema_name : "", (null == field_meta.value ? "(null)" : field_meta.value.toString()), // Something better for toString()?
                field_meta.help,
                (field_meta.values == null || field_meta.values.length == 0 ? "" : Arrays.toString(field_meta.values)),
                (field_meta.is_member_of_frames == null ? "[]" : Arrays.toString(field_meta.is_member_of_frames)),
                (field_meta.is_mutually_exclusive_with == null ? "[]" : Arrays.toString(field_meta.is_mutually_exclusive_with))
            );
          }
        }
        if (first)
          builder.paragraph("(none)");
      }

      if (include_output_fields) {
        first = true;
        builder.heading2("output fields");
        for (SchemaMetadata.FieldMetadata field_meta : meta.fields) {
          if (field_meta.direction == API.Direction.OUTPUT || field_meta.direction == API.Direction.INOUT) {
            if (first) {
              builder.tableHeader("name", "type", "schema?", "schema", "default", "description", "values", "is member of frames", "is mutually exclusive with");
              first = false;
            }
            builder.tableRow(
                field_meta.name,
                field_meta.type,
                String.valueOf(field_meta.is_schema),
                field_meta.is_schema ? field_meta.schema_name : "",
                (null == field_meta.value ? "(null)" : field_meta.value.toString()), // something better than toString()?
                field_meta.help,
                (field_meta.values == null || field_meta.values.length == 0 ? "" : Arrays.toString(field_meta.values)),
                (field_meta.is_member_of_frames == null ? "[]" : Arrays.toString(field_meta.is_member_of_frames)),
                (field_meta.is_mutually_exclusive_with == null ? "[]" : Arrays.toString(field_meta.is_mutually_exclusive_with)));
          }
        }
        if (first)
          builder.paragraph("(none)");
      }

      // TODO: render examples and other stuff, if it's passed in
    }
    catch (Exception e) {
      IcedHashMapGeneric.IcedHashMapStringObject values = new IcedHashMapGeneric.IcedHashMapStringObject();
      values.put("schema", this);
      // TODO: This isn't quite the right exception type:
      throw new H2OIllegalArgumentException("Caught exception using reflection on schema: " + this,
          "Caught exception using reflection on schema: " + this + ": " + e,
          values);
    }
    return builder.stringBuffer();
  }
74819
private void initSyntaxRule() throws SQLException {
    // Deduce the string used to quote identifiers. For example, Oracle
    // uses double-quotes:
    //   SELECT * FROM "My Schema"."My Table"
    String identifierQuoteString = meta.getIdentifierQuoteString();
    if (identifierQuoteString.length() > 1) {
      sqlLine.error("Identifier quote string is '" + identifierQuoteString
          + "'; quote strings longer than 1 char are not supported");
      identifierQuoteString = null;
    }
    final String productName = meta.getDatabaseProductName();
    final Set<String> keywords =
        Stream.of(meta.getSQLKeywords().split(","))
            .collect(Collectors.toSet());
    dialect = DialectImpl.create(keywords, identifierQuoteString,
        productName, meta.storesUpperCaseIdentifiers());
  }
496949
private void onInheritedProperty(TableInfo tableInfo, EntityType entityType)
    {
        String discrColumn = ((AbstractManagedType) entityType).getDiscriminatorColumn();

        if (discrColumn != null)
        {
            ColumnInfo columnInfo = new ColumnInfo();
            columnInfo.setColumnName(discrColumn);
            columnInfo.setType(String.class);
            columnInfo.setIndexable(true);

            IndexInfo idxInfo = new IndexInfo(discrColumn);
            tableInfo.addColumnInfo(columnInfo);
            tableInfo.addToIndexedColumnList(idxInfo);
        }
    }
855745
@Override
    public IHLLMetadata readMetadata(final byte[] bytes) {
        final byte versionByte = bytes[0];
        final byte parametersByte = bytes[1];
        final byte cutoffByte = bytes[2];

        final int typeOrdinal = SerializationUtil.typeOrdinal(versionByte);
        final int explicitCutoffValue = SerializationUtil.explicitCutoff(cutoffByte);
        final boolean explicitOff = (explicitCutoffValue == EXPLICIT_OFF);
        final boolean explicitAuto = (explicitCutoffValue == EXPLICIT_AUTO);
        final int log2ExplicitCutoff = (explicitOff || explicitAuto) ? -1/*sentinel*/ : (explicitCutoffValue - 1/*per spec*/);

        return new HLLMetadata(SCHEMA_VERSION,
                                    getType(typeOrdinal),
                                    SerializationUtil.registerCountLog2(parametersByte),
                                    SerializationUtil.registerWidth(parametersByte),
                                    log2ExplicitCutoff,
                                    explicitOff,
                                    explicitAuto,
                                    SerializationUtil.sparseEnabled(cutoffByte));
    }