The method "flattenize" the given Avro schema.
@param s  Avro schema
@return  List of supported fields which were extracted from original Schema
772172
public static Schema.Field[] flatSchema(Schema s) {
    List<Schema.Field> fields = s.getFields();
    Schema.Field[] flatSchema = new Schema.Field[fields.size()];
    int cnt = 0;
    for (Schema.Field f : fields) {
      if (isSupportedSchema(f.schema())) {
        flatSchema[cnt] = f;
        cnt++;
      }
    }
    // Return resized array
    return cnt != flatSchema.length ? Arrays.copyOf(flatSchema, cnt) : flatSchema;
  }
855376
public static List<Writable> toArrowWritablesSingle(List<FieldVector> fieldVectors,Schema schema) {
        return toArrowWritables(fieldVectors,schema).get(0);
    }
692747
def schema_map(schema):
    """"""
    mapper = {}
    for name in getFieldNames(schema):
        mapper[name] = name
    return mapper
1006104
def flatten(struct):
    
    if struct is None:
        return []
    flat = []
    if isinstance(struct, dict):
        for key, result in struct.items():
            flat += flatten(result)
        return flat

    if isinstance(struct, basestring):
        return [struct]

    try:
        # if iterable
        for result in struct:
            flat += flatten(result)
        return flat
    except TypeError:
        pass

    return [struct]
77935
public List<Field> resolveFields(QualifiedName name)
    {
        return allFields.stream()
                .filter(input -> input.canResolve(name))
                .collect(toImmutableList());
    }
971969
private static void validateIfAvroSchema(SerializerDefinition serializerDef) {
        if(serializerDef.getName().equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)
           || serializerDef.getName().equals(AVRO_GENERIC_TYPE_NAME)) {
            SchemaEvolutionValidator.validateAllAvroSchemas(serializerDef);
            // check backwards compatibility if needed
            if(serializerDef.getName().equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)) {
                SchemaEvolutionValidator.checkSchemaCompatibility(serializerDef);
            }
        }
    }
356089
def get_flattened_bsp_keys_from_schema(schema):
    
    keys = []

    for key in schema.declared_fields.keys():
        field = schema.declared_fields[key]

        if isinstance(field, mm.fields.Nested) and \
                isinstance(field.schema, BoundSpatialPoint):
            keys.append("{}.{}".format(key, "position"))

    return keys
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);
    }
855760
def to_s
      parts = FIELDS.flat_map do |field|
        [dump_extra_diffs(field),
         dump_missing_diffs(field),
         dump_mismatch_diffs(field)]
      end

      [
        "Table #{@table_name} does not match the expected schema.\n\n",
        parts.compact.join("\n"),
        "\nYou may disable schema checks by passing :disable => true to model_",
        "schema or by setting the ENV variable #{DISABLE_MODEL_SCHEMA_KEY}=1.\n"
      ].join
    end
1135257
@SuppressWarnings({ "rawtypes", "unchecked" })
  public static Schema toPangoolSchema(org.apache.avro.Schema avroSchema) {
		List<Field> fields = new ArrayList<Field>();
		for(org.apache.avro.Schema.Field avroField : avroSchema.getFields()) {
			org.apache.avro.Schema.Type type = avroField.schema().getType();
			Field pangoolField;
			switch(type){
			case INT: pangoolField = Field.create(avroField.name(),Type.INT); break;
			case LONG: pangoolField = Field.create(avroField.name(),Type.LONG); break;
			case FLOAT: pangoolField = Field.create(avroField.name(),Type.FLOAT); break;
			case DOUBLE: pangoolField = Field.create(avroField.name(),Type.DOUBLE); break;
			case BOOLEAN: pangoolField = Field.create(avroField.name(),Type.BOOLEAN); break;
			case STRING: pangoolField = Field.create(avroField.name(),Type.STRING); break;
			case BYTES:
				if (avroField.getProp(Field.METADATA_BYTES_AS_OBJECT) == null){
					pangoolField = Field.create(avroField.name(),Type.BYTES);
				} else {
					try {
					String objectClazz = avroField.getProp(Field.METADATA_OBJECT_CLASS);
					pangoolField = Field.createObject(avroField.name(),Class.forName(objectClazz));
					String serializationString = avroField.getProp(Field.METADATA_OBJECT_SERIALIZATION);
					if (serializationString != null){
							Class<? extends Serialization> ser=
		             (serializationString == null) ? null : 
			          	(Class<? extends Serialization>)Class.forName(serializationString);
							pangoolField.setObjectSerialization(ser);
					}
					
					} catch(ClassNotFoundException e) {
	          throw new PangoolRuntimeException(e);
          }
				}
				break;
			case ENUM:
				String objectClazz = avroField.getProp(Field.METADATA_OBJECT_CLASS);
				try{
					pangoolField = Field.createEnum(avroField.name(),Class.forName(objectClazz));
					} catch(ClassNotFoundException e){
						throw new PangoolRuntimeException(e);
					}
				break;
			default:
				throw new PangoolRuntimeException("Avro type:" + type + " can't be converted to Pangool Schema type");
			}
			//add properties 
			for(Map.Entry<String,String> entry : avroField.props().entrySet()){
				if (!Field.RESERVED_KEYWORDS.contains(entry.getKey())){
					pangoolField.addProp(entry.getKey(),entry.getValue());
				}
			}
			fields.add(pangoolField);
			
		}
		Schema schema = new Schema(avroSchema.getFullName(), fields);
		return schema;
	}
