@Override public void validate(DescriptorProperties properties) { super.validate(properties); final boolean hasRecordClass = properties.containsKey(FORMAT_RECORD_CLASS); final boolean hasAvroSchema = properties.containsKey(FORMAT_AVRO_SCHEMA); if (hasRecordClass && hasAvroSchema) { throw new ValidationException("A definition of both a schema and Avro schema is not allowed."); } else if (hasRecordClass) { properties.validateString(FORMAT_RECORD_CLASS, false, 1); } else if (hasAvroSchema) { properties.validateString(FORMAT_AVRO_SCHEMA, false, 1); } else { throw new ValidationException("A definition of an Avro specific record class or Avro schema is required."); } } }
@Override public void validate(DescriptorProperties properties) { super.validate(properties); properties.validateBoolean(FORMAT_DERIVE_SCHEMA, true); final boolean deriveSchema = properties.getOptionalBoolean(FORMAT_DERIVE_SCHEMA).orElse(false); final boolean hasSchema = properties.containsKey(FORMAT_SCHEMA); final boolean hasSchemaString = properties.containsKey(FORMAT_JSON_SCHEMA); if (deriveSchema && (hasSchema || hasSchemaString)) { throw new ValidationException( "Format cannot define a schema and derive from the table's schema at the same time."); } else if (!deriveSchema && hasSchema && hasSchemaString) { throw new ValidationException("A definition of both a schema and JSON schema is not allowed."); } else if (!deriveSchema && !hasSchema && !hasSchemaString) { throw new ValidationException("A definition of a schema or JSON schema is required."); } else if (hasSchema) { properties.validateType(FORMAT_SCHEMA, false, true); } else if (hasSchemaString) { properties.validateString(FORMAT_JSON_SCHEMA, false, 1); } properties.validateBoolean(FORMAT_FAIL_ON_MISSING_FIELD, true); } }
@Override public void validate(DescriptorProperties properties) { super.validate(properties); final boolean hasRecordClass = properties.containsKey(FORMAT_RECORD_CLASS); final boolean hasAvroSchema = properties.containsKey(FORMAT_AVRO_SCHEMA); if (hasRecordClass && hasAvroSchema) { throw new ValidationException("A definition of both a schema and Avro schema is not allowed."); } else if (hasRecordClass) { properties.validateString(FORMAT_RECORD_CLASS, false, 1); } else if (hasAvroSchema) { properties.validateString(FORMAT_AVRO_SCHEMA, false, 1); } else { throw new ValidationException("A definition of an Avro specific record class or Avro schema is required."); } } }
@Override public void validate(DescriptorProperties properties) { super.validate(properties); final boolean hasRecordClass = properties.containsKey(FORMAT_RECORD_CLASS); final boolean hasAvroSchema = properties.containsKey(FORMAT_AVRO_SCHEMA); if (hasRecordClass && hasAvroSchema) { throw new ValidationException("A definition of both a schema and Avro schema is not allowed."); } else if (hasRecordClass) { properties.validateString(FORMAT_RECORD_CLASS, false, 1); } else if (hasAvroSchema) { properties.validateString(FORMAT_AVRO_SCHEMA, false, 1); } else { throw new ValidationException("A definition of an Avro specific record class or Avro schema is required."); } } }
@Override public void validate(DescriptorProperties properties) { super.validate(properties); properties.validateBoolean(FORMAT_DERIVE_SCHEMA, true); final boolean deriveSchema = properties.getOptionalBoolean(FORMAT_DERIVE_SCHEMA).orElse(false); final boolean hasSchema = properties.containsKey(FORMAT_SCHEMA); final boolean hasSchemaString = properties.containsKey(FORMAT_JSON_SCHEMA); if (deriveSchema && (hasSchema || hasSchemaString)) { throw new ValidationException( "Format cannot define a schema and derive from the table's schema at the same time."); } else if (!deriveSchema && hasSchema && hasSchemaString) { throw new ValidationException("A definition of both a schema and JSON schema is not allowed."); } else if (!deriveSchema && !hasSchema && !hasSchemaString) { throw new ValidationException("A definition of a schema or JSON schema is required."); } else if (hasSchema) { properties.validateType(FORMAT_SCHEMA, false, true); } else if (hasSchemaString) { properties.validateString(FORMAT_JSON_SCHEMA, false, 1); } properties.validateBoolean(FORMAT_FAIL_ON_MISSING_FIELD, true); } }
@Override public void validate(DescriptorProperties properties) { super.validate(properties); properties.validateBoolean(FORMAT_DERIVE_SCHEMA, true); final boolean deriveSchema = properties.getOptionalBoolean(FORMAT_DERIVE_SCHEMA).orElse(false); final boolean hasSchema = properties.containsKey(FORMAT_SCHEMA); final boolean hasSchemaString = properties.containsKey(FORMAT_JSON_SCHEMA); if (deriveSchema && (hasSchema || hasSchemaString)) { throw new ValidationException( "Format cannot define a schema and derive from the table's schema at the same time."); } else if (!deriveSchema && hasSchema && hasSchemaString) { throw new ValidationException("A definition of both a schema and JSON schema is not allowed."); } else if (!deriveSchema && !hasSchema && !hasSchemaString) { throw new ValidationException("A definition of a schema or JSON schema is required."); } else if (hasSchema) { properties.validateType(FORMAT_SCHEMA, false, true); } else if (hasSchemaString) { properties.validateString(FORMAT_JSON_SCHEMA, false, 1); } properties.validateBoolean(FORMAT_FAIL_ON_MISSING_FIELD, true); } }