/** * Precondition-style validation that throws a {@link ValidationException}. * * @param isValid * {@code true} if valid, {@code false} if an exception should be * thrown * @param message * A String message for the exception. */ public static void check(boolean isValid, String message, Object... args) { if (!isValid) { String[] argStrings = new String[args.length]; for (int i = 0; i < args.length; i += 1) { argStrings[i] = String.valueOf(args[i]); } throw new IncompatibleSchemaException( String.format(String.valueOf(message), (Object[]) argStrings)); } } }
throw new IncompatibleSchemaException("Schema cannot read data " + "written using existing schema. Schema: " + schema.toString(true) +
+ " New schema: " + entitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg); + " New schema: " + entitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg); + " New schema: " + entitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg);
+ " New schema: " + entitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg); + " New schema: " + entitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg); + " New schema: " + entitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg);
throw new IncompatibleSchemaException( "Schema already exists as version: " + getEntityVersion(tableName, entityName, newEntitySchema)); + schemaString + " New schema: " + newEntitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg); + Integer.toString(version) + ": Old schema: " + schemaString + " New schema: " + newEntitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg);
throw new IncompatibleSchemaException( "Schema already exists as version: " + getEntityVersion(tableName, entityName, newEntitySchema)); + schemaString + " New schema: " + newEntitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg); + Integer.toString(version) + ": Old schema: " + schemaString + " New schema: " + newEntitySchema.getRawSchema(); throw new IncompatibleSchemaException(msg);
/** * Checks that the {@code existing} {@link DatasetDescriptor} is compatible * with {@code test}. * * @param existing the current {@code DatasetDescriptor} for a dataset * @param test a new {@code DatasetDescriptor} for the same dataset */ public static void checkCompatible(DatasetDescriptor existing, DatasetDescriptor test) { checkNotChanged("format", existing.getFormat(), test.getFormat()); checkNotChanged("partitioning", existing.isPartitioned(), test.isPartitioned()); if (existing.isPartitioned()) { checkStrategyUpdate( existing.getPartitionStrategy(), test.getPartitionStrategy(), test.getSchema()); } // 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)); } }
ManagedSchema managedSchema = getManagedSchema(tableName, entityName); if (managedSchema != null) { throw new IncompatibleSchemaException( "Cannot create schema when one already exists");
ManagedSchema managedSchema = getManagedSchema(tableName, entityName); if (managedSchema != null) { throw new IncompatibleSchemaException( "Cannot create schema when one already exists");