Package org.kitesdk.data

Examples of org.kitesdk.data.IncompatibleSchemaException


      type = (Class<E>) GenericData.Record.class;
    }

    Schema readerSchema = getReaderSchema(type, schema);
    if (false == SchemaValidationUtil.canRead(schema, readerSchema)) {
      throw new IncompatibleSchemaException(
          String.format("The reader schema derived from %s is not compatible "
          + "with the dataset's given writer schema.", type.toString()));
    }

    return type;
View Full Code Here


    EntitySchema entitySchema = schemaParser.parseEntitySchema(entitySchemaStr);

    try {
      ManagedSchema managedSchema = getManagedSchema(tableName, entityName);
      if (managedSchema != null) {
        throw new IncompatibleSchemaException(
            "Cannot create schema when one already exists");
      }
    } catch (SchemaNotFoundException e) {
      // we want the schema to not be found, continue
    }
View Full Code Here

    EntitySchema newEntitySchema = schemaParser.parseEntitySchema(newSchemaStr);
    KeySchema newKeySchema = schemaParser.parseKeySchema(newSchemaStr);

    // verify that the newSchema isn't a duplicate of a previous schema version.
    if (hasSchemaVersion(tableName, entityName, newEntitySchema)) {
      throw new IncompatibleSchemaException(
          "Schema already exists as version: "
              + getEntityVersion(tableName, entityName, newEntitySchema));
    }

    // validate that, for each version of the schema, this schema is
    // compatible with those schema version. That means the field mapping
    // hasn't changed, and we can read old schemas, and processes that
    // are configured with old schemas can read new schemas.
    int greatestSchemaVersion = 0;
    for (Entry<String, String> entry : managedSchema.getEntitySchemas()
        .entrySet()) {
      int version = Integer.parseInt(entry.getKey());
      if (version > greatestSchemaVersion) {
        greatestSchemaVersion = version;
      }
      String schemaString = entry.getValue();
      KeySchema keySchema = schemaParser.parseKeySchema(schemaString);
      EntitySchema entitySchema = schemaParser.parseEntitySchema(schemaString);
      if (!newKeySchema.compatible(keySchema)) {
        String msg = "StorageKey fields of entity schema not compatible with version "
            + Integer.toString(version)
            + ": Old schema: "
            + schemaString
            + " New schema: " + newEntitySchema.getRawSchema();
        throw new IncompatibleSchemaException(msg);
      }
      if (!newEntitySchema.compatible(entitySchema)) {
        String msg = "Avro schema not compatible with version "
            + Integer.toString(version) + ": Old schema: " + schemaString
            + " New schema: " + newEntitySchema.getRawSchema();
        throw new IncompatibleSchemaException(msg);
      }
    }

    // Validate that this schema is compatible with other schemas registered
    // with this same table.
View Full Code Here

                + tableName
                + ". Other schema: "
                + otherEntitySchema.getRawSchema()
                + " New schema: "
                + entitySchema.getRawSchema();
            throw new IncompatibleSchemaException(msg);
          }
          if (!validateCompatibleWithTableColumns(entitySchema,
              otherEntitySchema)) {
            String msg = "Column mappings of schema not compatible with other schema for the table. "
                + "Table: "
                + tableName
                + ". Other schema: "
                + otherEntitySchema.getRawSchema()
                + " New schema: "
                + entitySchema.getRawSchema();
            throw new IncompatibleSchemaException(msg);
          }
          if (!validateCompatibleWithTableOccVersion(entitySchema,
              otherEntitySchema)) {
            String msg = "OCCVersion mapping of schema not compatible with other schema for the table. "
                + "Only one schema in the table can have one."
                + "Table: "
                + tableName
                + ". Other schema: "
                + otherEntitySchema.getRawSchema()
                + " New schema: "
                + entitySchema.getRawSchema();
            throw new IncompatibleSchemaException(msg);
          }
        }
      }
    }
  }
View Full Code Here

    // check can read records written with old schema using new schema
    Schema oldSchema = existing.getSchema();
    Schema testSchema = test.getSchema();
    if (!SchemaValidationUtil.canRead(oldSchema, testSchema)) {
      throw new IncompatibleSchemaException("Schema cannot read data " +
          "written using existing schema. Schema: " + testSchema.toString(true) +
          "\nExisting schema: " + oldSchema.toString(true));
    }

  }
View Full Code Here

TOP

Related Classes of org.kitesdk.data.IncompatibleSchemaException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.