DB Connector for data.world#332
Conversation
c05c0d7 to
99cadf3
Compare
|
Thank you for this PR! |
|
Sure thing! 👍 |
194bc00 to
2a497a7
Compare
|
I've been able to mock data.world API responses so the the PR now includes tests. Looking forward to your feedback. |
| { | ||
| 'label': 'Token', | ||
| 'value': 'token', | ||
| 'type': 'text', |
| 'description': 'The URL of the dataset or project on data.world' | ||
| }, | ||
| { | ||
| 'label': 'Token', |
There was a problem hiding this comment.
data.world provides two API tokens: Read/Write and Admin.
To help users, we could re-label this input as Read/Write API Token.
| ], // TODO - password options for apache drill | ||
| [DIALECTS.DATA_WORLD]: [ | ||
| { | ||
| 'label': 'Dataset/Project URL', |
There was a problem hiding this comment.
I'd like to change this. Instead of having the user to input an URL and the connector to parse the URL to determine owner and dataset id. I'd like the user to input owner and id:
- this is more consistent with the existing connectors
- and it simplifies the code (no need for
getPathNames)
There was a problem hiding this comment.
Hi, @n-riesco, unless you feel strongly about this, we would like to use the URL. That would be consistent with our other connectors work (e.g. Tableau and Google Data Studio) and is more usable, as users only have one value to copy and paste, which is readily available on the browser for the dataset they are looking at. We do a little bit of extra work in code to spare the user in real life. Also, using URIs that contain information to parse out isn't without a precedent, the most common is JDBC.
There was a problem hiding this comment.
is more usable, as users only have one value to copy and paste, which is readily available on the browser for the dataset they are looking at
This sounds like a good reason to me 👍
|
|
||
| export function connect(connection) { | ||
| const { owner, id } = parseUrl(connection.url); | ||
| return new Promise((resolve, reject) => { |
There was a problem hiding this comment.
No need to create a new Promise, just return fetch(... and replace reject(json) by throw new Error(JSON.stringify(json)).
| } | ||
|
|
||
| export function tables(connection) { | ||
| return new Promise((resolve, reject) => { |
There was a problem hiding this comment.
No need to create a new Promise, just return query(...
| resolve(allTables); | ||
| }) | ||
| .catch(err => { | ||
| reject(err); |
There was a problem hiding this comment.
Logger.log(err);
throw err;
| }) | ||
| .catch(err => { | ||
| Logger.log(err); | ||
| throw new Error(err); |
| } | ||
|
|
||
| export function schemas(connection) { | ||
| return new Promise((resolve) => { |
There was a problem hiding this comment.
No need to create a new Promise, just return query(... and replace resolve({...}) by return {...}.
| }) | ||
| .catch(err => { | ||
| Logger.log(err); | ||
| throw new Error(err); |
| export function query(queryString, connection) { | ||
| const { owner, id } = parseUrl(connection.url); | ||
| return new Promise((resolve, reject) => { | ||
| const queryStatement = `${queryString.replace(/-/g, '_')}`; |
There was a problem hiding this comment.
This substitution could potentially break the SQL query,
I'd move this code (that replaces - with _) into tables and schemas to ensure the user only sees table names without -.
|
|
||
| export function query(queryString, connection) { | ||
| const { owner, id } = parseUrl(connection.url); | ||
| return new Promise((resolve, reject) => { |
There was a problem hiding this comment.
No need to create a new Promise, just return fetch(...
| }); | ||
| }) | ||
| .catch(err => { | ||
| reject(err); |
There was a problem hiding this comment.
Logger.log(err);
throw err;
| import * as IbmDb2 from './ibmdb2'; | ||
| import * as ApacheLivy from './livy'; | ||
| import * as ApacheImpala from './impala'; | ||
| import * as DataWorld from './DataWorld'; |
There was a problem hiding this comment.
Most of the project uses lowercase filenames and I'm planning to get rid of the exceptions.
Would you make this file lowercase?
|
|
||
| describe('Data World:', function () { | ||
|
|
||
| it('connect succeeds', function(done) { |
There was a problem hiding this comment.
You can return a promise and mocha will do the right thing:
+ it('connect succeeds', function() {
+ return connect(connection);
+ });|
This looks very good. Please, see my feedback. I don't have any more time today, but tomorrow I'm planning to search for the license of |
|
I've found that the use of When I wrote the DB2 connector (IBM also requires written permission to use their logo), I decided to use the text |
| }); | ||
|
|
||
| it('tables returns list of tables', function(done) { | ||
| tables(connection).then(result => { |
| }); | ||
|
|
||
| it('query returns rows and column names', function(done) { | ||
| query('SELECT * FROM sampletable LIMIT 5', connection).then(result => { |
| }); | ||
|
|
||
| it('schemas returns table schemas', function(done) { | ||
| schemas(connection).then(result => { |
c423a3a to
de82e14
Compare
|
@tarzzz done. |
|
💃 |
|
💃 💃 |

No description provided.