code: public static boolean checkReaderWriterCompatibility(Schema readerSchema, Schema writerSchema, boolean ignoreNamespace) {
      if (ignoreNamespace) {
        List<Schema.Field> fields = deepCopySchemaFields(readerSchema);
        readerSchema = Schema.createRecord(writerSchema.getName(), writerSchema.getDoc(), writerSchema.getNamespace(),
            readerSchema.isError());
        readerSchema.setFields(fields);
      }
  
      return SchemaCompatibility.checkReaderWriterCompatibility(readerSchema, writerSchema).getType().equals(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
    }
docs: Validates that the provided reader schema can be used to decode avro data written with the
  provided writer schema.
  @param readerSchema schema to check.
  @param writerSchema schema to check.
  @param ignoreNamespace whether name and namespace should be ignored in validation
  @return true if validation passes