Returns a {@link org.apache.gobblin.fork.CopyableSchema} wrapper around the given {@link Schema}.
{@inheritDoc}
@see org.apache.gobblin.converter.Converter#convertSchema(java.lang.Object, org.apache.gobblin.configuration.WorkUnitState)
965713
@Override
  public CopyableSchema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException {
    return new CopyableSchema(inputSchema);
  }
723420
public static <E> Schema getWriterSchema(Class<E> type, Schema schema) {
    Schema writerSchema = schema;
    GenericData dataModel = getDataModelForType(type);
    if (dataModel instanceof AllowNulls) {
      // assume fields are non-null by default to avoid schema conflicts
      dataModel = ReflectData.get();
    }

    if (dataModel instanceof SpecificData) {
      writerSchema = ((SpecificData)dataModel).getSchema(type);
    }

    return writerSchema;
  }
395488
public static <T> Schema<T> createFrom(MappedSchema<T> ms, 
            Instantiator<T> instantiator, 
            Factory vf, 
            Predicate.Factory pf, 
            String ... args)
    {
        return vf.create(ms.typeClass, ms.fields, ms.fieldsByNumber, 
                ms.fieldsByName, instantiator, pf, args);
    }
906692
public Schema compileSchema( InputStream stream, String systemId )
		throws VerifierConfigurationException, SAXException, IOException {
		
		InputSource is = new InputSource(stream);
		is.setSystemId(systemId);
		return compileSchema(is);
	}
56542
@Override
  protected GenericRecord convertRecord(GenericRecord record) throws IOException {
    return AvroUtils.convertRecordSchema(record, this.schema.get());
  }
676945
private static Schema getActualRecord(Schema inputSchema) {
    if (Type.RECORD.equals(inputSchema.getType())) {
      return inputSchema;
    }

    Preconditions.checkArgument(Type.UNION.equals(inputSchema.getType()), "Nested schema is only support with either record or union type of null with record");
    Preconditions.checkArgument(inputSchema.getTypes().size() <= 2,
        "For union type in nested record, it should only have NULL and Record type");

    for (Schema inner : inputSchema.getTypes()) {
      if (Type.NULL.equals(inner.getType())) {
        continue;
      }
      Preconditions.checkArgument(Type.RECORD.equals(inner.getType()), "For union type in nested record, it should only have NULL and Record type");
      return inner;

    }
    throw new IllegalArgumentException(inputSchema + " is not supported.");
  }
690682
@Override
    /**
     * Export schema handles the handleOperation method.
     */
    public void exportSchema(final String persistenceUnit, List<TableInfo> schemas)
    {
        cql_version = externalProperties != null ? (String) externalProperties.get(CassandraConstants.CQL_VERSION)
                : CassandraConstants.CQL_VERSION_2_0;
        super.exportSchema(persistenceUnit, schemas);
    }
629953
@Override
    public Schema transform(Schema schema) {
        int nCols = schema.numColumns();
        List<String> colNames = schema.getColumnNames();
        List<ColumnMetaData> meta = schema.getColumnMetaData();
        List<ColumnMetaData> newMeta = new ArrayList<>(nCols);

        for (int i = 0; i < nCols; i++) {
            String name = colNames.get(i);
            ColumnMetaData inMeta = meta.get(i);

            if (keyColumnsSet != null && keyColumnsSet.contains(name)) {
                //No change to key columns
                newMeta.add(inMeta);
                continue;
            }

            //First: check for a custom reduction on this column
            if (customReductions != null && customReductions.containsKey(name)) {
                AggregableColumnReduction reduction = customReductions.get(name);

                List<String> outName = reduction.getColumnsOutputName(name);
                List<ColumnMetaData> outMeta = reduction.getColumnOutputMetaData(outName, inMeta);
                newMeta.addAll(outMeta);
                continue;
            }

            //Second: check for conditional reductions on this column:
            if (conditionalReductions != null && conditionalReductions.containsKey(name)) {
                ConditionalReduction reduction = conditionalReductions.get(name);

                List<String> outNames = reduction.getOutputNames();
                List<ReduceOp> reductions = reduction.getReductions();
                for (int j = 0; j < reduction.getReductions().size(); j++) {
                    ReduceOp red = reductions.get(j);
                    String outName = outNames.get(j);
                    ColumnMetaData m = getMetaForColumn(red, name, inMeta);
                    m.setName(outName);
                    newMeta.add(m);
                }
                continue;
            }


            //Otherwise: get the specified (built-in) reduction op
            //If no reduction op is specified for that column: use the default
            List<ReduceOp> lop = opMap.containsKey(name) ? opMap.get(name) : Collections.singletonList(defaultOp);
            if (lop != null)
                for (ReduceOp op : lop) {
                    newMeta.add(getMetaForColumn(op, name, inMeta));
                }
        }

        return schema.newSchema(newMeta);
    }
