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

[HJwIMwqg] apoc.export.csv.graph incorrectly exports properties with datatype float #403

Merged
merged 4 commits into from Aug 31, 2023

Conversation

vga91
Copy link
Collaborator

@vga91 vga91 commented May 16, 2023

Added data types with config useTypes:true,
consistently with these ones

testCall(db, "CALL apoc.graph.fromDB('test',{}) yield graph " +
"CALL apoc.export.csv.graph(graph, $file,{useTypes: true, quotes: 'none'}) " +
"YIELD nodes, relationships, properties, file, source,format, time " +
"RETURN *", map("file", fileName),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this writing to the same resource file? If not, change the name of the file here so there's no confusion please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the fileName value

@@ -0,0 +1,80 @@
package apoc.export.csv;
Copy link
Collaborator

@ncordon ncordon May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these tests created in a separate file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there are extra nodes that would change the results of the ExportCsvTest test, so I created a new file to not make a lot of changes in that file and to simplify the assertions

(r) -> assertResults(fileName, r, "graph", 2L, 1L, 16L, true));
final String expected = Util.readResourceFile("manyTypes.csv");
assertEquals(expected, readFile(fileName));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also have a test for apoc.export.csv.data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Comment on lines 37 to 39
db.executeTransactionally("CREATE (n:SuperNode { one: datetime('2018-05-10T10:30[Europe/Berlin]'), two: time('18:02:33'), three: localtime('17:58:30'), \n" +
"four: localdatetime('2021-06-08'), five: date('2020'), six: duration({months: 5, days: 1.5}), seven : '2020'}) \n" +
"WITH n CREATE (n)-[:REL_TYPE {rel: point({x: 56.7, y: 12.78, crs: 'cartesian'})}]->(m:AnotherNode)");
Copy link
Collaborator

@ncordon ncordon May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd include array properties here as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better not to include arrays at the moment
since there's another specific card for arrays (the one with id F9oIci9k),
so I could put them there in case

} else {
result.addAll(Stream.of(starters).map(s -> s.split(":")[0]).collect(Collectors.toList()));
}
private List<Map.Entry<String, String>> generateHeader(Map<String, Class> propTypes, boolean useTypes, String... starters) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you have changed the type to List<Map.Entry<String, String>?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this way I have a list of entries <PropertyName, PropertyDataType>,
which I think is easier to handle in later lines,
i.e. the writeNext() on line 170 (where I use both PropertyName and PropertyDataType )
and in the getNamesHeader(..), where I use PropertyName only, without needing to split the ":" to retrieve the names of the properties

writeRels(graph, out, reporter, getNamesHeader(relHeader, REL_HEADER_FIXED_COLUMNS.length), cols, nodeHeader.size(), config.getBatchSize());
}

private List<String> getNamesHeader(List<Map.Entry<String, String>> nodeHeader, int length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not always a nodeHeader so the name is misleading

Copy link
Collaborator

@ncordon ncordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It'll be good to include explanations of what is being done, the code of certain places looks very convoluted without any comment explaining what is doing.
  • This PR requires more test coverage to be absolutely sure it's not breaking existing functionality and the new functionality works as expected.

@vga91
Copy link
Collaborator Author

vga91 commented May 30, 2023

  • It'll be good to include explanations of what is being done, the code of certain places looks very convoluted without any comment explaining what is doing.
  • This PR requires more test coverage to be absolutely sure it's not breaking existing functionality and the new functionality works as expected.

Added several additional tests and some comments.
It would be great to add some roundtrip examples as well, but I'd like to wait for the card with id yVM4sJbH to be fixed, and do it in that pr, in case

@vga91 vga91 merged commit ae1d8be into dev Aug 31, 2023
13 checks passed
@vga91 vga91 deleted the apoc.export.csv.graph-float-type branch August 31, 2023 15:38
vga91 added a commit that referenced this pull request Sep 1, 2023
vga91 added a commit that referenced this pull request Sep 1, 2023
vga91 added a commit that referenced this pull request Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants