From 0c07ab4bedfbd0047fa5142fb1f36aae39ce74ad Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Tue, 2 Jul 2024 18:43:31 +0530 Subject: [PATCH 1/2] add header to the exporter csv in query command The CSV file generated using `mf query --csv ` does not contain the header. This commit updates the function to include the column header as well --- dbt-metricflow/dbt_metricflow/cli/main.py | 1 + 1 file changed, 1 insertion(+) 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}") From 20ac397c6471aff2c8e09656e45ec59f2e8cb4cf Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Tue, 16 Jul 2024 09:01:58 +0530 Subject: [PATCH 2/2] chore: add changelog --- .changes/unreleased/Fixes-20240716-090114.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixes-20240716-090114.yaml 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