{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-hawq/pulls/comments/51835264","id":51835264,"diff_hunk":"@@ -0,0 +1,288 @@\n+package org.apache.hawq.pxf.plugins.json;\n+\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ * \n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ * \n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+import java.io.File;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import org.apache.hadoop.fs.Path;\n+import org.apache.hawq.pxf.api.Fragmenter;\n+import org.apache.hawq.pxf.api.ReadAccessor;\n+import org.apache.hawq.pxf.api.ReadResolver;\n+import org.apache.hawq.pxf.api.io.DataType;\n+import org.apache.hawq.pxf.plugins.hdfs.HdfsDataFragmenter;\n+import org.apache.hawq.pxf.plugins.json.JsonAccessor;\n+import org.apache.hawq.pxf.plugins.json.JsonResolver;\n+import org.junit.After;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+public class JsonExtensionTest extends PxfUnit {\n+\n+\tprivate List<Pair<String, DataType>> columnDefs = null;\n+\tprivate List<Pair<String, String>> extraParams = new ArrayList<Pair<String, String>>();\n+\n+\t@Before\n+\tpublic void before() {\n+\n+\t\tcolumnDefs = new ArrayList<Pair<String, DataType>>();\n+\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"created_at\", DataType.TEXT));\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"id\", DataType.BIGINT));\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"text\", DataType.TEXT));\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"user.screen_name\", DataType.TEXT));\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"entities.hashtags[0]\", DataType.TEXT));\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"coordinates.coordinates[0]\", DataType.FLOAT8));\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"coordinates.coordinates[1]\", DataType.FLOAT8));\n+\t}\n+\n+\t@After\n+\tpublic void cleanup() throws Exception {\n+\t\tcolumnDefs.clear();\n+\t\textraParams.clear();\n+\t}\n+\n+\t@Test\n+\tpublic void testCompressedMultilineJsonFile() throws Exception {\n+\n+\t\textraParams.add(new Pair<String, String>(\"IDENTIFIER\", \"created_at\"));\n+\n+\t\tList<String> output = new ArrayList<String>();\n+\n+\t\toutput.add(\"Fri Jun 07 22:45:02 +0000 2013,343136547115253761,text1,SpreadButter,tweetCongress,,\");\n+\t\toutput.add(\"Fri Jun 07 22:45:02 +0000 2013,343136547123646465,text2,patronusdeadly,,,\");\n+\t\toutput.add(\"Fri Jun 07 22:45:02 +0000 2013,343136547136233472,text3,NoSecrets_Vagas,,,\");\n+\n+\t\tsuper.assertOutput(new Path(System.getProperty(\"user.dir\") + File.separator\n+\t\t\t\t+ \"src/test/resources/tweets.tar.gz\"), output);\n+\t}\n+\n+\t@Test\n+\tpublic void testMaxRecordLength() throws Exception {\n+\n+\t\t// variable-size-objects.json contains 3 json objects but only 2 of them fit in the 27 byte length limitation\n+\n+\t\textraParams.add(new Pair<String, String>(\"IDENTIFIER\", \"key666\"));\n+\t\textraParams.add(new Pair<String, String>(\"MAXLENGTH\", \"27\"));\n+\n+\t\tcolumnDefs.clear();\n+\t\tcolumnDefs.add(new Pair<String, DataType>(\"key666\", DataType.TEXT));\n+\n+\t\tList<String> output = new ArrayList<String>();\n+\n+\t\toutput.add(\"small object1\");\n+\t\t// skip the large object2 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n+\t\toutput.add(\"small object3\");\n+\n+\t\tsuper.assertOutput(new Path(System.getProperty(\"user.dir\") + File.separator\n+\t\t\t\t+ \"src/test/resources/variable-size-objects.json\"), output);\n+\t}\n+\n+\t@Test\n+\tpublic void testDataTypes() throws Exception {\n+\n+\t\t// TDOO: The BYTEA type is not tested!!! Current oneField.val = val.asText().getBytes(); convention is","path":"pxf/pxf-json/src/test/java/org/apache/hawq/pxf/plugins/json/JsonExtensionTest.java","position":102,"original_position":102,"commit_id":"e81234f3f151065244d8dc8543aa1b6bdbfbf189","original_commit_id":"e81234f3f151065244d8dc8543aa1b6bdbfbf189","user":{"login":"hornn","id":11283944,"avatar_url":"https://avatars.githubusercontent.com/u/11283944?v=3","gravatar_id":"","url":"https://api.github.com/users/hornn","html_url":"https://github.com/hornn","followers_url":"https://api.github.com/users/hornn/followers","following_url":"https://api.github.com/users/hornn/following{/other_user}","gists_url":"https://api.github.com/users/hornn/gists{/gist_id}","starred_url":"https://api.github.com/users/hornn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hornn/subscriptions","organizations_url":"https://api.github.com/users/hornn/orgs","repos_url":"https://api.github.com/users/hornn/repos","events_url":"https://api.github.com/users/hornn/events{/privacy}","received_events_url":"https://api.github.com/users/hornn/received_events","type":"User","site_admin":false},"body":"Let's open a sub-task for it, what do you think?","created_at":"2016-02-04T06:45:28Z","updated_at":"2016-02-04T06:45:28Z","html_url":"https://github.com/apache/incubator-hawq/pull/302#discussion_r51835264","pull_request_url":"https://api.github.com/repos/apache/incubator-hawq/pulls/302","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-hawq/pulls/comments/51835264"},"html":{"href":"https://github.com/apache/incubator-hawq/pull/302#discussion_r51835264"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-hawq/pulls/302"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-hawq/pulls/302","id":57582087,"html_url":"https://github.com/apache/incubator-hawq/pull/302","diff_url":"https://github.com/apache/incubator-hawq/pull/302.diff","patch_url":"https://github.com/apache/incubator-hawq/pull/302.patch","issue_url":"https://api.github.com/repos/apache/incubator-hawq/issues/302","number":302,"state":"open","locked":false,"title":"HAWQ-178: Add JSON plugin support in code base","user":{"login":"tzolov","id":1351573,"avatar_url":"https://avatars.githubusercontent.com/u/1351573?v=3","gravatar_id":"","url":"https://api.github.com/users/tzolov","html_url":"https://github.com/tzolov","followers_url":"https://api.github.com/users/tzolov/followers","following_url":"https://api.github.com/users/tzolov/following{/other_user}","gists_url":"https://api.github.com/users/tzolov/gists{/gist_id}","starred_url":"https://api.github.com/users/tzolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzolov/subscriptions","organizations_url":"https://api.github.com/users/tzolov/orgs","repos_url":"https://api.github.com/users/tzolov/repos","events_url":"https://api.github.com/users/tzolov/events{/privacy}","received_events_url":"https://api.github.com/users/tzolov/received_events","type":"User","site_admin":false},"body":"Add `pxf-json` and registers it along the pxf-hdfs, pxf-hive and pxf-hbase plugins.  \r\n\r\nNote: I've copied the PxfUnit so i can use the pxf-json unit testing. In log term the PxfUnit should be placed in a standalone project.\r\n\r\nPlugin has manually been tested against HAWQ-2.0.0-beta.","created_at":"2016-01-28T23:14:22Z","updated_at":"2016-02-04T06:45:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ba1a47646174ee635fbfbb28c73c42a9ed7e173","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-hawq/pulls/302/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-hawq/pulls/302/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-hawq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-hawq/issues/302/comments","statuses_url":"https://api.github.com/repos/apache/incubator-hawq/statuses/e81234f3f151065244d8dc8543aa1b6bdbfbf189","head":{"label":"tzolov:HAWQ-178","ref":"HAWQ-178","sha":"e81234f3f151065244d8dc8543aa1b6bdbfbf189","user":{"login":"tzolov","id":1351573,"avatar_url":"https://avatars.githubusercontent.com/u/1351573?v=3","gravatar_id":"","url":"https://api.github.com/users/tzolov","html_url":"https://github.com/tzolov","followers_url":"https://api.github.com/users/tzolov/followers","following_url":"https://api.github.com/users/tzolov/following{/other_user}","gists_url":"https://api.github.com/users/tzolov/gists{/gist_id}","starred_url":"https://api.github.com/users/tzolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzolov/subscriptions","organizations_url":"https://api.github.com/users/tzolov/orgs","repos_url":"https://api.github.com/users/tzolov/repos","events_url":"https://api.github.com/users/tzolov/events{/privacy}","received_events_url":"https://api.github.com/users/tzolov/received_events","type":"User","site_admin":false},"repo":{"id":48232699,"name":"incubator-hawq","full_name":"tzolov/incubator-hawq","owner":{"login":"tzolov","id":1351573,"avatar_url":"https://avatars.githubusercontent.com/u/1351573?v=3","gravatar_id":"","url":"https://api.github.com/users/tzolov","html_url":"https://github.com/tzolov","followers_url":"https://api.github.com/users/tzolov/followers","following_url":"https://api.github.com/users/tzolov/following{/other_user}","gists_url":"https://api.github.com/users/tzolov/gists{/gist_id}","starred_url":"https://api.github.com/users/tzolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzolov/subscriptions","organizations_url":"https://api.github.com/users/tzolov/orgs","repos_url":"https://api.github.com/users/tzolov/repos","events_url":"https://api.github.com/users/tzolov/events{/privacy}","received_events_url":"https://api.github.com/users/tzolov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tzolov/incubator-hawq","description":"Mirror of Apache HAWQ (Incubating)","fork":true,"url":"https://api.github.com/repos/tzolov/incubator-hawq","forks_url":"https://api.github.com/repos/tzolov/incubator-hawq/forks","keys_url":"https://api.github.com/repos/tzolov/incubator-hawq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tzolov/incubator-hawq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tzolov/incubator-hawq/teams","hooks_url":"https://api.github.com/repos/tzolov/incubator-hawq/hooks","issue_events_url":"https://api.github.com/repos/tzolov/incubator-hawq/issues/events{/number}","events_url":"https://api.github.com/repos/tzolov/incubator-hawq/events","assignees_url":"https://api.github.com/repos/tzolov/incubator-hawq/assignees{/user}","branches_url":"https://api.github.com/repos/tzolov/incubator-hawq/branches{/branch}","tags_url":"https://api.github.com/repos/tzolov/incubator-hawq/tags","blobs_url":"https://api.github.com/repos/tzolov/incubator-hawq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tzolov/incubator-hawq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tzolov/incubator-hawq/git/refs{/sha}","trees_url":"https://api.github.com/repos/tzolov/incubator-hawq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tzolov/incubator-hawq/statuses/{sha}","languages_url":"https://api.github.com/repos/tzolov/incubator-hawq/languages","stargazers_url":"https://api.github.com/repos/tzolov/incubator-hawq/stargazers","contributors_url":"https://api.github.com/repos/tzolov/incubator-hawq/contributors","subscribers_url":"https://api.github.com/repos/tzolov/incubator-hawq/subscribers","subscription_url":"https://api.github.com/repos/tzolov/incubator-hawq/subscription","commits_url":"https://api.github.com/repos/tzolov/incubator-hawq/commits{/sha}","git_commits_url":"https://api.github.com/repos/tzolov/incubator-hawq/git/commits{/sha}","comments_url":"https://api.github.com/repos/tzolov/incubator-hawq/comments{/number}","issue_comment_url":"https://api.github.com/repos/tzolov/incubator-hawq/issues/comments{/number}","contents_url":"https://api.github.com/repos/tzolov/incubator-hawq/contents/{+path}","compare_url":"https://api.github.com/repos/tzolov/incubator-hawq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tzolov/incubator-hawq/merges","archive_url":"https://api.github.com/repos/tzolov/incubator-hawq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tzolov/incubator-hawq/downloads","issues_url":"https://api.github.com/repos/tzolov/incubator-hawq/issues{/number}","pulls_url":"https://api.github.com/repos/tzolov/incubator-hawq/pulls{/number}","milestones_url":"https://api.github.com/repos/tzolov/incubator-hawq/milestones{/number}","notifications_url":"https://api.github.com/repos/tzolov/incubator-hawq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tzolov/incubator-hawq/labels{/name}","releases_url":"https://api.github.com/repos/tzolov/incubator-hawq/releases{/id}","deployments_url":"https://api.github.com/repos/tzolov/incubator-hawq/deployments","created_at":"2015-12-18T11:53:23Z","updated_at":"2015-12-18T11:53:50Z","pushed_at":"2016-02-03T16:36:18Z","git_url":"git://github.com/tzolov/incubator-hawq.git","ssh_url":"git@github.com:tzolov/incubator-hawq.git","clone_url":"https://github.com/tzolov/incubator-hawq.git","svn_url":"https://github.com/tzolov/incubator-hawq","homepage":null,"size":148216,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"682749953dd710f04fc49fb3b631673021648e3a","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":41952293,"name":"incubator-hawq","full_name":"apache/incubator-hawq","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-hawq","description":"Mirror of Apache HAWQ (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-hawq","forks_url":"https://api.github.com/repos/apache/incubator-hawq/forks","keys_url":"https://api.github.com/repos/apache/incubator-hawq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-hawq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-hawq/teams","hooks_url":"https://api.github.com/repos/apache/incubator-hawq/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-hawq/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-hawq/events","assignees_url":"https://api.github.com/repos/apache/incubator-hawq/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-hawq/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-hawq/tags","blobs_url":"https://api.github.com/repos/apache/incubator-hawq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-hawq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-hawq/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-hawq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-hawq/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-hawq/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-hawq/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-hawq/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-hawq/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-hawq/subscription","commits_url":"https://api.github.com/repos/apache/incubator-hawq/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-hawq/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-hawq/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-hawq/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-hawq/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-hawq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-hawq/merges","archive_url":"https://api.github.com/repos/apache/incubator-hawq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-hawq/downloads","issues_url":"https://api.github.com/repos/apache/incubator-hawq/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-hawq/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-hawq/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-hawq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-hawq/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-hawq/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-hawq/deployments","created_at":"2015-09-05T07:00:05Z","updated_at":"2016-02-01T06:48:13Z","pushed_at":"2016-02-04T04:02:43Z","git_url":"git://github.com/apache/incubator-hawq.git","ssh_url":"git@github.com:apache/incubator-hawq.git","clone_url":"https://github.com/apache/incubator-hawq.git","svn_url":"https://github.com/apache/incubator-hawq","homepage":null,"size":148739,"stargazers_count":103,"watchers_count":103,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":90,"mirror_url":"git://git.apache.org/incubator-hawq.git","open_issues_count":16,"forks":90,"open_issues":16,"watchers":103,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-hawq/pulls/302"},"html":{"href":"https://github.com/apache/incubator-hawq/pull/302"},"issue":{"href":"https://api.github.com/repos/apache/incubator-hawq/issues/302"},"comments":{"href":"https://api.github.com/repos/apache/incubator-hawq/issues/302/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-hawq/pulls/302/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-hawq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-hawq/pulls/302/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-hawq/statuses/e81234f3f151065244d8dc8543aa1b6bdbfbf189"}}}}