Skip to content
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

oetl import does not rename mysql fields #7307

Closed
on-meetsys opened this issue Apr 5, 2017 · 3 comments
Closed

oetl import does not rename mysql fields #7307

on-meetsys opened this issue Apr 5, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@on-meetsys
Copy link

OrientDB Version: 2.2.17

Java Version: 1.8.0_111

OS: debian 8

Expected behavior

I am importing tables from mysql to orientdb thanks to oetl.sh.
I use the following setup :

{
  "config": {
    "log": "debug"
  },
  "extractor" : {
    "jdbc": { "driver": "com.mysql.jdbc.Driver",
              "url": "jdbc:mysql://localhost/DBFROM",
              "userName": "mysqluser",
              "userPassword": "mysqlpwd",
              "query": "SELECT m.firstname, m.name as lastname FROM member m" }
  },
  "transformers" : [
    {"vertex": { "class":"Member"}}
  ],
  "loader" : {
    "orientdb": {
      "dbType": "graph",
      "dbURL": "remote:localhost/mydb",
      "dbUser": "admin",
      "dbPassword": "admin",
      "serverUser": "root",
      "serverPassword": "root",
      "standardElementConstraints": false,
      "dbAutoCreate": true
    }
  }
}

Actual behavior

In orientdb studio, I query members :
SELECT FROM Member

the result returns members with {firstname, name} fields and not {firstname,lastname}

If I look at Member class, the fields are well {firstname,lastname} though.

It looks like the fields are not the same in the class and in the data.

Steps to reproduce

see before

@lvca lvca added the bug label Apr 5, 2017
@robfrank
Copy link
Contributor

robfrank commented Apr 6, 2017

Can you try to import on a clean db WITHOUT aliases?

SELECT firstname, name  FROM member

Thanks

@on-meetsys
Copy link
Author

As expected, this works perfectly : the @Class and the SELECT results both have {firstname,name}

This is the workaround I use to import my data, renaming name to lastname in the orientd database afterwards with :

ALTER PROPERTY Member.name NAME lastname;
UPDATE Member REMOVE name;

(btw, I wonder why I do have to remove the 'name' field, which is still present in data after the ALTER PROPERTY...)

@robfrank
Copy link
Contributor

robfrank commented Apr 6, 2017

Discovered. The JDBC extractor was fetching the column name using getColumnName instead of getColumnLabel. The latter uses the alias, if present, or the column name, if not.
This fix will be available in the next 2.2.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants