{"action":"created","comment":{"url":"https://api.github.com/repos/dask/dask/pulls/comments/105565825","pull_request_review_id":26452149,"id":105565825,"diff_hunk":"@@ -0,0 +1,86 @@\n+from __future__ import print_function, division, absolute_import\n+\n+import io\n+import pytest\n+from dask.utils import tmpfile\n+from dask.dataframe.io.sql import read_sql_table\n+pd = pytest.importorskip('pandas')\n+dd = pytest.importorskip('dask.dataframe')\n+pytest.importorskip('sqlalchemy')\n+pytest.importorskip('sqlite3')\n+\n+\n+data = \"\"\"\n+name,number,age,negish\n+Alice,0,33,-5\n+Bob,1,40,-3\n+Chris,2,22,3\n+Dora,3,16,5\n+Edith,4,53,0\n+Francis,5,30,0\n+Garreth,6,20,0\n+\"\"\"\n+\n+df = pd.read_csv(io.StringIO(data), index_col='number')\n+\n+\n+@pytest.yield_fixture\n+def db():\n+    with tmpfile() as f:\n+        uri = 'sqlite:///%s' % f\n+        df.to_sql('test', uri, index=True, if_exists='replace')\n+        yield uri\n+\n+\n+def test_simple(db):\n+    # single chunk\n+    data = read_sql_table('test', db, partitions=2, index_col='number').compute()\n+    assert (data.name == df.name).all()\n+    assert data.index.name == 'number'\n+    assert (data.columns == df.columns).all()\n+\n+\n+def test_partitions(db):\n+    data = read_sql_table('test', db, columns=list(df.columns), partitions=2,\n+                          index_col='number')\n+    assert len(data.divisions) == 3\n+    assert (data.name.compute() == df.name).all()\n+    data = read_sql_table('test', db, columns=['name'], partitions=6,\n+                          index_col=\"number\").compute()\n+    assert (data.name == df.name).all()\n+\n+    data = read_sql_table('test', db, columns=['name'], partitions=[0, 2, 4],\n+                          index_col=\"number\")\n+    assert data.divisions == (0, 2, 4)\n+    assert data.index.max().compute() == 3\n+\n+\n+def test_range(db):\n+    data = read_sql_table('test', db, partitions=2, index_col='number', limits=[1, 4])\n+    assert data.index.min().compute() == 1\n+    assert data.index.max().compute() == 3\n+\n+\n+def test_datetimes():\n+    import datetime\n+    now = datetime.datetime.now()\n+    d = datetime.timedelta(seconds=1)\n+    df = pd.DataFrame({'a': list('ghjkl'), 'b': [now + i*d for i in range(2, -3, -1)]})","path":"dask/dataframe/io/tests/test_sql.py","position":68,"original_position":68,"commit_id":"bfd3a5f349f798fec1cf07b3e59ecdefefd44725","original_commit_id":"bfd3a5f349f798fec1cf07b3e59ecdefefd44725","user":{"login":"mrocklin","id":306380,"avatar_url":"https://avatars0.githubusercontent.com/u/306380?v=3","gravatar_id":"","url":"https://api.github.com/users/mrocklin","html_url":"https://github.com/mrocklin","followers_url":"https://api.github.com/users/mrocklin/followers","following_url":"https://api.github.com/users/mrocklin/following{/other_user}","gists_url":"https://api.github.com/users/mrocklin/gists{/gist_id}","starred_url":"https://api.github.com/users/mrocklin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrocklin/subscriptions","organizations_url":"https://api.github.com/users/mrocklin/orgs","repos_url":"https://api.github.com/users/mrocklin/repos","events_url":"https://api.github.com/users/mrocklin/events{/privacy}","received_events_url":"https://api.github.com/users/mrocklin/received_events","type":"User","site_admin":false},"body":"In the future you might want to check out the options in `pandas.util.testing`.  For example these: https://github.com/dask/distributed/blob/master/distributed/protocol/tests/test_pandas.py#L35-L46 and `makeTimeDataFrame` in particular.","created_at":"2017-03-12T19:05:08Z","updated_at":"2017-03-12T19:07:13Z","html_url":"https://github.com/dask/dask/pull/1181#discussion_r105565825","pull_request_url":"https://api.github.com/repos/dask/dask/pulls/1181","_links":{"self":{"href":"https://api.github.com/repos/dask/dask/pulls/comments/105565825"},"html":{"href":"https://github.com/dask/dask/pull/1181#discussion_r105565825"},"pull_request":{"href":"https://api.github.com/repos/dask/dask/pulls/1181"}}},"pull_request":{"url":"https://api.github.com/repos/dask/dask/pulls/1181","id":71478108,"html_url":"https://github.com/dask/dask/pull/1181","diff_url":"https://github.com/dask/dask/pull/1181.diff","patch_url":"https://github.com/dask/dask/pull/1181.patch","issue_url":"https://api.github.com/repos/dask/dask/issues/1181","number":1181,"state":"open","locked":false,"title":"Add sql loader","user":{"login":"martindurant","id":6042212,"avatar_url":"https://avatars2.githubusercontent.com/u/6042212?v=3","gravatar_id":"","url":"https://api.github.com/users/martindurant","html_url":"https://github.com/martindurant","followers_url":"https://api.github.com/users/martindurant/followers","following_url":"https://api.github.com/users/martindurant/following{/other_user}","gists_url":"https://api.github.com/users/martindurant/gists{/gist_id}","starred_url":"https://api.github.com/users/martindurant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martindurant/subscriptions","organizations_url":"https://api.github.com/users/martindurant/orgs","repos_url":"https://api.github.com/users/martindurant/repos","events_url":"https://api.github.com/users/martindurant/events{/privacy}","received_events_url":"https://api.github.com/users/martindurant/received_events","type":"User","site_admin":false},"body":"Fixes #943 : reading only here, and (columns of a) table only, not general query. \n","created_at":"2016-05-25T23:16:30Z","updated_at":"2017-03-12T19:07:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f7a3ba56271f2980967457bba155292067792a9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dask/dask/pulls/1181/commits","review_comments_url":"https://api.github.com/repos/dask/dask/pulls/1181/comments","review_comment_url":"https://api.github.com/repos/dask/dask/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dask/dask/issues/1181/comments","statuses_url":"https://api.github.com/repos/dask/dask/statuses/bfd3a5f349f798fec1cf07b3e59ecdefefd44725","head":{"label":"martindurant:sql","ref":"sql","sha":"bfd3a5f349f798fec1cf07b3e59ecdefefd44725","user":{"login":"martindurant","id":6042212,"avatar_url":"https://avatars2.githubusercontent.com/u/6042212?v=3","gravatar_id":"","url":"https://api.github.com/users/martindurant","html_url":"https://github.com/martindurant","followers_url":"https://api.github.com/users/martindurant/followers","following_url":"https://api.github.com/users/martindurant/following{/other_user}","gists_url":"https://api.github.com/users/martindurant/gists{/gist_id}","starred_url":"https://api.github.com/users/martindurant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martindurant/subscriptions","organizations_url":"https://api.github.com/users/martindurant/orgs","repos_url":"https://api.github.com/users/martindurant/repos","events_url":"https://api.github.com/users/martindurant/events{/privacy}","received_events_url":"https://api.github.com/users/martindurant/received_events","type":"User","site_admin":false},"repo":{"id":59704001,"name":"dask","full_name":"martindurant/dask","owner":{"login":"martindurant","id":6042212,"avatar_url":"https://avatars2.githubusercontent.com/u/6042212?v=3","gravatar_id":"","url":"https://api.github.com/users/martindurant","html_url":"https://github.com/martindurant","followers_url":"https://api.github.com/users/martindurant/followers","following_url":"https://api.github.com/users/martindurant/following{/other_user}","gists_url":"https://api.github.com/users/martindurant/gists{/gist_id}","starred_url":"https://api.github.com/users/martindurant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martindurant/subscriptions","organizations_url":"https://api.github.com/users/martindurant/orgs","repos_url":"https://api.github.com/users/martindurant/repos","events_url":"https://api.github.com/users/martindurant/events{/privacy}","received_events_url":"https://api.github.com/users/martindurant/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/martindurant/dask","description":"Versatile parallel programming with task scheduling","fork":true,"url":"https://api.github.com/repos/martindurant/dask","forks_url":"https://api.github.com/repos/martindurant/dask/forks","keys_url":"https://api.github.com/repos/martindurant/dask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/martindurant/dask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/martindurant/dask/teams","hooks_url":"https://api.github.com/repos/martindurant/dask/hooks","issue_events_url":"https://api.github.com/repos/martindurant/dask/issues/events{/number}","events_url":"https://api.github.com/repos/martindurant/dask/events","assignees_url":"https://api.github.com/repos/martindurant/dask/assignees{/user}","branches_url":"https://api.github.com/repos/martindurant/dask/branches{/branch}","tags_url":"https://api.github.com/repos/martindurant/dask/tags","blobs_url":"https://api.github.com/repos/martindurant/dask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/martindurant/dask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/martindurant/dask/git/refs{/sha}","trees_url":"https://api.github.com/repos/martindurant/dask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/martindurant/dask/statuses/{sha}","languages_url":"https://api.github.com/repos/martindurant/dask/languages","stargazers_url":"https://api.github.com/repos/martindurant/dask/stargazers","contributors_url":"https://api.github.com/repos/martindurant/dask/contributors","subscribers_url":"https://api.github.com/repos/martindurant/dask/subscribers","subscription_url":"https://api.github.com/repos/martindurant/dask/subscription","commits_url":"https://api.github.com/repos/martindurant/dask/commits{/sha}","git_commits_url":"https://api.github.com/repos/martindurant/dask/git/commits{/sha}","comments_url":"https://api.github.com/repos/martindurant/dask/comments{/number}","issue_comment_url":"https://api.github.com/repos/martindurant/dask/issues/comments{/number}","contents_url":"https://api.github.com/repos/martindurant/dask/contents/{+path}","compare_url":"https://api.github.com/repos/martindurant/dask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/martindurant/dask/merges","archive_url":"https://api.github.com/repos/martindurant/dask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/martindurant/dask/downloads","issues_url":"https://api.github.com/repos/martindurant/dask/issues{/number}","pulls_url":"https://api.github.com/repos/martindurant/dask/pulls{/number}","milestones_url":"https://api.github.com/repos/martindurant/dask/milestones{/number}","notifications_url":"https://api.github.com/repos/martindurant/dask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/martindurant/dask/labels{/name}","releases_url":"https://api.github.com/repos/martindurant/dask/releases{/id}","deployments_url":"https://api.github.com/repos/martindurant/dask/deployments","created_at":"2016-05-25T23:14:24Z","updated_at":"2016-05-25T23:14:25Z","pushed_at":"2017-03-12T18:52:44Z","git_url":"git://github.com/martindurant/dask.git","ssh_url":"git@github.com:martindurant/dask.git","clone_url":"https://github.com/martindurant/dask.git","svn_url":"https://github.com/martindurant/dask","homepage":"http://dask.pydata.org","size":13453,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dask:master","ref":"master","sha":"d39bf762b962e533236b509e246b909e09765915","user":{"login":"dask","id":17131925,"avatar_url":"https://avatars2.githubusercontent.com/u/17131925?v=3","gravatar_id":"","url":"https://api.github.com/users/dask","html_url":"https://github.com/dask","followers_url":"https://api.github.com/users/dask/followers","following_url":"https://api.github.com/users/dask/following{/other_user}","gists_url":"https://api.github.com/users/dask/gists{/gist_id}","starred_url":"https://api.github.com/users/dask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dask/subscriptions","organizations_url":"https://api.github.com/users/dask/orgs","repos_url":"https://api.github.com/users/dask/repos","events_url":"https://api.github.com/users/dask/events{/privacy}","received_events_url":"https://api.github.com/users/dask/received_events","type":"Organization","site_admin":false},"repo":{"id":28782747,"name":"dask","full_name":"dask/dask","owner":{"login":"dask","id":17131925,"avatar_url":"https://avatars2.githubusercontent.com/u/17131925?v=3","gravatar_id":"","url":"https://api.github.com/users/dask","html_url":"https://github.com/dask","followers_url":"https://api.github.com/users/dask/followers","following_url":"https://api.github.com/users/dask/following{/other_user}","gists_url":"https://api.github.com/users/dask/gists{/gist_id}","starred_url":"https://api.github.com/users/dask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dask/subscriptions","organizations_url":"https://api.github.com/users/dask/orgs","repos_url":"https://api.github.com/users/dask/repos","events_url":"https://api.github.com/users/dask/events{/privacy}","received_events_url":"https://api.github.com/users/dask/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dask/dask","description":"Versatile parallel programming with task scheduling","fork":false,"url":"https://api.github.com/repos/dask/dask","forks_url":"https://api.github.com/repos/dask/dask/forks","keys_url":"https://api.github.com/repos/dask/dask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dask/dask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dask/dask/teams","hooks_url":"https://api.github.com/repos/dask/dask/hooks","issue_events_url":"https://api.github.com/repos/dask/dask/issues/events{/number}","events_url":"https://api.github.com/repos/dask/dask/events","assignees_url":"https://api.github.com/repos/dask/dask/assignees{/user}","branches_url":"https://api.github.com/repos/dask/dask/branches{/branch}","tags_url":"https://api.github.com/repos/dask/dask/tags","blobs_url":"https://api.github.com/repos/dask/dask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dask/dask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dask/dask/git/refs{/sha}","trees_url":"https://api.github.com/repos/dask/dask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dask/dask/statuses/{sha}","languages_url":"https://api.github.com/repos/dask/dask/languages","stargazers_url":"https://api.github.com/repos/dask/dask/stargazers","contributors_url":"https://api.github.com/repos/dask/dask/contributors","subscribers_url":"https://api.github.com/repos/dask/dask/subscribers","subscription_url":"https://api.github.com/repos/dask/dask/subscription","commits_url":"https://api.github.com/repos/dask/dask/commits{/sha}","git_commits_url":"https://api.github.com/repos/dask/dask/git/commits{/sha}","comments_url":"https://api.github.com/repos/dask/dask/comments{/number}","issue_comment_url":"https://api.github.com/repos/dask/dask/issues/comments{/number}","contents_url":"https://api.github.com/repos/dask/dask/contents/{+path}","compare_url":"https://api.github.com/repos/dask/dask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dask/dask/merges","archive_url":"https://api.github.com/repos/dask/dask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dask/dask/downloads","issues_url":"https://api.github.com/repos/dask/dask/issues{/number}","pulls_url":"https://api.github.com/repos/dask/dask/pulls{/number}","milestones_url":"https://api.github.com/repos/dask/dask/milestones{/number}","notifications_url":"https://api.github.com/repos/dask/dask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dask/dask/labels{/name}","releases_url":"https://api.github.com/repos/dask/dask/releases{/id}","deployments_url":"https://api.github.com/repos/dask/dask/deployments","created_at":"2015-01-04T18:50:00Z","updated_at":"2017-03-12T05:58:42Z","pushed_at":"2017-03-12T18:52:45Z","git_url":"git://github.com/dask/dask.git","ssh_url":"git@github.com:dask/dask.git","clone_url":"https://github.com/dask/dask.git","svn_url":"https://github.com/dask/dask","homepage":"http://dask.pydata.org","size":13393,"stargazers_count":1382,"watchers_count":1382,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":245,"mirror_url":null,"open_issues_count":189,"forks":245,"open_issues":189,"watchers":1382,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dask/dask/pulls/1181"},"html":{"href":"https://github.com/dask/dask/pull/1181"},"issue":{"href":"https://api.github.com/repos/dask/dask/issues/1181"},"comments":{"href":"https://api.github.com/repos/dask/dask/issues/1181/comments"},"review_comments":{"href":"https://api.github.com/repos/dask/dask/pulls/1181/comments"},"review_comment":{"href":"https://api.github.com/repos/dask/dask/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dask/dask/pulls/1181/commits"},"statuses":{"href":"https://api.github.com/repos/dask/dask/statuses/bfd3a5f349f798fec1cf07b3e59ecdefefd44725"}}}}
{"actor":{"display_login":"mrocklin"}}