Skip to main content

File

A file is used in File System Persistence Mappings to define the location and format of data on a filesystem. There are many types of files, and each type may have different required fields, based on the format field.

Text File

A text file has a single field, value for each row in the file.

Specification

{
"format": "text",
"path": "<string>",
"fileName": "<string>",
"compression": "<string>"
}

Structure values

Field NameTypeDescriptionRequiredDefault
pathStringParent path of the file. Can be an empty string.Required
fileNameStringName of the file or folder. Can be a glob using wildcards (e.g., *.txt)Required
compressionStringCompression type for source file. Supported compression types: none bzip2 gzip lz4 snappy deflate Note: this compression is only used when writing files. Magpie will detect the compression of files based on the file extension when reading.Optionalgzip
formatStringFile's storage format, text for text files.Required

Example

{
"path": "/my_data",
"fileName": "transactions.txt",
"format": "text"
}

Delimited Text File (e.g., csv, tsv)

A text file with fields delimited by a specified separator.

Specification

{
"format": "DelimitedText",
"path": "<string>",
"fileName": "<string>",
"compression": "<string>",
"encoding": "<string>",
"delimiter": "<string>",
"header": <boolean>,
"multiLine": <boolean>,
"ignoreLeadingWhiteSpace": <boolean>,
"ignoreTrailingWhiteSpace": <boolean>,
"quoteCharacter": "<string>",
"escapeCharacter": "<string>",
"dateFormat": "<string>",
"timestampFormat": "<string>"
}

Structure values

Field NameTypeDescriptionRequiredDefault
pathStringParent path of the file. Can be an empty string.Required
fileNameStringName of the file or folder. Can be a glob using wildcards (e.g., *.csv)Required
delimiterStringThe separator used to partition records into fieldsOptional,
compressionStringCompression type for source file. Supported compression types: none bzip2 gzip lz4 snappy deflate Note: this compression is only used when writing files. Magpie will detect the compression of files based on the file extension when reading.Optionalgzip
encodingStringEncoding of the fileOptionalutf-8
headerBooleanIf true, the first line of each file will be used as field names for the resulting tables.Optionalfalse
multiLineBooleanIf true, multiple lines of the file will be parsed as one record, with new records starting based on field counts.Optionalfalse
ignoreLeadingWhiteSpaceBooleanIf true, leading white space will be trimmed from each field.Optionalfalse
ignoreTrailingWhiteSpaceBooleanIf true, trailing white space will be trimmed from each field.Optionalfalse
quoteCharacterStringThe character optionally used to enclose fields within the files.Optional"
escapeCharacterStringThe character optionally used to escape quotations within a quoted field.Optional"
nullValueStringThe value to treat as null when reading files and the value to use as null when writing files.Optional
dateFormatStringThe Java date format used to identify fields as dates within the files.Optionalyyyy-MM-dd
timestampFormatStringThe Java date time format used to identify fields as timestamps within the files.Optionalyyyy-MM-dd HH:mm:ss
formatStringFile's storage format, DelimitedText for delimited text files.Required

Example

{
"path": "/my_data",
"fileName": "transactions.tsv.gz",
"delimiter": "\t",
"compression": "Gzip",
"encoding": "UTF-8",
"header": true,
"multiLine": false,
"ignoreLeadingWhiteSpace": false,
"ignoreTrailingWhiteSpace": false,
"quoteCharacter": "\"",
"escapeCharacter": "\"",
"dateFormat": "yyyy-MM-dd",
"timestampFormat": "yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
"format": "DelimitedText"
}

Parquet File

A columnar storage format. Default storage format in Magpie.

Specification

{
"format": "parquet",
"path": "<string>",
"fileName": "<string>",
"compression": "<string>",
"mergeSchema": <boolean>
}

Structure values

Field NameTypeDescriptionRequiredDefault
pathStringParent path of the file. Can be an empty string.Required
fileNameStringName of the file or folder. Can be a glob using wildcards.Required
compressionStringCompression type for source file. Supported compression types: none gzip snappy lzo Note: this compression is only used when writing files. Magpie will detect the compression of files based on the file extension when reading.Optionalsnappy
mergeSchemaBooleanIf true and this file points to a folder of parquet files, Magpie will merge the schema for each file to create the final schema for the table. If false, Magpie will only use the schema of the first file for the table.Optionalfalse
formatStringFile's storage format, parquet for parquet files.Required

