diff --git a/.changes/unreleased/Fixes-20240716-090114.yaml b/.changes/unreleased/Fixes-20240716-090114.yaml new file mode 100644 index 0000000000..acbacc51f7 --- /dev/null +++ b/.changes/unreleased/Fixes-20240716-090114.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Add Column header to the exported CSV from query command +time: 2024-07-16T09:01:14.102978+05:30 +custom: + Author: saurabh0402 + Issue: 1285,1313 diff --git a/dbt-metricflow/dbt_metricflow/cli/main.py b/dbt-metricflow/dbt_metricflow/cli/main.py index cf05ff9f28..c59ad93435 100644 --- a/dbt-metricflow/dbt_metricflow/cli/main.py +++ b/dbt-metricflow/dbt_metricflow/cli/main.py @@ -340,6 +340,7 @@ def query( elif csv is not None: # csv is a LazyFile that is file-like that works in this case. csv_writer = csv_module.writer(csv) + csv_writer.writerow(df.column_names) for row in df.rows: csv_writer.writerow(row) click.echo(f"🖨 Successfully written query output to {csv.name}")