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

apoc.export.csv.query() config for quotes: 'ifNeeded' not working #4014

Open
JMHReif opened this issue Mar 14, 2024 · 3 comments
Open

apoc.export.csv.query() config for quotes: 'ifNeeded' not working #4014

JMHReif opened this issue Mar 14, 2024 · 3 comments
Labels
team-cypher-surface Cypher Surface team should review the PR

Comments

@JMHReif
Copy link
Contributor

JMHReif commented Mar 14, 2024

Expected Behavior (Mandatory)

Should produce a CSV that only has quotes around the string values.

Expected following output:

group_id,product_group
1,"Whole Bean/Teas"
2,"Beverages"
3,"Add-ons"
4,"Food"
5,"Merchandise"

Actual Behavior (Mandatory)

Not having any quotes around any value. Output looks the same as when quotes: 'none'

How to Reproduce the Problem

  • Test the apoc.export.csv.query quote issue with config stream: true, quotes: 'ifNeeded'

Simple Dataset (where it's possibile)

//Insert here a set of Cypher statements that helps us to reproduce the problem
WITH ["Whole Bean/Teas", "Beverages", "Add-ons", "Food", "Merchandise"] as list
UNWIND list as item
MERGE (g:Group {group: item});

Steps (Mandatory)

  1. Create the sample data set
  2. Run the following query:
WITH "MATCH (group:Group) 
WITH collect(group) AS groups 
WITH groups, range(0, size(groups) - 1) AS ordinal_positions
UNWIND ordinal_positions AS id
WITH id+1 as group_id, groups[id] as group
return group_id, group.group as product_group" AS query
CALL apoc.export.csv.query(query, null, {stream: true, quotes: 'ifNeeded'})
YIELD data
RETURN data;

Screenshots (where it's possibile)

Screenshot 2024-03-14 at 4 01 35 PM

Specifications (Mandatory)

Currently used versions

Versions

  • OS:
  • Neo4j: Aura
  • Neo4j-Apoc: Aura
@JoelBergstrand JoelBergstrand added the team-cypher-surface Cypher Surface team should review the PR label Mar 15, 2024
@JoelBergstrand
Copy link
Contributor

Thanks for the excellent bug report! Agree that it looks like a bug, we'll look into it 🧐

@JoelBergstrand
Copy link
Contributor

I've looked into it now and this is the expected behavior of using 'ifNeeded'. It escapes characters such as commas and not the column as a whole. Alternatively, you could use 'always' which puts all values in quotation marks and would get you the following result:

"group_id","product_group" 
"1","Whole Bean/Teas"
"2","Beverages"
...

@JMHReif
Copy link
Contributor Author

JMHReif commented Mar 22, 2024

That turns everything into strings, including integer values, dates, and so on. I was expecting the 'if-needed' option to not turn integers and other non-string data types into strings. 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-cypher-surface Cypher Surface team should review the PR
Projects
Status: Core issues (with trello core card)
Development

No branches or pull requests

2 participants