Skip to content

Commit

Permalink
Revert "Zoned datetime data type (#723)" (#763)
Browse files Browse the repository at this point in the history
This reverts commit 16c8157.
  • Loading branch information
kgolubic authored May 14, 2024
1 parent 16c8157 commit 6c4a5d4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 126 deletions.
2 changes: 1 addition & 1 deletion pages/advanced-algorithms/available-algorithms/date.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Memgraph for managing time-based data.
### `format()`

Returns a string representation of time value using the specified unit,
specified format, and specified timezone.
specified format, and specified time zone.

{<h4> Input: </h4>}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The procedure formats a temporal value.

{<h4> Input: </h4>}

- `temporal: Any` ➡ A temporal value (date, time, local datetime, duration) that needs to be formatted.
- `temporal: Any` ➡ A temporal value (date, time, datetime, duration) that needs to be formatted.
- `format: str` ➡ The wanted format. The parameter supports values defined under [Python strftime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes).

{<h4> Output: </h4>}
Expand Down
9 changes: 5 additions & 4 deletions pages/data-migration/migrate-from-neo4j.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ MATCH (manager:Employee {employeeID: column.ReportsTo})
MERGE (employee)-[:REPORTS_TO]->(manager);
```

When migrating a particular dataset, be aware of the differences between Neo4j
and [Memgraph data types](/fundamentals/data-types). For example, Memgraph
doesn’t yet support the `POINT` spatial type, but you can represent it as a
map with the appropriate properties.
If you are going to use different dataset to migrate, be aware of the
differences between Neo4j and [Memgraph data
types](/fundamentals/data-types) (for example, Memgraph doesn't support
`DateTime()` as there is no temporal type in Memgraph that supports timezones yet,
but you can modify data to use `localDateTime()`).

## Exporting data from Neo4j

Expand Down
104 changes: 8 additions & 96 deletions pages/fundamentals/data-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ the supported types. Below is a table of supported data types.
| [`Map`](#maps) | A mapping of string keys to values of any supported type. |
| [`Duration`](#duration) | A period of time. |
| [`Date`](#date) | A date with year, month, and day. |
| [`LocalTime`](#localtime) | Time without the timezone. |
| [`LocalDateTime`](#localdatetime) | Date and time without the timezone. |
| [`ZonedDateTime`](#zoneddatetime) | Date and time in a specific timezone. |
| [`LocalTime`](#localtime) | Time without the time zone. |
| [`LocalDateTime`](#localdatetime) | Date and time without the time zone. |

<Callout type="info">

Expand Down Expand Up @@ -272,8 +271,8 @@ RETURN actor {.*, .dateOfBirth} as bradley

## Temporal types

The following temporal types are available: `Duration`, `Date`, `LocalTime`,
`LocalDateTime` and `ZonedDateTime`.
The following temporal types are available: `Duration`, `Date`, `LocalTime` and
`LocalDateTime`.

### Duration

Expand Down Expand Up @@ -537,88 +536,10 @@ Example:
MATCH (f:Flights) RETURN f.AIR123.year;
```

### ZonedDateTime
### Temporal types arithmetic

You can create a value of the `ZonedDateTime` type from a string or a map by
calling the `datetime()` function.

**Strings**

The `datetime()` function takes strings that follow the ISO 8601 standard. An
ISO 8601-compliant string that stands for a zoned datetime value has two parts:
`<DateTime><timezone>`. The first part is defined the same way as with
[LocalDateTime](#localdatetime), and the second part follows one of the given
timezone formats:
* `Z`
* `±hh:mm`
* `±hh:mm[ZoneName]`
* `±hhmm`
* `±hhmm[ZoneName]`
* `±hh`
* `±hh[ZoneName]`
* `[ZoneName]`,
where `ZoneName` is a timezone name from the
[IANA timezone database](https://en.wikipedia.org/wiki/Tz_database).

Examples:

```cypher
CREATE (:Flight {AIR123: datetime("2024-04-21T14:15:00-08:00[America/Los_Angeles]")});
CREATE (:Flight {AIR123: datetime("2021-04-21Z")});
```

**Maps**

Maps for constructing `ZonedDateTime` values may have the following fields:
`year`, `month`, `day`, `hour`, `minute`, `second`, `millisecond`,
`microsecond` and `timezone`.

There are two options for the `timezone` field:
* string: timezone name from the
[IANA timezone database](https://en.wikipedia.org/wiki/Tz_database)
* int: offset from UTC (in minutes)

```cypher
CREATE (:Flight {AIR123: datetime({year: 2024, month: 4, day: 21, hour: 14, minute: 15, timezone: "America/Los_Angeles"})});
CREATE (:Flight {AIR123: datetime({year: 2021, month: 4, day: 21, hour: 14, minute: 15, timezone: -60})});
```

**No arguments**

Calling `datetime` without passing arguments creates a `ZonedDateTime` value
that reflects the current date and time in UTC.

Example:

```cypher
CREATE (:Flights {AIR123: datetime()});
```

You can access the individual fields of ZonedDateTime through its properties:

| name | description |
| :---------: | :------------------------------: |
| year | Returns the year field |
| month | Returns the month field |
| day | Returns the day field |
| hour | Returns the hour field |
| minute | Returns the minute field |
| second | Returns the second field |
| millisecond | Returns the millisecond field |
| microsecond | Returns the microsecond field |
| timezone | Returns the timezone (as string) |

Example:

```cypher
MATCH (f: Flight) RETURN f.AIR123.timezone;
```

### Temporal type arithmetic

The `Duration`, `Date`, `LocalTime`, `LocalDateTime` and `ZonedDateTime` types
support native arithmetic, and the operations are summarized in the following
tables:
Temporal types `Duration`, `Date`, `LocalTime` and `LocalDateTime` support
native arithmetic, and the operations are summarized in the following tables:

Duration operations:

Expand Down Expand Up @@ -651,19 +572,10 @@ LocalDateTime operations:
| operation | result |
| :---------------------------: | :-----------: |
| LocalDateTime + Duration | LocalDateTime |
| Duration + LocalDateTime | LocalDateTime |
| Duration + LocalTateTime | LocalDateTime |
| LocalDateTime - Duration | LocalDateTime |
| LocalDateTime - LocalDateTime | Duration |

ZonedDateTime operations:

| operation | result |
| :---------------------------: | :-----------: |
| ZonedDateTime + Duration | ZonedDateTime |
| Duration + ZonedDateTime | ZonedDateTime |
| ZonedDateTime - Duration | ZonedDateTime |
| ZonedDateTime - ZonedDateTime | Duration |

## Procedures API

Data types are also used within query modules. Check out the documentation for
Expand Down
22 changes: 10 additions & 12 deletions pages/fundamentals/storage-memory-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -545,18 +545,16 @@ value. So the layout of each property is:

$\texttt{propertySize} = \texttt{basicMetadata} + \texttt{propertyID} + [\texttt{additionalMetadata}] + \texttt{value}.$

| Value type | Size | Note
|-----------------------------|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`NULL` | 1B + 1B | The value is written in the first byte of the basic metadata. |
|`BOOL` | 1B + 1B | The value is written in the first byte of the basic metadata. |
|`INT` | 1B + 1B + 1B, 2B, 4B or 8B | Basic metadata, property ID and the value depending on the size of the integer. |
|`DOUBLE` | 1B + 1B + 8B | Basic metadata, property ID and the value |
|`STRING` | 1B + 1B + 1B + min 1B | Basic metadata, property ID, additional metadata and lastly the value depending on the size of the string, where 1 ASCII character in the string takes up 1B. |
|`LIST` | 1B + 1B + 1B + min 1B | Basic metadata, property ID, additional metadata and the total size depends on the number and size of the values in the list. |
|`MAP` | 1B + 1B + 1B + min 1B | Basic metadata, property ID, additional metadata and the total size depends on the number and size of the values in the map. |
|`TEMPORAL_DATA` | 1B + 1B + 1B + min 1B + min 1B | Basic metadata, property ID, additional metadata, seconds, microseconds. Value of the seconds and microseconds is at least 1B, but probably 4B in most cases due to the large values they store. |
|`ZONED_TEMPORAL_DATA` | `TEMPORAL_DATA` + 1B + min 1B | Like `TEMPORAL_DATA`, but followed by timezone name length (1 byte) and string (1 byte per character). |
|`OFFSET_ZONED_TEMPORAL_DATA` | `TEMPORAL_DATA` + 2B | Like `TEMPORAL_DATA`, but followed by the offset from UTC (in minutes; always 2 bytes). |
|Value type |Size |Note
|-----------------|--------------------------------|-----------------------------------------------------------------------------------------------------|
|`NULL` |1B + 1B | The value is written in the first byte of the basic metadata. |
|`BOOL` |1B + 1B | The value is written in the first byte of the basic metadata.
|`INT` |1B + 1B + 1B, 2B, 4B or 8B | Basic metadata, property ID and the value depending on the size of the integer. |
|`DOUBLE` |1B + 1B + 8B | Basic metadata, property ID and the value |
|`STRING` |1B + 1B + 1B + min 1B | Basic metadata, property ID, additional metadata and lastly the value depending on the size of the string, where 1 ASCII character in the string takes up 1B.|
|`LIST` |1B + 1B + 1B + min 1B | Basic metadata, property ID, additional metadata and the total size depends on the number and size of the values in the list.|
|`MAP` |1B + 1B + 1B + min 1B | Basic metadata, property ID, additional metadata and the total size depends on the number and size of the values in the map.|
|`TEMPORAL_DATA` |1B + 1B + 1B + min 1B + min 1B | Basic metadata, property ID, additional metadata, seconds, microseconds. Value od the seconds and microseconds is at least 1B, but probably 4B in most cases due to the large values they store.|

### Marvel dataset use case

Expand Down
3 changes: 2 additions & 1 deletion pages/querying/differences-in-cypher-implementations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ RETURN val, valueType(val) = "INTEGER"
### Unsupported data types

- `POINT` -> Track progress on [GitHub](https://github.com/memgraph/memgraph/issues/1583) and add a comment if you require such a feature.
- `ZONED TIME` -> Open a [GitHub](https://github.com/memgraph/memgraph/) issue if you require such a feature.
- `ZONED DATETIME`, `ZONED TIME` -> Track progress on [GitHub](https://github.com/memgraph/memgraph/issues/612) and add a comment if you require such a feature.

### Unsupported functions

Expand Down Expand Up @@ -286,6 +286,7 @@ RETURN val, valueType(val) = "INTEGER"

**Datetime functions**:

- `datetime()`
- `time()`

## Memgraph's Cypher extension
Expand Down
21 changes: 10 additions & 11 deletions pages/querying/functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ This section contains the list of supported functions.
| Name | Signature | Description |
| --------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `duration` | `duration(value: string\|Duration) -> (Duration)` | Returns the data type that represents a period of time. |
| `date` | `date(value: string\|Date\|LocalDateTime) -> (Date)` | Returns the data type that represents a date with year, month, and day. |
| `localTime` | `localTime(value: string\|LocalTime\|LocalDateTime) -> (LocalTime)` | Returns the data type that represents time within a day without timezone. |
| `date` | `date(value: string\|Date\|LocalDateTime) -> (Date)` | Returns the data type that represents a date with year, month, and day. |
| `localTime` | `localTime(value: string\|LocalTime\|LocalDateTime) -> (LocalTime)` | Returns the data type that represents time within a day without timezone. |
| `localDateTime` | `localDateTime(value: string\|LocalDateTime)-> (LocalDateTime)` | Returns the data type that represents a date and local time. |
| `datetime` | `datetime(value: NULL\|string\|map)-> (ZonedDateTime)` | Returns the `ZonedDateTime` value defined by the given parameters. |

### Scalar functions

Expand Down Expand Up @@ -117,14 +116,14 @@ This section contains the list of supported functions.

### Aggregation functions

| Name | Signature | Description |
|-----------|--------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `avg` | `avg(row: int\|float) -> (float)` | Returns an average value of rows with numerical values generated with the `MATCH` or `UNWIND` clause. |
| `collect` | `collect(values: any) -> (List[any])` | Returns a single aggregated list containing returned values. |
| `count` | `count(values: any) -> (integer)` | Counts the number of non-null values returned by the expression. |
| `max` | `max(row: integer\|float\|temporal) -> (integer\|float\|temporal)` | Returns the maximum value in a set of values. Supported temporal types: `Date`, `LocalTime`, `LocalDateTime` and `ZonedDateTime`. |
| `min` | `min(row: integer\|float\|temporal) -> (integer\|float\|temporal)` | Returns the minimum value in a set of values. Supported temporal types: `Date`, `LocalTime`, `LocalDateTime` and `ZonedDateTime`. |
| `sum` | `sum(row: integer\|float) -> (integer\|float)` | Returns a sum value of rows with numerical values generated with the `MATCH` or `UNWIND` clause. |
| Name | Signature | Description |
|-----------|--------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| `avg` | `avg(row: int\|float) -> (float)` | Returns an average value of rows with numerical values generated with the `MATCH` or `UNWIND` clause. |
| `collect` | `collect(values: any) -> (List[any])` | Returns a single aggregated list containing returned values. |
| `count` | `count(values: any) -> (integer)` | Counts the number of non-null values returned by the expression. |
| `max` | `max(row: integer\|float\|temporal) -> (integer\|float\|temporal)` | Returns the maximum value in a set of values. Supported temporal types: `Date`, `LocalTime` and `LocalDateTime`. |
| `min` | `min(row: integer\|float\|temporal) -> (integer\|float\|temporal)` | Returns the minimum value in a set of values. Supported temporal types: `Date`, `LocalTime` and `LocalDateTime`. |
| `sum` | `sum(row: integer\|float) -> (integer\|float)` | Returns a sum value of rows with numerical values generated with the `MATCH` or `UNWIND` clause. |

<Callout type="info">
All aggregation functions can be used with the `DISTINCT` operator to perform calculations only on unique values. For example, `count(DISTINCT n.prop)` and `collect(DISTINCT n.prop)`.
Expand Down

0 comments on commit 6c4a5d4

Please sign in to comment.