1339003
public static JsonElementConverter getConvertor(JsonSchema schemaNode, String namespace, WorkUnitState state)
      throws UnsupportedDateTypeException {

    Type type = schemaNode.getType();

    DateTimeZone timeZone = getTimeZone(state.getProp(ConfigurationKeys.CONVERTER_AVRO_DATE_TIMEZONE, "UTC"));
    switch (type) {
      case DATE:
        return new DateConverter(schemaNode,
            state.getProp(ConfigurationKeys.CONVERTER_AVRO_DATE_FORMAT, "yyyy-MM-dd HH:mm:ss"), timeZone, state);

      case TIMESTAMP:
        return new DateConverter(schemaNode,
            state.getProp(ConfigurationKeys.CONVERTER_AVRO_TIMESTAMP_FORMAT, "yyyy-MM-dd HH:mm:ss"), timeZone, state);

      case TIME:
        return new DateConverter(schemaNode, state.getProp(ConfigurationKeys.CONVERTER_AVRO_TIME_FORMAT, "HH:mm:ss"),
            timeZone, state);

      case FIXED:
        throw new UnsupportedDateTypeException(type.toString() + " is unsupported");

      case STRING:
        return new StringConverter(schemaNode);

      case BYTES:
        return new BinaryConverter(schemaNode, state.getProp(ConfigurationKeys.CONVERTER_AVRO_BINARY_CHARSET, "UTF8"));

      case INT:
        return new IntConverter(schemaNode);

      case LONG:
        return new LongConverter(schemaNode);

      case FLOAT:
        return new FloatConverter(schemaNode);

      case DOUBLE:
        return new DoubleConverter(schemaNode);

      case BOOLEAN:
        return new BooleanConverter(schemaNode);

      case ARRAY:
        return new ArrayConverter(schemaNode, state);

      case MAP:
        return new MapConverter(schemaNode, state);

      case ENUM:
        return new EnumConverter(schemaNode, namespace);

      case RECORD:
        return new RecordConverter(schemaNode, state, namespace);

      case NULL:
        return new NullConverter(schemaNode);

      case UNION:
        return new UnionConverter(schemaNode, state);

      default:
        throw new UnsupportedDateTypeException(type.toString() + " is unsupported");
    }
  }
871697
@Override
  public Iterable<GenericRecord> convertRecord(String outputSchema, GenericRecord inputRecord, WorkUnitState workUnit)
      throws DataConversionException {
    try {
      String schemaIdField = workUnit.contains(PAYLOAD_SCHEMA_ID_FIELD) ?
          workUnit.getProp(PAYLOAD_SCHEMA_ID_FIELD) : DEFAULT_PAYLOAD_SCHEMA_ID_FIELD;
      String payloadField = workUnit.contains(PAYLOAD_FIELD) ?
          workUnit.getProp(PAYLOAD_FIELD) : DEFAULT_PAYLOAD_FIELD;
      String schemaKey = String.valueOf(inputRecord.get(schemaIdField));
      Schema payloadSchema = (Schema) this.registry.getSchemaByKey(schemaKey);
      byte[] payload = getPayload(inputRecord, payloadField);
      GenericRecord outputRecord = deserializePayload(payload, payloadSchema);
      if (this.fieldRemover.isPresent()) {
        payloadSchema = this.fieldRemover.get().removeFields(payloadSchema);
      }
      return new SingleRecordIterable<>(AvroUtils.convertRecordSchema(outputRecord, payloadSchema));
    } catch (IOException | SchemaRegistryException | ExecutionException e) {
      throw new DataConversionException(e);
    }
  }