Example

{
"path": "/my_data",
"fileName": "transactions",
"mergeSchema": true,
"format": "parquet"
}

JSON File

A JSON or newline-delimited JSON file (NDJSON).

Specification

{
"format": "json",
"path": "<string>",
"fileName": "<string>",
"compression": "<string>",
"encoding": "<string>",
"multiLine": <boolean>,
"dateFormat": "<string>",
"timestampFormat": "<string>"
}

Structure values

Field NameTypeDescriptionRequiredDefault
pathStringParent path of the file. Can be an empty string.Required
fileNameStringName of the file or folder. Can be a glob using wildcards (e.g., *.json).Required
compressionStringCompression type for source file. Supported compression types: none bzip2 gzip lz4 snappy deflate Note: this compression is only used when writing files. Magpie will detect the compression of files based on the file extension when reading.Optionalgzip
encodingStringThe file’s encoding. If not specified, encoding is auto-detected.Optional
multiLineBooleanIf true, each file will be parsed as a single record (each file is a single JSON record). If false, files are parsed as newline-delimited JSON, with each new line starting a separate JSON record.Optionalfalse
dateFormatStringThe Java date format used to identify fields as dates within the files.Optionalyyyy-MM-dd
timestampFormatStringThe Java datetime format used to identify fields as timestamps within the files.Optionalyyyy-MM-dd'T'HH:mm:ss.SSSXXX
formatStringFile's storage format, json for JSON files.Required

Example

{
"path": "/my_data",
"fileName": "clicks/*.json",
"multiLine": true,
"dateFormat": "yyyy-MM-dd",
"timestampFormat": "yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
"format": "json"
}

ORC File

A columnar storage format.

Specification

{
"format": "orc",
"path": "<string>",
"fileName": "<string>",
"compression": "<string>"
}

Structure values

Field NameTypeDescriptionRequiredDefault
pathStringParent path of the file. Can be an empty string.Required
fileNameStringName of the file or folder. Can be a glob using wildcards.Required
compressionStringCompression type for source file. Supported compression types: none snappy zlib lzo Note: this compression is only used when writing files. Magpie will detect the compression of files based on the file extension when reading.Optionalsnappy
formatStringFile's storage format, orc for ORC files.Required

Example

{
"path": "/my_data",
"fileName": "transactions",
"format": "orc"
}

Avro File

A row-based storage format widely used as a serialization platform.

Specification

{
"format": "avro",
"path": "<string>",
"fileName": "<string>",
"compression": "<string>",
"ignoreExtension": <boolean>,
"recordName": "<string>",
"recordNamespace": "<string>"
}

Structure values

Field NameTypeDescriptionRequiredDefault
pathStringParent path of the file. Can be an empty string.Required
fileNameStringName of the file or folder. Can be a glob using wildcards.Required
compressionStringCompression type for source file. Supported compression types: none snappy deflate bzip2 xz Note: this compression is only used when writing files. Magpie will detect the compression of files based on the file extension when reading.Optionalsnappy
ignoreExtensionBooleanIf false, read only .avro files at the specified path. If true, read all files as Avro regardless of the extension.Optionalfalse
recordNameStringWhen writing, the name of the top level record to write.OptionaltopLevelRecord
recordNamespaceStringWhen writing, the namespace of the record to write.Optional
formatStringFile's storage format, avro for Avro files.Required

Example

{
"path": "/my_data",
"fileName": "transactions",
"format": "avro"
}

Delta File

A delta lake file.

Specification

{
"format": "delta",
"path": "<string>",
"fileName": "<string>",
"mergeSchema": <boolean>
}

Structure values

Field NameTypeDescriptionRequiredDefault
pathStringParent path of the file. Can be an empty string.Required
fileNameStringName of the file or folder. Can be a glob using wildcards.Required
mergeSchemaBooleanIf true and this file points to a folder of delta files, Magpie will merge the schema for each file to create the final schema for the table. If false, Magpie will only use the schema of the first file for the table.Optionalfalse
formatStringFile's storage format, delta for Delta Lake files.Required

Example

{
"path": "/my_data",
"fileName": "transactions",
"format": "delta"
}