2017-02-01 5 views
1

Ich habe eine Tabelle erstellt folgende Skript:Cassandra Parsen Datum

CREATE TABLE "TestTable2" (
    id uuid, 
    timestamp timestamp, 
    msg text, 
    priority int, 
    source text, 
    PRIMARY KEY (id, timestamp) 
); 

Nun bin ich Einfügen einer Zeile:

INSERT INTO "TestTable2" (id, timestamp, msg, source) values (uuid(), '2002-03-31 02:36:10', 'asdas dasdasd', 'system1'); 

und ich erhalte eine Fehlermeldung:

Unable to execute CQL script on 'UdcCluster':Unable to coerce '2002-03-31 02:36:10' to a formatted date (long)

Wenn ich den Tag des Monats auf 30 oder Stunde auf 22 ändere, wird die Anweisung erfolgreich ausgeführt. Kannst du mir bitte erklären, was mit dem Date falsch ist?

PS. Derselbe Fehler wird für '1998-03-29 02:12:13', '1987-03-29 02:55:21' und '1984-03-25 02:45:25' wiederholt. In jedem Fall ist es Ende März 2 Uhr morgens ...

Antwort

0

Sie versuchen, von einer bestimmten lokalen Zeit zu einer DateTime-Instanz zu gelangen, und Sie möchten, dass diese Karte robust gegen Sommerzeit ist.

Geben Sie die Zeitzone in dem Muster: yyyy-mm-DD HH: mm: ssZ

where Z is the RFC-822 4-digit time zone, expressing the time zone's difference from UTC. For example, for the date and time of Jan 2, 2003, at 04:05:00 AM, GMT:

If no time zone is specified, the time zone of the Cassandra coordinator node handing the write request is used. For accuracy, DataStax recommends specifying the time zone rather than relying on the time zone configured on the Cassandra nodes.

https://docs.datastax.com/en/cql/3.1/cql/cql_reference/timestamp_type_r.html