{"action":"created","comment":{"url":"https://api.github.com/repos/apache/flink/pulls/comments/38078475","id":38078475,"diff_hunk":"@@ -0,0 +1,215 @@\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, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.apache.flink.hcatalog.scala.test\n+\n+\n+import java.io.{FileWriter, FileReader, BufferedReader, IOException, File}\n+\n+import org.apache.commons.io.FileUtils\n+import org.apache.flink.api.scala.{DataSet, ExecutionEnvironment, _}\n+import org.apache.flink.hcatalog.scala.{HCatInputFormat, HCatOutputFormat}\n+import org.apache.hadoop.hive.cli.CliSessionState\n+import org.apache.hadoop.hive.conf.HiveConf\n+import org.apache.hadoop.hive.ql.Driver\n+import org.apache.hadoop.hive.ql.session.SessionState\n+import org.junit.Assert._\n+import org.junit.{After, Before, Test}\n+\n+class HCatInputOutputFormatITest {\n+  private var dataDir: File = null\n+  private var warehouseDir: String = null\n+  private var inputFileName: String = null\n+  private var driver: Driver = null\n+  private var input: Array[String] = null\n+  private var hiveConf: HiveConf = null\n+\n+  @Before\n+  @throws(classOf[Exception])\n+  def setup {\n+    dataDir = new File(System.getProperty(\"java.io.tmpdir\") + File.separator +\n+      this.getClass.getCanonicalName + \"-\" + System.currentTimeMillis)\n+    hiveConf = new HiveConf\n+    warehouseDir = makePathASafeFileName(dataDir + File.separator + \"warehouse\")\n+    hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, \"\")\n+    hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, \"\")\n+    hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, \"false\")\n+    hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, warehouseDir)\n+    driver = new Driver(hiveConf)\n+    SessionState.start(new CliSessionState(hiveConf))\n+    if (!(new File(warehouseDir).mkdirs)) {\n+      throw new RuntimeException(\"Could not create \" + warehouseDir)\n+    }\n+  }\n+\n+  @After\n+  @throws(classOf[IOException])\n+  def teardown {\n+    if (dataDir != null) {\n+      FileUtils.deleteDirectory(dataDir)\n+    }\n+  }\n+\n+  @Test\n+  @throws(classOf[Exception])\n+  def testReadTextFile {\n+    inputFileName = makePathASafeFileName(dataDir + File.separator + \"input1.data\")\n+\n+    input = Array[String](\"a1/b1/c1\\t1:v11/2:v12\\td/1\\te1\\t0.1\",\n+      \"a2/b2/c2\\t1:v21/2:v22\\td/2\\te2\\t0.2\")\n+\n+    createTestDataFile(inputFileName, input)\n+\n+    val createTable: String = \"CREATE TABLE test_table(\" +\n+      \"c1 array<string>,\\n\" +\n+      \"c2 map<int,string>,\\n\" +\n+      \"c3 struct<name:string,score:int>,\\n\" +\n+      \"c4 string,\\n\" +\n+      \"c5 float)\\n\" +\n+      \"row format delimited \" +\n+      \"fields terminated by '\\t' \" +\n+      \"COLLECTION ITEMS TERMINATED BY '/' \" +\n+      \"MAP KEYS TERMINATED BY ':' \" +\n+      \"STORED AS TEXTFILE\"\n+    driver.run(\"drop table test_table\")\n+    val retCode1: Int = driver.run(createTable).getResponseCode\n+    assertTrue(retCode1 == 0)\n+    val loadTable: String = \"load data inpath '\" + inputFileName + \"' into table test_table\"\n+    val retCode2: Int = driver.run(loadTable).getResponseCode\n+    assertTrue(retCode2 == 0)","path":"flink-staging/flink-hcatalog/src/test/scala/org/apache/flink/hcatalog/scala/test/HCatInputOutputFormatITest.scala","position":93,"original_position":93,"commit_id":"aa149f4d2c74db9c7c1d8f82dbe923e3930713b1","original_commit_id":"aa149f4d2c74db9c7c1d8f82dbe923e3930713b1","user":{"login":"chiwanpark","id":1941681,"avatar_url":"https://avatars.githubusercontent.com/u/1941681?v=3","gravatar_id":"","url":"https://api.github.com/users/chiwanpark","html_url":"https://github.com/chiwanpark","followers_url":"https://api.github.com/users/chiwanpark/followers","following_url":"https://api.github.com/users/chiwanpark/following{/other_user}","gists_url":"https://api.github.com/users/chiwanpark/gists{/gist_id}","starred_url":"https://api.github.com/users/chiwanpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chiwanpark/subscriptions","organizations_url":"https://api.github.com/users/chiwanpark/orgs","repos_url":"https://api.github.com/users/chiwanpark/repos","events_url":"https://api.github.com/users/chiwanpark/events{/privacy}","received_events_url":"https://api.github.com/users/chiwanpark/received_events","type":"User","site_admin":false},"body":"More detail message","created_at":"2015-08-27T09:41:26Z","updated_at":"2015-08-27T09:41:26Z","html_url":"https://github.com/apache/flink/pull/1064#discussion_r38078475","pull_request_url":"https://api.github.com/repos/apache/flink/pulls/1064","_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/38078475"},"html":{"href":"https://github.com/apache/flink/pull/1064#discussion_r38078475"},"pull_request":{"href":"https://api.github.com/repos/apache/flink/pulls/1064"}}},"pull_request":{"url":"https://api.github.com/repos/apache/flink/pulls/1064","id":43476811,"html_url":"https://github.com/apache/flink/pull/1064","diff_url":"https://github.com/apache/flink/pull/1064.diff","patch_url":"https://github.com/apache/flink/pull/1064.patch","issue_url":"https://api.github.com/repos/apache/flink/issues/1064","number":1064,"state":"open","locked":false,"title":"[FLINK1919] add HCatOutputFormat","user":{"login":"jamescao","id":11864950,"avatar_url":"https://avatars.githubusercontent.com/u/11864950?v=3","gravatar_id":"","url":"https://api.github.com/users/jamescao","html_url":"https://github.com/jamescao","followers_url":"https://api.github.com/users/jamescao/followers","following_url":"https://api.github.com/users/jamescao/following{/other_user}","gists_url":"https://api.github.com/users/jamescao/gists{/gist_id}","starred_url":"https://api.github.com/users/jamescao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamescao/subscriptions","organizations_url":"https://api.github.com/users/jamescao/orgs","repos_url":"https://api.github.com/users/jamescao/repos","events_url":"https://api.github.com/users/jamescao/events{/privacy}","received_events_url":"https://api.github.com/users/jamescao/received_events","type":"User","site_admin":false},"body":"[FLINK1919]\r\nAdd `HCatOutputFormat` for Tuple data types for java and scala api also fix a bug for the scala api's `HCatInputFormat` for hive complex types.\r\nJava api includes check if the schema of the HCatalog table and the Flink tuples match if the user provides a `TypeInformation` in the constructor. For data types other than tuples, the OutputFormat requires a preceding Map function that converts to `HCatRecords` \r\nscala api includes check if the schema of the HCatalog table and the Scala tuples match. For data types other than scala `Tuple`, the OutputFormat requires a preceding Map function that converts to `HCatRecords`  scala api require suser to import `org.apache.flink.api.scala._` to allow the type be captured by the scala macro.\r\nThe Hcatalog jar in maven central is compiled using hadoop1, which is not compatible with hive jars for testing, so a cloudera hcatalog jar is pulled into the pom for testing purpose. It can be removed if not required.\r\njava `List` and `Map` can not be cast to scala `List` and `Map`,` JavaConverters` is used to fix a bug in HcatInputFormat scala api","created_at":"2015-08-27T03:46:04Z","updated_at":"2015-08-27T09:41:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea83084514f50dad3a7bd0e80f6ea3a237f0c910","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/flink/pulls/1064/commits","review_comments_url":"https://api.github.com/repos/apache/flink/pulls/1064/comments","review_comment_url":"https://api.github.com/repos/apache/flink/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/flink/issues/1064/comments","statuses_url":"https://api.github.com/repos/apache/flink/statuses/aa149f4d2c74db9c7c1d8f82dbe923e3930713b1","head":{"label":"jamescao:hcatbranch","ref":"hcatbranch","sha":"aa149f4d2c74db9c7c1d8f82dbe923e3930713b1","user":{"login":"jamescao","id":11864950,"avatar_url":"https://avatars.githubusercontent.com/u/11864950?v=3","gravatar_id":"","url":"https://api.github.com/users/jamescao","html_url":"https://github.com/jamescao","followers_url":"https://api.github.com/users/jamescao/followers","following_url":"https://api.github.com/users/jamescao/following{/other_user}","gists_url":"https://api.github.com/users/jamescao/gists{/gist_id}","starred_url":"https://api.github.com/users/jamescao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamescao/subscriptions","organizations_url":"https://api.github.com/users/jamescao/orgs","repos_url":"https://api.github.com/users/jamescao/repos","events_url":"https://api.github.com/users/jamescao/events{/privacy}","received_events_url":"https://api.github.com/users/jamescao/received_events","type":"User","site_admin":false},"repo":{"id":39397084,"name":"flink","full_name":"jamescao/flink","owner":{"login":"jamescao","id":11864950,"avatar_url":"https://avatars.githubusercontent.com/u/11864950?v=3","gravatar_id":"","url":"https://api.github.com/users/jamescao","html_url":"https://github.com/jamescao","followers_url":"https://api.github.com/users/jamescao/followers","following_url":"https://api.github.com/users/jamescao/following{/other_user}","gists_url":"https://api.github.com/users/jamescao/gists{/gist_id}","starred_url":"https://api.github.com/users/jamescao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamescao/subscriptions","organizations_url":"https://api.github.com/users/jamescao/orgs","repos_url":"https://api.github.com/users/jamescao/repos","events_url":"https://api.github.com/users/jamescao/events{/privacy}","received_events_url":"https://api.github.com/users/jamescao/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jamescao/flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/jamescao/flink","forks_url":"https://api.github.com/repos/jamescao/flink/forks","keys_url":"https://api.github.com/repos/jamescao/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jamescao/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jamescao/flink/teams","hooks_url":"https://api.github.com/repos/jamescao/flink/hooks","issue_events_url":"https://api.github.com/repos/jamescao/flink/issues/events{/number}","events_url":"https://api.github.com/repos/jamescao/flink/events","assignees_url":"https://api.github.com/repos/jamescao/flink/assignees{/user}","branches_url":"https://api.github.com/repos/jamescao/flink/branches{/branch}","tags_url":"https://api.github.com/repos/jamescao/flink/tags","blobs_url":"https://api.github.com/repos/jamescao/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jamescao/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jamescao/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/jamescao/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jamescao/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/jamescao/flink/languages","stargazers_url":"https://api.github.com/repos/jamescao/flink/stargazers","contributors_url":"https://api.github.com/repos/jamescao/flink/contributors","subscribers_url":"https://api.github.com/repos/jamescao/flink/subscribers","subscription_url":"https://api.github.com/repos/jamescao/flink/subscription","commits_url":"https://api.github.com/repos/jamescao/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/jamescao/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/jamescao/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/jamescao/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/jamescao/flink/contents/{+path}","compare_url":"https://api.github.com/repos/jamescao/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jamescao/flink/merges","archive_url":"https://api.github.com/repos/jamescao/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jamescao/flink/downloads","issues_url":"https://api.github.com/repos/jamescao/flink/issues{/number}","pulls_url":"https://api.github.com/repos/jamescao/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/jamescao/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/jamescao/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jamescao/flink/labels{/name}","releases_url":"https://api.github.com/repos/jamescao/flink/releases{/id}","created_at":"2015-07-20T17:06:50Z","updated_at":"2015-07-20T17:07:01Z","pushed_at":"2015-08-27T02:09:43Z","git_url":"git://github.com/jamescao/flink.git","ssh_url":"git@github.com:jamescao/flink.git","clone_url":"https://github.com/jamescao/flink.git","svn_url":"https://github.com/jamescao/flink","homepage":null,"size":56650,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"366d937a4599e5546052c74c595cad417ae69588","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":20587599,"name":"flink","full_name":"apache/flink","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/flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/flink","forks_url":"https://api.github.com/repos/apache/flink/forks","keys_url":"https://api.github.com/repos/apache/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/flink/teams","hooks_url":"https://api.github.com/repos/apache/flink/hooks","issue_events_url":"https://api.github.com/repos/apache/flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/flink/events","assignees_url":"https://api.github.com/repos/apache/flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/flink/tags","blobs_url":"https://api.github.com/repos/apache/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/flink/languages","stargazers_url":"https://api.github.com/repos/apache/flink/stargazers","contributors_url":"https://api.github.com/repos/apache/flink/contributors","subscribers_url":"https://api.github.com/repos/apache/flink/subscribers","subscription_url":"https://api.github.com/repos/apache/flink/subscription","commits_url":"https://api.github.com/repos/apache/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/flink/merges","archive_url":"https://api.github.com/repos/apache/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/flink/downloads","issues_url":"https://api.github.com/repos/apache/flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/flink/releases{/id}","created_at":"2014-06-07T07:00:10Z","updated_at":"2015-08-27T06:53:56Z","pushed_at":"2015-08-27T09:21:54Z","git_url":"git://github.com/apache/flink.git","ssh_url":"git@github.com:apache/flink.git","clone_url":"https://github.com/apache/flink.git","svn_url":"https://github.com/apache/flink","homepage":null,"size":2543641,"stargazers_count":580,"watchers_count":580,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":387,"mirror_url":"git://git.apache.org/incubator-flink.git","open_issues_count":83,"forks":387,"open_issues":83,"watchers":580,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/1064"},"html":{"href":"https://github.com/apache/flink/pull/1064"},"issue":{"href":"https://api.github.com/repos/apache/flink/issues/1064"},"comments":{"href":"https://api.github.com/repos/apache/flink/issues/1064/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/flink/pulls/1064/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/flink/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/flink/pulls/1064/commits"},"statuses":{"href":"https://api.github.com/repos/apache/flink/statuses/aa149f4d2c74db9c7c1d8f82dbe923e3930713b1"}}}}