The results of executing SQL and Python source code are saved so that they can be used as input for subsequent processes.

The format of the saved results varies depending on the format of each process’s result. Additionally, you can change the output destination and format by specifying the output_paths in the SQL config function or the Python @morph.func argument.

Output Formats

SQL

By default, results are saved as .parquet files. You can also specify csv in output_paths.

Python

The format specified in the output_type argument of @morph.func is used, or if not specified, it is automatically inferred from the return value. The format of the saved file changes depending on the type of value returned by the function, as shown below.

DataFrame

By default, results are saved as .parquet files. You can also specify csv in output_paths.

Plotly and Matplotlib Charts

By default, both .html and .png files are saved. You can also limit the file extensions saved by specifying them in output_paths.

By specifying the output extension like output_paths=["_private/sample.png"], you can change it to output only files with the specified extension.

JSON

If the return value is a dict or list, it is saved as a .json file.

markdown

If the return value is a str and output_type is markdown, it is saved as a .md file.

Text

If the return value is a str and no specific output_type is specified, it is saved as a .txt file.

How to Specify output_paths

You can specify the path in output_paths to designate the output destination path as shown below.

{{
    config(
        name="sample_sql",
        description="Sameple SQL for output_paths",
        output_paths=[
            "/tmp/morph/{name}/{now()}{ext()}",
            "_private/{name}/{now()}.csv"
        ]
    )
}}

select * from sample;

Placeholders

In output_paths, you can use the following placeholders to specify dynamic output destinations.

placeholderdescription
nameThe value of name specified in config or @morph.func
now()Outputs the date in the format (%Y%m%d_%H%M%S)
unix()Timestamp in milliseconds
ext()Automatically inferred extension