80885
public static synchronized Schema getXJCLSchema() {
        if (schema == null) {
            try {
                URL url = ValidatorHelper.class.getResource("/" + SCHEMA_LOCATION);
                schema = sf.newSchema(url);
            } catch (SAXException e) {
                throw new RuntimeException(e);
            }
        }
        return schema;        
    }
888216
public ObjectSchema getObjectSchema(Set<String> objectClasses) 
        throws NamingException, ClassNotFoundException {
        
        ObjectSchema result = new ObjectSchema();
        createObjectClass(objectClasses, schemaContext, result);
        return result;
    }
211244
public static Schema decorateRecordSchema(Schema inputSchema, @Nonnull List<Field> fieldList) {
    Preconditions.checkState(inputSchema.getType().equals(Type.RECORD));
    List<Field> outputFields = deepCopySchemaFields(inputSchema);
    List<Field> newOutputFields = Stream.concat(outputFields.stream(), fieldList.stream()).collect(Collectors.toList());

    Schema outputSchema = Schema.createRecord(inputSchema.getName(), inputSchema.getDoc(),
            inputSchema.getNamespace(), inputSchema.isError());
    outputSchema.setFields(newOutputFields);
    copyProperties(inputSchema, outputSchema);
    return outputSchema;
  }
525666
public Schema schema(TableSchema schema) {
		tableSchema.clear();
		lastField = null;
		for (int i = 0; i < schema.getFieldCount(); i++) {
			field(schema.getFieldName(i).get(), schema.getFieldType(i).get());
		}
		return this;
	}
1075707
@Override
  public S getSchema()
      throws IOException {
    try {
      if (_schemaRegistry.isPresent()) {
        return _schemaRegistry.get().getLatestSchemaByTopic(this._partition.topic());
      }
    } catch (SchemaRegistryException e) {
      throw new RuntimeException(e);
    }
    return ((S) this._partition.topic());
  }
1254453
protected void addImportedSchemas(Schema schema) throws WSDLException, IOException, TransformerException, TransformerFactoryConfigurationError {
        for (Object imports : schema.getImports().values()) {
            for (SchemaImport schemaImport : (Vector<SchemaImport>)imports) {
                // Prevent duplicate imports
                if (!importedSchemas.contains(schemaImport.getNamespaceURI())) {
                    importedSchemas.add(schemaImport.getNamespaceURI());
                    Schema referencedSchema = schemaImport.getReferencedSchema();

                    if (referencedSchema != null) {
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        Source source = new DOMSource(referencedSchema.getElement());
                        Result result = new StreamResult(bos);

                        TransformerFactory.newInstance().newTransformer().transform(source, result);
                        Resource schemaResource = new ByteArrayResource(bos.toByteArray());

                        addImportedSchemas(referencedSchema);
                        schemaResources.add(schemaResource);
                    }
                }
            }
        }
    }
1272591
def fromSchema(self, schema):
        ''' 
        '''  
        ns = schema.getTargetNamespace()
        assert self.targetNamespace is None or self.targetNamespace == ns,\
            'SchemaDescription instance represents %s, not %s'\
            %(self.targetNamespace, ns)

        if self.targetNamespace is None:
            self.targetNamespace = ns
 
        self.classHead.ns = self.classFoot.ns = ns
        for item in [t for t in schema.types if t.getAttributeName() not in self.__types]:
            self.__types.append(item.getAttributeName())
            self.items.append(TypeWriter(do_extended=self.do_extended, extPyClasses=self.extPyClasses))
            self.items[-1].fromSchemaItem(item)

        for item in [e for e in schema.elements if e.getAttributeName() not in self.__elements]:
            self.__elements.append(item.getAttributeName())
            self.items.append(ElementWriter(do_extended=self.do_extended))
            self.items[-1].fromSchemaItem(item)