431774
private Path getOrGenerateSchemaFile(Schema schema) throws IOException {

    Preconditions.checkNotNull(schema, "Avro Schema should not be null");

    String hashedSchema = Hashing.sha256().hashString(schema.toString(), StandardCharsets.UTF_8).toString();

    if (!this.schemaPaths.containsKey(hashedSchema)) {

      Path schemaFilePath = new Path(this.schemaDir, String.valueOf(System.currentTimeMillis() + ".avsc"));
      AvroUtils.writeSchemaToFile(schema, schemaFilePath, fs, true);

      this.schemaPaths.put(hashedSchema, schemaFilePath);
    }

    return this.schemaPaths.get(hashedSchema);
  }
1112642
public static StreamSchema deserialize(String schemaString) {
    Iterable<String> fieldArray = Splitter.on(';').trimResults().omitEmptyStrings().split(schemaString);
    StreamSchema.Builder builder = new StreamSchema.Builder();
    for (String field : fieldArray) {
      Iterable<String> defnArray = Splitter.onPattern("\\s+").trimResults().omitEmptyStrings().split(field);
      List<String> defnList = Lists.newArrayList(defnArray);
      //We expect FieldType, FieldName (optional : FieldAttribute)
      Preconditions.checkArgument(defnList.size() >= 2);
      GDATFieldType type = GDATFieldType.getGDATFieldType(defnList.get(0).toUpperCase());
      String fieldName = defnList.get(1);
      builder.addField(fieldName, type);
    }
    return builder.build();
  }
748521
static Matcher flattenNestedSequences(Matcher matcher) {
    if (matcher instanceof SeqMatcher) {
      List<Matcher> matchers = matcher.<SeqMatcher>as().matchers();
      List<Matcher> ms = new ArrayList<>();
      for (Matcher m : matchers) {
        if (m instanceof SeqMatcher) {
          ms.addAll(m.<SeqMatcher>as().matchers());
        } else {
          ms.add(m);
        }
      }
      return SeqMatcher.create(ms);
    }
    return matcher;
  }
975771
public static <T> List<Field> getDeclaredFields(T type) {
        return new ArrayList<>(asList(type.getClass().getDeclaredFields()));
    }
314507
private List<Field> getList(Map<Class<?>, List<Field>> fields) {
        List<Field> ret = fields == null ? null : fields.get(getServiceClass());
        if (ret != null) {
            ret = Collections.unmodifiableList(ret);
        } else {
            ret = Collections.emptyList();
        }
        return ret;
    }
315823
public static List<List<Writable>> convertStringInput(List<List<String>> stringInput,Schema schema) {
        List<List<Writable>> ret = new ArrayList<>();
        List<List<Writable>> timeStepAdd = new ArrayList<>();
        for(int j = 0; j < stringInput.size(); j++) {
            List<String> record = stringInput.get(j);
            List<Writable> recordAdd = new ArrayList<>();
            for(int k = 0; k < record.size(); k++) {
                switch(schema.getType(k)) {
                    case Double: recordAdd.add(new DoubleWritable(Double.parseDouble(record.get(k)))); break;
                    case Float:  recordAdd.add(new FloatWritable(Float.parseFloat(record.get(k)))); break;
                    case Integer:  recordAdd.add(new IntWritable(Integer.parseInt(record.get(k)))); break;
                    case Long:  recordAdd.add(new LongWritable(Long.parseLong(record.get(k)))); break;
                    case String: recordAdd.add(new Text(record.get(k))); break;
                    case Time: recordAdd.add(new LongWritable(Long.parseLong(record.get(k)))); break;

                }
            }

            timeStepAdd.add(recordAdd);
        }


        return ret;
    }
549762
@Override
  public Schema convertSchema(Schema inputSchema, WorkUnitState workUnit) {
    return AVRO_FLATTENER.flatten(inputSchema, false);
  }