Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SL-2418] [Bug] Missing column names when writing a query to CSV #1285

Closed
2 tasks done
Jstein77 opened this issue Jun 14, 2024 · 1 comment
Closed
2 tasks done

[SL-2418] [Bug] Missing column names when writing a query to CSV #1285

Jstein77 opened this issue Jun 14, 2024 · 1 comment
Assignees
Labels
bug Something isn't working High priority Created by Linear-GitHub Sync Low Created by Linear-GitHub Sync Metricflow Created by Linear-GitHub Sync starter task Created by Linear-GitHub Sync triage Tasks that need to be triaged

Comments

@Jstein77
Copy link
Contributor

Jstein77 commented Jun 14, 2024

Is this a new bug in metricflow?

  • I believe this is a new bug in metricflow
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When I run mf query --metrics revenue --group-by metric_time__week --csv test the csv result does not include the metric or dimension names.

The first for rows for test.csv are:

2016-09-26 00:00:00,4221.0
2016-10-31 00:00:00,4880.0
2016-11-14 00:00:00,6020.0
2016-11-21 00:00:00,6530.0

Expected Behavior

I expect the first row of the CSV to be the metrics and dimensions in my query

metric_time__week, revenue
2016-09-26 00:00:00,4221.0
2016-10-31 00:00:00,4880.0
2016-11-14 00:00:00,6020.0
2016-11-21 00:00:00,6530.0

Steps To Reproduce

  1. In dbt 1.8 and mf version 0.7.0 run mf query --metrics revenue_offset --group-by metric_time__week --csv test
  2. The CSV will not inlcude the metric and dimension names in the first row.

Relevant log output

No response

Environment

- OS:
- Python:
- dbt:
- metricflow:

Which database are you using?

No response

Additional Context

No response

SL-2418

@Jstein77 Jstein77 added bug Something isn't working triage Tasks that need to be triaged labels Jun 14, 2024
@Jstein77 Jstein77 changed the title [Bug] Missing column names when writing query re [SL-2418] [Bug] Missing column names when writing query re Jun 14, 2024
@Jstein77 Jstein77 self-assigned this Jun 14, 2024
@Jstein77 Jstein77 changed the title [SL-2418] [Bug] Missing column names when writing query re [SL-2418] [Bug] Missing column names when writing query to CSV Jun 14, 2024
@Jstein77 Jstein77 changed the title [SL-2418] [Bug] Missing column names when writing query to CSV [SL-2418] [Bug] Missing column names when writing a query to CSV Jun 14, 2024
@Jstein77 Jstein77 added High priority Created by Linear-GitHub Sync Metricflow Created by Linear-GitHub Sync labels Jun 27, 2024
@saurabh0402
Copy link
Contributor

saurabh0402 commented Jul 2, 2024

Hey @Jstein77, would it be fine if I pick this up?

tlento pushed a commit that referenced this issue Jul 16, 2024
# Issue
#1285

The CSV exported from the `mf query <metric> --csv <csv-file-name>`
command does not contain the column header. The CSV thus does not make
too much sense.

# Fix
- The code
[here](https://github.com/dbt-labs/metricflow/blob/main/dbt-metricflow/dbt_metricflow/cli/main.py#L344)
is writing data to the CSV file. The column names aren't getting added
to the file.
- With this PR, we are adding the column names returned from
`df.column_names` to the CSV to fix the issue.
tlento pushed a commit that referenced this issue Jul 26, 2024
# Issue
#1285

The CSV exported from the `mf query <metric> --csv <csv-file-name>`
command does not contain the column header. The CSV thus does not make
too much sense.

# Fix
- The code
[here](https://github.com/dbt-labs/metricflow/blob/main/dbt-metricflow/dbt_metricflow/cli/main.py#L344)
is writing data to the CSV file. The column names aren't getting added
to the file.
- With this PR, we are adding the column names returned from
`df.column_names` to the CSV to fix the issue.
tlento added a commit that referenced this issue Jul 27, 2024
…1354)

This commit is a backport of PR #1313 to dbt-metricflow 0.7.x

This will allow us to deploy @saurabh0402's fix for the following issue:

#1285

Note - efficacy was tested via the CLI by running hatch build and doing
a pip install
of the build package into a clean VM, and running `mf query` with the
`--csv` flag
enabled.

Co-authored-by: Saurabh Kumar <[email protected]>
@Jstein77 Jstein77 added this to the MetricFlow Sprint milestone Sep 13, 2024
@Jstein77 Jstein77 added the Low Created by Linear-GitHub Sync label Sep 13, 2024
@Jstein77 Jstein77 modified the milestones: MetricFlow Sprint, v.37 Sep 17, 2024
@Jstein77 Jstein77 added the starter task Created by Linear-GitHub Sync label Sep 17, 2024
@Jstein77 Jstein77 removed this from the v.37 milestone Sep 19, 2024
@Jstein77 Jstein77 modified the milestones: v.38, v.39 Sep 27, 2024
@Jstein77 Jstein77 modified the milestones: v.39, v.40, v.41 Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working High priority Created by Linear-GitHub Sync Low Created by Linear-GitHub Sync Metricflow Created by Linear-GitHub Sync starter task Created by Linear-GitHub Sync triage Tasks that need to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants