Change order of columns in output data table from workflow in OD Processor

Hi,

How can I change the order of columns saved in a Parquet/PostgreSQL/Result Table?

Let’s say, the columns “A” and “B” are sorted in this order in my Result Table:

A | B

I would like columns to be displayed in this order, instead:

B | A

The only solution I have managed to find so far is using a Python processor, by passing the column names as column selectors. But is there any way to do this with a OD Processor?

from onelogic.odpf import ImageType
import pandas as pd

# od_input keys represent name of the input dataset set in OD processor
input_df = od_input['input'].get_as_pandas()

#select subset of columns and output data frame in the selected order
output_df = input_df[["B", "A"]]

od_output.add_data("output", output_df)

A query processor with a select query containing the list of columns in the order you would like should help getting the expected schema in the result table

1 Like