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

java.lang.NullPointerException when setting the type of a property to "datetime" in the mapping config of apoc.load.csv() #3218

Closed
srpalko opened this issue Oct 13, 2022 · 1 comment

Comments

@srpalko
Copy link

srpalko commented Oct 13, 2022

Guidelines

Please note that GitHub issues are only meant for bug reports/feature requests. If you have questions on how to use APOC, please ask on the Neo4j Discussion Forum instead of creating an issue here.

Expected Behavior (Mandatory)

I'm using apoc.periodic.iterate with apoc.load.csv to process CSV files. In the configuration map of apoc.periodic.iterate, I'm using the mapping key to set the types of the fields. When give a value of "datetime" I expect the field to be parsed into a datetime property.

Actual Behavior (Mandatory)

When I set mapping; { date_prop: {type: "datetime"} }, the query fails to invoke apoc.periodic.iterate caused by java.lang.NullPointerException. If I change the type to "string' it works fine.

How to Reproduce the Problem

Simple Dataset (where it's possible)

":LABEL","log_id","access_date","log_type","full_text_access","cid","source_system","external_source","name","id"
"Session","232387464","2022-05-01T00:00:30","library_login","","0","","","session","log-232387449"
"Session","232387449","2022-05-01T00:00:06","Meta_Data_View","False","1000030957","PROD","","session","log-232387454"

        CALL apoc.load.directory("access-subgraph-*-vertices-*.csv") YIELD value 
        WITH value as url
        CALL apoc.periodic.iterate(
            'CALL apoc.load.csv(
                $url,
                {
                    header: true,
                    ignore: [":LABEL"],
                    nullValues: [""],
                    mapping: {
                        name: {type: "string"},
			log_id: {type: "string"},
			access_date: {type: "datetime"},
			log_type: {type: "string"},
			full_text_access: {type: "string"},
			cid: {type: "string"},
			source_system: {type: "string"},
			external_source: {type: "string"}
                    }
                }
            ) YIELD map AS row RETURN row',
            'MERGE (node:Session {id: row.id}) 
             ON CREATE SET node = row
             ON MATCH SET node = row',
            {batchSize: 10000, parallel: true, params: {url: url}}
        ) YIELD batches, total 
          RETURN datetime() AS timestamp, 'access-subgraph-*' AS file_type, batches, total;

Steps (Mandatory)

  1. Place CSV file in the import directory
  2. Call the above query

Screenshots (where it's possibile)

Specifications (Mandatory)

32 GB RAM, Intel Xeon Platinum 8259CL @ 2.50GHz

Currently used versions

Versions

  • OS: Ubuntu 18.04.6 LTS
  • Neo4j: 4.4.12
  • Neo4j-Apoc: 4.4.0.9
@vga91
Copy link
Collaborator

vga91 commented Jan 16, 2024

@srpalko

The issue should be caused by APOC Core code, so it cannot be resolved in this repository.

I created a task on Core to fix the problem.

In the meantime, as a workaround,
can you try changing {type: "datetime"} to {type: "datetime", optionalData: {}}?

vga91 added a commit that referenced this issue Feb 29, 2024
…a property to datetime in the mapping config of apoc.load.csv()
vga91 added a commit that referenced this issue Mar 14, 2024
…a property to datetime in the mapping config of apoc.load.csv()
RobertoSannino pushed a commit that referenced this issue Mar 14, 2024
…a property to datetime in the mapping config of apoc.load.csv() (#3976)
vga91 added a commit that referenced this issue Apr 3, 2024
…ype of a property to datetime in the mapping config of apoc.load.csv() (#3976)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants