Data import¶
This topic introduces how to import data into NebulaGraph Cloud.
Prerequisites¶
- A database instance is created. For more information, see Create a database instance.
- A graph type and a graph are created. For more information, see Graph management.
- To perform the operations in this topic, you must be granted related roles. For more information, see Account user management.
Create an import task¶
Required role: Project Admin
- 
In NebulaGraph Cloud, switch to the project you want to use, and click the name of the database to view the database details. 
- 
On the left-side navigation pane of the database details page, click Import > Import Data to create an import task, which includes uploading files, configuring files, and mapping data. 
Step 1. Select a graph and upload files¶
- 
In the upper-left corner of the Import page, select a graph from the Load to Graph drop-down list for data import. 
- 
On the Select source tab, choose one of the following data sources to upload data, then click Next. - Local file: Upload CSV files from your local machine. The size of each file must be less than 400 MB.
- Amazon S3: Click +Add, enter your Amazon S3 URL and click Connect. You can add up to 10 Amazon S3 URLs. Only CSV files are supported.
 
Step 2. Preview files¶
- On the Preview files tab, check the uploaded data files.
- 
In the upper-right corner of each file, click  and specify the following items: and specify the following items:- Separator: Specify a character to separate the fields in the data file. Default value: ,.
- Use First Row as Header?: If your files have headers in the first row, select Yes. Otherwise, select No to exclude headers from data mapping in Step 3.
 
- Separator: Specify a character to separate the fields in the data file. Default value: 
- 
Click Apply to apply the changes to the current file or click Apply to All Files to apply the changes to all files. 
- 
Then click Next. 
Step 3. Map data and check mappings¶
- 
On the Mapping tab, specify the following items: - Type: Select a node type or edge type with its name.
- Select a file: Select an uploaded file.
- 
Map from file or Direction: Map data from specified columns to graph type properties using the following methods. - To map data individually, select each column name from the file.
- To map data in batches, click Quick Mapping on the right side. If the column name matches the property name, the system maps them automatically. If they do not match, the system maps them sequentially.
 
 
- 
Click Next. 
- 
On the Confirm tab, check the mapping information. 
- 
Click Import to start the import task. 
- 
On the Import page, view the task status. 
You can go to the Query or Explore page from the left navigation pane to view the imported data. For more information, see Explore graph and Data query.
For a detailed example about mapping, see Best practice for mapping.
Manage import tasks¶
You can view import tasks and perform actions on these tasks on the Import page.
View import tasks¶
Required role: Project Admin or Project Member
- 
In NebulaGraph Cloud, switch to the project you want to use, and click the name of the database to view the database details. 
- 
On the left-side navigation pane of the database details page, click Import. 
- 
On the Import page, you can view the import tasks. The task list includes: - ID: The import task ID.
 - Graph: The graph where the data is imported.
 - Status: The status of the import task, including Finished, Running, Failed, Stopped, Stopping and Queued.
 - Created At: The time when the import task was created.
 - Import Duration: The time taken to import data.
 - Actions: You can perform different actions on tasks in different statuses. For more information, see Perform actions on import tasks.
 
Perform actions on import tasks¶
- 
In NebulaGraph Cloud, switch to the project you want to use, and click the name of the database to view the database details. 
- 
On the left-side navigation pane of the database details page, click Import. 
- 
On the Import page, you can perform the following actions on import tasks in different statuses: 
| Task status | Supported actions | Descriptions | Required role | 
|---|---|---|---|
| Finished | View details | You can view details for finished tasks, including their status, import duration, average QPS, total records, successful records and failed records. | Project AdminorProject Member | 
| Explore graph | For finished tasks without any failed nodes or edges, you can click Explore Results in the detail pane to start data exploration. This will automatically navigate to the Explore page and create the canvas for the corresponding graph. | Project Admin | |
| Delete task | You can delete finished tasks without affecting the imported data. | Project Admin | |
| Download error logs | For finished tasks with failed nodes or edges, you can download the error logs in the status column for troubleshooting if they are provided. | Project Admin | |
| Failed | Retry task | You can retry failed tasks. After you retry a task, its status changes to Queuedand then toRunning. | Project Admin | 
| Delete task | You can delete failed tasks without affecting the imported data. | Project Admin | |
| Download error logs | For failed tasks, you can download the error logs in the status column for troubleshooting if they are provided. | Project Admin | |
| Running | Stop task | You can stop running tasks. After you stop a task, its status changes to Stoppingand then toStopped. | Project Admin | 
| Delete task | You can delete running tasks without affecting the imported data. | Project Admin | |
| Stopped | Resume task | You can resume stopped tasks. After you resume a task, its status changes to Queuedand then toRunning. | Project Admin | 
| Delete task | You can delete stopped tasks without affecting the imported data. | Project Admin | 
Best practice for mapping¶
Required role: Project Admin
To show you a best practice for mapping in NebulaGraph Cloud, we take the following local files and graph type of the demo dataset as an example.
| Demo file to be imported | Node/edge type | Property | 
|---|---|---|
| sub_user.csv: Contains the information about users. | User | id | 
| sub_movie.csv: Contains the information about movies. | Movie | idandname | 
| sub_user_watched_movies.csv: Contains the information about the relationship between users and movies. | Watch | rate | 
Before you start, make sure:
- Demo files are downloaded. You can click the above file names to download files directly.
- The node types UserandMovie, the edge typeWatch, and the graphmovieare created according to the demo dataset. For more information, see Create a graph type and Create a graph.
- Step 1 and Step 2 are completed.
Follow the steps below to map the data in sub_user.csv, sub_movie.csv, and sub_user_watched_movies.csv to the node types User and Movie, and the edge type Watch, respectively.
- 
In the upper-left corner of the Import page, select the graph moviefrom the Load to Graph drop-down list.
- 
On the Mapping tab, specify the items according to the table: Type Select a file Direction Map from file Node: User sub_use.csv NA Property id⬅ Column nameuser_id(187)Node: Movie sub_movie.csv NA Property id⬅ Column namemovie_id(4)
 Propertyname⬅ Column namename(Estado De Sitio)Edge: Watch sub_user_watched_movies.csv From: Primary key id⬅ Column nameuser_id(187)
 To: Primary keyid⬅ Column namemovie_id(1)Property rate⬅ Column namerate(3.5)Note The first row of imported data is displayed in the parentheses ()next to the column name.
- 
Click Import once you have mapped all the data.