Search code examples
orientdb

OrientDB ETL importing date field


I have imported a large table containing demographic information and my ETL JSON looks like this

{
 "config": {
"log": "debug"
},
 "extractor" : {
  "jdbc": { "driver": "com.mysql.jdbc.Driver",
            "url": "jdbc:mysql://localhost/avicenna",
          "userName": "xxxxxx",
          "userPassword": "xxxxxxxxxxxx",
          "query": "select * from patients",
          "fetchSize": 1000 
          }
 },
 "transformers" : [
  { "vertex": { "class": "patients"} }
 ],
 "loader" : {
   "orientdb": {
  "dbURL": "plocal:c:/tools/orientdb-community-2.0.5/databases/Avicenna",
  "dbType": "graph",
  "dbAutoCreate": true
  }
 }
 }

My patients class in OrientDB is defined as follows

-------------------------------+-------------+
 NAME                          | TYPE        |
-------------------------------+-------------+
 PatientID                     | INTEGER     |
 MaritalStatus                 | STRING      |
 DOB                           | DATE        |
 Sex                           | STRING      |
-------------------------------+-------------+

Although MySQL patients table has DOB field created as "Date" all imported data will nevertheless display full DateTime

orientdb {db=avicenna}> select from patients limit 3

  ----+-----+--------+---------+-------------------+-------------+----+------------
#   |@RID |@CLASS  |PatientID|DOB                |MaritalStatus|Sex  |out_admitted
     ----+-----+--------+---------+-------------------+-------------+----+------------
0   |#18:0|patients|1022     |1996-02-29 00:00:00|Single       |M   |[size=5]
1   |#18:1|patients|1033     |1996-02-02 00:00:00|Single       |M   |[size=1]
2   |#18:2|patients|1089     |1995-07-21 00:00:00|Single       |F   |[size=1]
----+-----+--------+---------+-------------------+-------------+----+------------

is there something I am doing wrong with the import script? And now how can I clean up the dates in OrientDB?


Solution

  • I believe there's nothing wrong with your script, that's just the way Dates are stored.

    create property V.someDate date
    create property V.someDateTime datetime
    
    insert into V set someDate = sysdate(), someDateTime = sysdate()
    
    select from V
    

    enter image description here