# Path: peachbox/model/file_format.py
# class FileFormat(object):
#     JSON = 0
#     Parquet = 1


import pyspark.sql.types
import peachbox.model
from peachbox.model.file_format import FileFormat
    @classmethod
    def generate_spark_schema(cls):
        fields = []
        types = [None]*(len(cls.schema)+1)
        indices = {}
        current_idx = 0

        type_int = peachbox.model.Types.spark_type('IntegerType') 
        fields.append(pyspark.sql.types.StructField('true_as_of_seconds', type_int, True))
        types[current_idx] = int
        indices['true_as_of_seconds'] = current_idx
        current_idx += 1

        for field in cls.schema:
            spark_type = peachbox.model.Types.spark_type(field['type'])
            fields.append(pyspark.sql.types.StructField(field['field'], spark_type, True))
            types[current_idx] = peachbox.model.Types.python_type(field['type'])
            indices[field['field']] = current_idx

            current_idx += 1

        cls._spark_schema = pyspark.sql.types.StructType(fields)
        cls._spark_indices = indices
        cls._types = types

    @classmethod
    def get_field_index(cls, field_name):
        return cls._spark_indices[field_name]



# Path: peachbox/model/file_format.py
# class FileFormat(object):
#     JSON = 0
#     Parquet = 1


# Path: peachbox/model/schema.py
import pyspark.sql.types
import peachbox.model
from peachbox.model.file_format import FileFormat

    @classmethod
    def generate_spark_schema(cls):
        fields = []
        types = [None]*(len(cls.schema)+1)
        indices = {}
        current_idx = 0

        type_int = peachbox.model.Types.spark_type('IntegerType') 
        fields.append(pyspark.sql.types.StructField('true_as_of_seconds', type_int, True))
        types[current_idx] = int
        indices['true_as_of_seconds'] = current_idx
        current_idx += 1

        for field in cls.schema:
            spark_type = peachbox.model.Types.spark_type(field['type'])
            fields.append(pyspark.sql.types.StructField(field['field'], spark_type, True))
            types[current_idx] = peachbox.model.Types.python_type(field['type'])
            indices[field['field']] = current_idx

            current_idx += 1

        cls._spark_schema = pyspark.sql.types.StructType(fields)
        cls._spark_indices = indices
        cls._types = types

    @classmethod
    def get_field_index(cls, field_name):
        return cls._spark_indices[field_name]



    @classmethod