{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/21590","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/21590/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/21590/comments","events_url":"https://api.github.com/repos/apache/spark/issues/21590/events","html_url":"https://github.com/apache/spark/pull/21590","id":333544979,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1NzMwNzUy","number":21590,"title":"[SPARK-24423][SQL] Add a new option  for JDBC sources","user":{"login":"dilipbiswal","id":14225158,"node_id":"MDQ6VXNlcjE0MjI1MTU4","avatar_url":"https://avatars0.githubusercontent.com/u/14225158?v=4","gravatar_id":"","url":"https://api.github.com/users/dilipbiswal","html_url":"https://github.com/dilipbiswal","followers_url":"https://api.github.com/users/dilipbiswal/followers","following_url":"https://api.github.com/users/dilipbiswal/following{/other_user}","gists_url":"https://api.github.com/users/dilipbiswal/gists{/gist_id}","starred_url":"https://api.github.com/users/dilipbiswal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilipbiswal/subscriptions","organizations_url":"https://api.github.com/users/dilipbiswal/orgs","repos_url":"https://api.github.com/users/dilipbiswal/repos","events_url":"https://api.github.com/users/dilipbiswal/events{/privacy}","received_events_url":"https://api.github.com/users/dilipbiswal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-06-19T07:10:33Z","updated_at":"2018-06-20T05:38:19Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/21590","html_url":"https://github.com/apache/spark/pull/21590","diff_url":"https://github.com/apache/spark/pull/21590.diff","patch_url":"https://github.com/apache/spark/pull/21590.patch"},"body":"## What changes were proposed in this pull request?\r\nHere is the description in the JIRA -\r\n\r\nCurrently, our JDBC connector provides the option `dbtable` for users to specify the to-be-loaded JDBC source table. \r\n\r\n ```SQL\r\n val jdbcDf = spark.read\r\n   .format(\"jdbc\")\r\n   .option(\"*dbtable*\", \"dbName.tableName\")\r\n   .options(jdbcCredentials: Map)\r\n   .load()\r\n ```\r\n\r\nNormally, users do not fetch the whole JDBC table due to the poor performance/throughput of JDBC. Thus, they normally just fetch a small set of tables. For advanced users, they can pass a subquery as the option.   \r\n\r\n ```SQL\r\n val query = \"\"\" (select * from tableName limit 10) as tmp \"\"\"\r\n val jdbcDf = spark.read\r\n   .format(\"jdbc\")\r\n   .option(\"*dbtable*\", query)\r\n   .options(jdbcCredentials: Map)\r\n   .load()\r\n ```\r\nHowever, this is straightforward to end users. We should simply allow users to specify the query by a new option `query`. We will handle the complexity for them. \r\n\r\n ```SQL\r\n val query = \"\"\"select * from tableName limit 10\"\"\"\r\n val jdbcDf = spark.read\r\n   .format(\"jdbc\")\r\n   .option(\"*{color:#ff0000}query{color}*\", query)\r\n   .options(jdbcCredentials: Map)\r\n   .load()\r\n```\r\n\r\n## How was this patch tested?\r\nAdded tests in JDBCSuite and JDBCWriterSuite.\r\nAlso tested against MySQL, Postgress, Oracle, DB2 (using docker infrastructure) to make sure there are no syntax issues.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/398629990","html_url":"https://github.com/apache/spark/pull/21590#issuecomment-398629990","issue_url":"https://api.github.com/repos/apache/spark/issues/21590","id":398629990,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODYyOTk5MA==","user":{"login":"SparkQA","id":8108735,"node_id":"MDQ6VXNlcjgxMDg3MzU=","avatar_url":"https://avatars1.githubusercontent.com/u/8108735?v=4","gravatar_id":"","url":"https://api.github.com/users/SparkQA","html_url":"https://github.com/SparkQA","followers_url":"https://api.github.com/users/SparkQA/followers","following_url":"https://api.github.com/users/SparkQA/following{/other_user}","gists_url":"https://api.github.com/users/SparkQA/gists{/gist_id}","starred_url":"https://api.github.com/users/SparkQA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SparkQA/subscriptions","organizations_url":"https://api.github.com/users/SparkQA/orgs","repos_url":"https://api.github.com/users/SparkQA/repos","events_url":"https://api.github.com/users/SparkQA/events{/privacy}","received_events_url":"https://api.github.com/users/SparkQA/received_events","type":"User","site_admin":false},"created_at":"2018-06-20T05:38:19Z","updated_at":"2018-06-20T05:38:19Z","author_association":"NONE","body":"**[Test build #92118 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92118/testReport)** for PR 21590 at commit [`8920793`](https://github.com/apache/spark/commit/8920793d480de76e3cbe9d25f66e624ad6183503)."}}
{"actor":{"display_login":"SparkQA"}}