Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

DB Connector for data.world#332

Merged
n-riesco merged 36 commits intoplotly:masterfrom
kndungu:add-data-world
Jan 12, 2018
Merged

DB Connector for data.world#332
n-riesco merged 36 commits intoplotly:masterfrom
kndungu:add-data-world

Conversation

@kndungu
Copy link
Copy Markdown
Contributor

@kndungu kndungu commented Jan 2, 2018

No description provided.

@n-riesco
Copy link
Copy Markdown
Contributor

n-riesco commented Jan 3, 2018

Thank you for this PR!
I'll review it later today.

@kndungu
Copy link
Copy Markdown
Contributor Author

kndungu commented Jan 3, 2018

Sure thing! 👍

@kndungu kndungu force-pushed the add-data-world branch 6 times, most recently from 194bc00 to 2a497a7 Compare January 8, 2018 14:43
@kndungu
Copy link
Copy Markdown
Contributor Author

kndungu commented Jan 8, 2018

@n-riesco

I've been able to mock data.world API responses so the the PR now includes tests. Looking forward to your feedback.

Comment thread app/constants/constants.js Outdated
{
'label': 'Token',
'value': 'token',
'type': 'text',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'type': 'password'

Comment thread app/constants/constants.js Outdated
'description': 'The URL of the dataset or project on data.world'
},
{
'label': 'Token',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't feel strongly about it.

@tarzzz @chriddyp are you OK with using an URL here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Copy Markdown
Contributor

@n-riesco n-riesco Jan 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to create a new Promise, just return query(...

resolve(allTables);
})
.catch(err => {
reject(err);
Copy link
Copy Markdown
Contributor

@n-riesco n-riesco Jan 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger.log(err);
throw err;

})
.catch(err => {
Logger.log(err);
throw new Error(err);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw err

}

export function schemas(connection) {
return new Promise((resolve) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to create a new Promise, just return query(... and replace resolve({...}) by return {...}.

})
.catch(err => {
Logger.log(err);
throw new Error(err);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw err

export function query(queryString, connection) {
const { owner, id } = parseUrl(connection.url);
return new Promise((resolve, reject) => {
const queryStatement = `${queryString.replace(/-/g, '_')}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to create a new Promise, just return fetch(...

});
})
.catch(err => {
reject(err);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can return a promise and mocha will do the right thing:

 +    it('connect succeeds', function() {
 +        return connect(connection);
 +    });

@n-riesco
Copy link
Copy Markdown
Contributor

n-riesco commented Jan 8, 2018

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 data.world's logo. If I don't find it, I'll contact them.

@n-riesco
Copy link
Copy Markdown
Contributor

n-riesco commented Jan 9, 2018

Screenshot showing use of data.world's logo:
image

@n-riesco
Copy link
Copy Markdown
Contributor

n-riesco commented Jan 9, 2018

I've found that the use of data.world's logo is governed by https://data.world/terms/ and they require written permission.

When I wrote the DB2 connector (IBM also requires written permission to use their logo), I decided to use the text DB2 instead of IBM DB2's logo. We could do the same with this connector, if we don't want to deal with requesting the written permission.

});

it('tables returns list of tables', function(done) {
tables(connection).then(result => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Promise

});

it('query returns rows and column names', function(done) {
query('SELECT * FROM sampletable LIMIT 5', connection).then(result => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Promise

});

it('schemas returns table schemas', function(done) {
schemas(connection).then(result => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Promise

@kndungu
Copy link
Copy Markdown
Contributor Author

kndungu commented Jan 12, 2018

@tarzzz done.

@n-riesco n-riesco merged commit eecd62c into plotly:master Jan 12, 2018
@n-riesco
Copy link
Copy Markdown
Contributor

💃

@kndungu
Copy link
Copy Markdown
Contributor Author

kndungu commented Jan 12, 2018

💃 💃

@kndungu kndungu deleted the add-data-world branch January 12, 2018 15:59
@n-riesco n-riesco mentioned this pull request Apr 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants