{"action":"created","issue":{"url":"https://api.github.com/repos/apache/incubator-carbondata/issues/126","repository_url":"https://api.github.com/repos/apache/incubator-carbondata","labels_url":"https://api.github.com/repos/apache/incubator-carbondata/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/apache/incubator-carbondata/issues/126/comments","events_url":"https://api.github.com/repos/apache/incubator-carbondata/issues/126/events","html_url":"https://github.com/apache/incubator-carbondata/pull/126","id":175103800,"number":126,"title":"[CARBONDATA-212] Use SQLContext to read CarbonData files","user":{"login":"jackylk","id":6500698,"avatar_url":"https://avatars.githubusercontent.com/u/6500698?v=3","gravatar_id":"","url":"https://api.github.com/users/jackylk","html_url":"https://github.com/jackylk","followers_url":"https://api.github.com/users/jackylk/followers","following_url":"https://api.github.com/users/jackylk/following{/other_user}","gists_url":"https://api.github.com/users/jackylk/gists{/gist_id}","starred_url":"https://api.github.com/users/jackylk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackylk/subscriptions","organizations_url":"https://api.github.com/users/jackylk/orgs","repos_url":"https://api.github.com/users/jackylk/repos","events_url":"https://api.github.com/users/jackylk/events{/privacy}","received_events_url":"https://api.github.com/users/jackylk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-05T16:40:28Z","updated_at":"2016-09-14T15:55:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/incubator-carbondata/pulls/126","html_url":"https://github.com/apache/incubator-carbondata/pull/126","diff_url":"https://github.com/apache/incubator-carbondata/pull/126.diff","patch_url":"https://github.com/apache/incubator-carbondata/pull/126.patch"},"body":"In this PR, user can use SQLContext instead of CarbonContext to read CarbonData files.\r\nExample:\r\n```\r\n    // Save a DataFrame to CarbonData files\r\n    df.write\r\n      .format(\"carbondata\")\r\n      .option(\"tableName\", \"carbon1\")\r\n      .mode(SaveMode.Overwrite)\r\n      .save()\r\n\r\n    // use SQLContext to read CarbonData files\r\n    val sqlContext = new SQLContext(sc)\r\n    sqlContext.sql(\r\n      \"\"\"\r\n        | CREATE TEMPORARY TABLE source\r\n        | (c1 string, c2 string, c3 long)\r\n        | USING org.apache.spark.sql.CarbonSource\r\n        | OPTIONS (path './examples/target/store/default/carbon1',       // file path\r\n      \"\"\".stripMargin)\r\n    sqlContext.sql(\"SELECT c1, c2, count(*) FROM source WHERE c3 > 100 GROUP BY c1, c2\").show\r\n```\r\n\r\nUser can also create table without providing schema, schema will be read from the CarbonData file:\r\n```\r\n    sqlContext.sql(\r\n      \"\"\"\r\n        | CREATE TEMPORARY TABLE source\r\n        | USING org.apache.spark.sql.CarbonSource\r\n        | OPTIONS (path './examples/target/store/default/carbon1',       // file path\r\n      \"\"\".stripMargin)\r\n```\r\n\r\nSave to CarbonData file is still using CarbonContext, but in read path, it can use SQLContext datasource API."},"comment":{"url":"https://api.github.com/repos/apache/incubator-carbondata/issues/comments/247061238","html_url":"https://github.com/apache/incubator-carbondata/pull/126#issuecomment-247061238","issue_url":"https://api.github.com/repos/apache/incubator-carbondata/issues/126","id":247061238,"user":{"login":"chenliang613","id":8075709,"avatar_url":"https://avatars.githubusercontent.com/u/8075709?v=3","gravatar_id":"","url":"https://api.github.com/users/chenliang613","html_url":"https://github.com/chenliang613","followers_url":"https://api.github.com/users/chenliang613/followers","following_url":"https://api.github.com/users/chenliang613/following{/other_user}","gists_url":"https://api.github.com/users/chenliang613/gists{/gist_id}","starred_url":"https://api.github.com/users/chenliang613/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenliang613/subscriptions","organizations_url":"https://api.github.com/users/chenliang613/orgs","repos_url":"https://api.github.com/users/chenliang613/repos","events_url":"https://api.github.com/users/chenliang613/events{/privacy}","received_events_url":"https://api.github.com/users/chenliang613/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T15:55:55Z","updated_at":"2016-09-14T15:55:55Z","body":"verified ok: don't need to provide schema,  can automatically get metadata information.\r\n\r\nLGTM"}}
{"actor":{"display_login":"chenliang613"}}