-
Notifications
You must be signed in to change notification settings - Fork 30
DOC-2200 supporting null val #308
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
base: 4.3.0-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,10 @@ Existing schemas that are using `STRING COMPRESS` can continue to function norma | |
| If you need reference for `STRING COMPRESS`, please refer to GSQL Language Reference version 3.5 or older. | ||
| ==== | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| Primitive data types used as attributes of a vertex or edge, can be set to `NULL`. | ||
| ==== | ||
| Additionally, GSQL also supports the following complex data types: | ||
|
|
||
| == Collection types | ||
|
|
@@ -143,6 +147,17 @@ Due to multithreaded GSQL loading, the initial order of elements loaded into a l | |
| ** Supported value types: `INT`, `DOUBLE`, `STRING`, `DATETIME`, and `UDT`. | ||
| ** To declare a map type, use `<>` to enclose the types, with a comma to separate the key and value types, e.g., `MAP<INT, DOUBLE>`. | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| * `LIST`, `SET`, `MAP` can be assigned `NULL` as an attribute. | ||
| * For `LIST` or `SET`: | ||
| ** `NULL` is different from [NULL, NULL] or {NULL}. | ||
| ** Elements inside `LIST` or `SET` cannot be `NULL`. | ||
| * For `MAP`: | ||
| ** Keys and Values cannot be `NULL`. | ||
|
|
||
| ==== | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not all of this belongs in a special note:
This is just following the standard rule that any attribute that is NULLABLE can have null. No special treatment.
This does deserve being in a NOTE because this is where TigerGraph's support is not as complete as it is in some other products.
I would just lump this together with
From a technical standpoint, this is not saying anything that isn't already said in the preceding rules. It's usefulness is as an example, not an additional rule. MyList = NULL // This is setting the entire list to null. Supported. |
||
| == User-defined tuples | ||
|
|
||
| A *User-Defined Tuple (UDT)* represents an ordered structure of several fields of the same or different types. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,6 +108,72 @@ RUN LOADING JOB job1 USING file1="m1:/data/v1_1.csv", file2="m2:/data/e2.csv" <2 | |
| <1> File path specified at compile time. | ||
| <2> Run-time specification will override path specified at compile time. | ||
|
|
||
| === Loading NULL Values | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have sections that talk about how to load each type of data. It is called "Attributes and attribute expressions", with a subsection for each data type. |
||
| `NULL` values can be loaded to vertex/edge attributes using a loading job either by parsing from source file or during creation of loading job. | ||
|
|
||
| ==== Loading NULL from source file | ||
| If an attribute is defined as *nullable* in the schema, any of the following in a CSV or JSON file are treated as `NULL`: | ||
|
|
||
| * The value `NULL` or `null` | ||
| * A missing value (empty field) | ||
|
|
||
| .Example: CSV file containing NULL values | ||
| [source,csv] | ||
| ---- | ||
| id,att | ||
| 1,null // valid null and will be parsed to storage | ||
| 2,NULL // valid null and will be parsed to storage | ||
| 3, // missing value and will be parsed as null to storage | ||
| 4,Null // invalid attribute | ||
| ---- | ||
|
|
||
| .Example: JSON file containing NULL values | ||
| [source,json] | ||
| ---- | ||
| {"id":1,"att":null} // valid null and will be parsed to storage | ||
| {"id":2,"att":NULL} // valid null and will be parsed to storage | ||
| {"id":3,"att":Null} // invalid like Null except for string | ||
| {"id":4,"att":} // invalid JSON | ||
| ---- | ||
|
|
||
| Sample Output | ||
| [source,json] | ||
| ---- | ||
| "results": [ | ||
| { "1,null": null }, | ||
| { "2,NULL": null }, | ||
| { "3,": null }, | ||
| { "4,Null": "Null" } | ||
| ] | ||
| ---- | ||
|
|
||
| ==== Loading NULL during creation of loading job | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would modify and reduce the scope of this section.
We might want a section called "Omitted Fields and Default Values".
|
||
|
|
||
| `NULL` can be stored in the following situations: | ||
|
|
||
| * When the attribute is nullable and the vertex or edge does not exist: | ||
| ** The default value for that attribute in the schema is `NULL`, or | ||
| ** No default value is defined in the schema. | ||
| * If the attribute is nullable, NULL will be stored for this attribute for all vertices/edges loaded in this job. | ||
| * If the attribute is not nullable, the GSQL shell shows a *semantic error*. | ||
|
|
||
| For example: | ||
| [source,gsql] | ||
| ---- | ||
| CREATE LOADING JOB load_nullable FOR GRAPH g { | ||
| DEFINE FILENAME f; | ||
|
|
||
| // Implicit NULL using underscore | ||
| LOAD f TO VERTEX v0 VALUES($0, _); | ||
| LOAD f TO EDGE e0 VALUES ($0, $1, _); | ||
|
|
||
| // Explicit NULL using NULL keyword | ||
| LOAD f TO VERTEX v1 VALUES ($0, NULL); | ||
| LOAD f TO EDGE e1 VALUES ($0, $1, NULL); | ||
| } | ||
| ---- | ||
|
|
||
|
|
||
| == `DROP JOB` statement | ||
|
|
||
| To drop (remove) a job, run `DROP JOB job_name`. The job will be removed from GSQL. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,7 +167,7 @@ ADD VERTEX:: | |
| -- | ||
| ---- | ||
| ADD VERTEX Vertex_Type_Name ( PRIMARY_ID id_name id_type | ||
| [, attribute_name type [DEFAULT default_value] ]* ) | ||
| [, attribute_name type [NULLABLE][DEFAULT default_value] ]* ) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This syntax detail is correct, but there is another section on the page that needs to same treatment. |
||
| [WITH [STATS="none"|"outdegree_by_edgetype"][primary_id_as_attribute="true"]] | ||
| ---- | ||
| -- | ||
|
|
@@ -179,7 +179,7 @@ ADD UNDIRECTED EDGE Edge_Type_Name ( | |
| FROM Vertex_Type_Name "," TO Vertex_Type_Name | ||
| [ "|" FROM Vertex_Type_Name "," TO Vertex_Type_Name]* | ||
| [ "," DISCRIMINATOR "(" attribute_name type ["," attribute_name type]* ")" ] | ||
| [ "," attribute_name type [DEFAULT default_value]]* | ||
| [ "," attribute_name type [NULLABLE][DEFAULT default_value]]* | ||
| ) | ||
| ---- | ||
| -- | ||
|
|
@@ -192,7 +192,39 @@ For example, the following statement in a schema change job adds a directed edge | |
| ADD DIRECTED EDGE Study_At (From Person, To University, | ||
| DISCRIMINATOR(class_year INT, class_month INT)); | ||
| ---- | ||
| Starting in 4.3, vertex/edge attributes can be defined as `NULLABLE` to accept `NULL` values. | ||
|
|
||
| For example: | ||
| [tabs] | ||
| ==== | ||
| ADD VERTEX:: | ||
| + | ||
| -- | ||
| ---- | ||
| ADD VERTEX Student ( | ||
| PRIMARY_ID id INT, | ||
| name STRING NULLABLE, | ||
| age INT NULLABLE | ||
| ); | ||
| ---- | ||
| -- | ||
| ADD EDGE:: | ||
| + | ||
| -- | ||
| ---- | ||
| ADD DIRECTED EDGE Enrolled_In ( | ||
| FROM Student, | ||
| TO Course, | ||
| grade STRING NULLABLE | ||
| ); | ||
| ---- | ||
| -- | ||
| ==== | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| Attributes used for `PRIMARY_KEY` or `COMPOSITE_KEY` or `DISCRIMINATOR` cannot be declared `NULLABLE`. | ||
| ==== | ||
|
|
||
| == `ALTER VERTEX | EDGE` | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -340,6 +340,23 @@ VALUES (value_for_from_vertex, value_for_to_vertex, <1> | |||||
| For each attribute value, provide either an expression _expr_ or `_`, which means the default value for that attribute type. | ||||||
| The optional _name_ which follows the first two (id) values is to specify the source vertex type and target vertex type, if the edge type had been defined with wildcard vertex types. | ||||||
|
|
||||||
| + | ||||||
| .NULL Value Ingestion | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section does not seem to be in the right place on this page. I have more to say on this, which I will write in a separate note. |
||||||
| + | ||||||
| The `INSERT INTO` statement supports inserting `NULL` values for attributes defined as `NULLABLE` in the schema. | ||||||
| * `NULL` or `null` can be used in the `VALUES` clause to insert a NULL value. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| .Example | ||||||
| [source,gsql] | ||||||
| ---- | ||||||
| CREATE VERTEX Student ( | ||||||
| PRIMARY_ID id INT, | ||||||
| name STRING NULLABLE, | ||||||
| age INT NULLABLE | ||||||
| ); | ||||||
| INSERT INTO Student VALUES (1001, "Alice", NULL); | ||||||
| ---- | ||||||
|
|
||||||
| === Query-Body INSERT | ||||||
|
|
||||||
| The following query illustrates query-body level `INSERT` statements: insert new `Company` vertices and `Works_For` edges into the `Works_Net` graph. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make this a new (brief) section on Null Values, not a Note.