{"action":"created","comment":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/83735674","pull_request_review_id":4558640,"id":83735674,"diff_hunk":"@@ -0,0 +1,229 @@\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+package org.apache.apex.malhar.sql.schema;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.sql.Time;\n+import java.util.ArrayList;\n+import java.util.Date;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.jar.JarOutputStream;\n+import java.util.zip.ZipEntry;\n+\n+import org.codehaus.jettison.json.JSONException;\n+\n+import org.apache.apex.malhar.sql.codegen.BeanClassGenerator;\n+import org.apache.apex.malhar.sql.operators.OperatorUtils;\n+import org.apache.calcite.rel.type.RelDataType;\n+import org.apache.calcite.rel.type.RelDataTypeField;\n+\n+import org.apache.commons.lang.ClassUtils;\n+import org.apache.hadoop.classification.InterfaceStability;\n+import org.apache.hadoop.conf.Configuration;\n+import org.apache.hadoop.fs.FSDataOutputStream;\n+import org.apache.hadoop.fs.FileSystem;\n+import org.apache.hadoop.fs.Path;\n+\n+@InterfaceStability.Evolving\n+public class TupleSchemaRegistry\n+{\n+  public static final String FQCN_PACKAGE = \"org.apache.apex.generated.schema.\";\n+  private Map<String, Schema> schemas = new HashMap<>();\n+\n+  public Schema createNewSchema(String name)\n+  {\n+    if (schemas.containsKey(name)) {\n+      return schemas.get(name);\n+    }\n+\n+    Schema schema = new Schema();\n+    schema.name = name;\n+    schemas.put(name, schema);\n+\n+    return schema;\n+  }\n+\n+  public Schema getSchemaDefinition(String name)\n+  {\n+    return schemas.get(name);\n+  }\n+\n+  public String generateCommonJar() throws IOException\n+  {\n+    File file = new File(\"/tmp/schemaSQL.jar\");\n+    if (file.exists()) {\n+      file.delete();\n+    }\n+\n+    FileSystem fs = FileSystem.newInstance(file.toURI(), new Configuration());\n+    FSDataOutputStream out = fs.create(new Path(file.getAbsolutePath()));\n+    JarOutputStream jout = new JarOutputStream(out);\n+\n+    for (Schema schema : schemas.values()) {\n+      jout.putNextEntry(new ZipEntry(schema.fqcn.replace(\".\", \"/\") + \".class\"));\n+      jout.write(schema.beanClassBytes);\n+      jout.closeEntry();\n+    }\n+\n+    jout.close();\n+    out.close();\n+\n+    return file.getAbsolutePath();\n+  }\n+\n+  public static Class getSchemaForRelDataType(TupleSchemaRegistry registry, String schemaName, RelDataType rowType)\n+  {\n+    if (rowType.isStruct()) {\n+      TupleSchemaRegistry.Schema newSchema = registry.createNewSchema(schemaName);\n+      for (RelDataTypeField field : rowType.getFieldList()) {\n+        RelDataType type = field.getType();\n+        newSchema.addField(OperatorUtils.getValidFieldName(field), convertPrimitiveToSqlType(type));\n+      }\n+      try {\n+        newSchema.generateBean();\n+      } catch (IOException | JSONException e) {\n+        throw new RuntimeException(\"Failed t generate schema\", e);","path":"sql/src/main/java/org/apache/apex/malhar/sql/schema/TupleSchemaRegistry.java","position":104,"original_position":104,"commit_id":"6e82fbd6ee2b15baa53fdc8a8af338326a322f62","original_commit_id":"6e82fbd6ee2b15baa53fdc8a8af338326a322f62","user":{"login":"tweise","id":263695,"avatar_url":"https://avatars.githubusercontent.com/u/263695?v=3","gravatar_id":"","url":"https://api.github.com/users/tweise","html_url":"https://github.com/tweise","followers_url":"https://api.github.com/users/tweise/followers","following_url":"https://api.github.com/users/tweise/following{/other_user}","gists_url":"https://api.github.com/users/tweise/gists{/gist_id}","starred_url":"https://api.github.com/users/tweise/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tweise/subscriptions","organizations_url":"https://api.github.com/users/tweise/orgs","repos_url":"https://api.github.com/users/tweise/repos","events_url":"https://api.github.com/users/tweise/events{/privacy}","received_events_url":"https://api.github.com/users/tweise/received_events","type":"User","site_admin":false},"body":"typo","created_at":"2016-10-17T21:15:23Z","updated_at":"2016-10-17T21:15:23Z","html_url":"https://github.com/apache/apex-malhar/pull/432#discussion_r83735674","pull_request_url":"https://api.github.com/repos/apache/apex-malhar/pulls/432","_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/83735674"},"html":{"href":"https://github.com/apache/apex-malhar/pull/432#discussion_r83735674"},"pull_request":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/432"}}},"pull_request":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/432","id":87142387,"html_url":"https://github.com/apache/apex-malhar/pull/432","diff_url":"https://github.com/apache/apex-malhar/pull/432.diff","patch_url":"https://github.com/apache/apex-malhar/pull/432.patch","issue_url":"https://api.github.com/repos/apache/apex-malhar/issues/432","number":432,"state":"open","locked":false,"title":"[Review Only] APEXMALHAR-1818 SQL Support for converting given SQL statement to APEX DAG","user":{"login":"chinmaykolhatkar","id":12393897,"avatar_url":"https://avatars.githubusercontent.com/u/12393897?v=3","gravatar_id":"","url":"https://api.github.com/users/chinmaykolhatkar","html_url":"https://github.com/chinmaykolhatkar","followers_url":"https://api.github.com/users/chinmaykolhatkar/followers","following_url":"https://api.github.com/users/chinmaykolhatkar/following{/other_user}","gists_url":"https://api.github.com/users/chinmaykolhatkar/gists{/gist_id}","starred_url":"https://api.github.com/users/chinmaykolhatkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinmaykolhatkar/subscriptions","organizations_url":"https://api.github.com/users/chinmaykolhatkar/orgs","repos_url":"https://api.github.com/users/chinmaykolhatkar/repos","events_url":"https://api.github.com/users/chinmaykolhatkar/events{/privacy}","received_events_url":"https://api.github.com/users/chinmaykolhatkar/received_events","type":"User","site_admin":false},"body":"Features implemented are:\r\n1. SELECT STATEMENT\r\n2. INSERT STATEMENT\r\n3. INNER JOIN with non-empty equi join condition\r\n4. WHERE clause\r\n5. SCALAR functions implemented in calcite are ready to use\r\n6. Custom scalar functions can be registered.\r\n7. Endpoint can be File OR Kafka OR Streaming Port for both input and output\r\n8. CSV Data Format implemented for both input and output side.\r\n9. Static loading of calcite JDBC driver.\r\n10. Testing on local as well as cluster mode.","created_at":"2016-09-28T15:22:49Z","updated_at":"2016-10-17T21:30:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6327d55fe5806488ef1d5f43f5c9d6cfad01fc2f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/apex-malhar/pulls/432/commits","review_comments_url":"https://api.github.com/repos/apache/apex-malhar/pulls/432/comments","review_comment_url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/apex-malhar/issues/432/comments","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/6e82fbd6ee2b15baa53fdc8a8af338326a322f62","head":{"label":"chinmaykolhatkar:calcite","ref":"calcite","sha":"6e82fbd6ee2b15baa53fdc8a8af338326a322f62","user":{"login":"chinmaykolhatkar","id":12393897,"avatar_url":"https://avatars.githubusercontent.com/u/12393897?v=3","gravatar_id":"","url":"https://api.github.com/users/chinmaykolhatkar","html_url":"https://github.com/chinmaykolhatkar","followers_url":"https://api.github.com/users/chinmaykolhatkar/followers","following_url":"https://api.github.com/users/chinmaykolhatkar/following{/other_user}","gists_url":"https://api.github.com/users/chinmaykolhatkar/gists{/gist_id}","starred_url":"https://api.github.com/users/chinmaykolhatkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinmaykolhatkar/subscriptions","organizations_url":"https://api.github.com/users/chinmaykolhatkar/orgs","repos_url":"https://api.github.com/users/chinmaykolhatkar/repos","events_url":"https://api.github.com/users/chinmaykolhatkar/events{/privacy}","received_events_url":"https://api.github.com/users/chinmaykolhatkar/received_events","type":"User","site_admin":false},"repo":{"id":43486479,"name":"apex-malhar","full_name":"chinmaykolhatkar/apex-malhar","owner":{"login":"chinmaykolhatkar","id":12393897,"avatar_url":"https://avatars.githubusercontent.com/u/12393897?v=3","gravatar_id":"","url":"https://api.github.com/users/chinmaykolhatkar","html_url":"https://github.com/chinmaykolhatkar","followers_url":"https://api.github.com/users/chinmaykolhatkar/followers","following_url":"https://api.github.com/users/chinmaykolhatkar/following{/other_user}","gists_url":"https://api.github.com/users/chinmaykolhatkar/gists{/gist_id}","starred_url":"https://api.github.com/users/chinmaykolhatkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinmaykolhatkar/subscriptions","organizations_url":"https://api.github.com/users/chinmaykolhatkar/orgs","repos_url":"https://api.github.com/users/chinmaykolhatkar/repos","events_url":"https://api.github.com/users/chinmaykolhatkar/events{/privacy}","received_events_url":"https://api.github.com/users/chinmaykolhatkar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chinmaykolhatkar/apex-malhar","description":"Mirror of Apache Apex malhar (Incubating)","fork":true,"url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar","forks_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/forks","keys_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/teams","hooks_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/events","assignees_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/tags","blobs_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/subscription","commits_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/merges","archive_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/downloads","issues_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/chinmaykolhatkar/apex-malhar/deployments","created_at":"2015-10-01T08:43:18Z","updated_at":"2016-06-07T18:33:11Z","pushed_at":"2016-10-17T14:16:56Z","git_url":"git://github.com/chinmaykolhatkar/apex-malhar.git","ssh_url":"git@github.com:chinmaykolhatkar/apex-malhar.git","clone_url":"https://github.com/chinmaykolhatkar/apex-malhar.git","svn_url":"https://github.com/chinmaykolhatkar/apex-malhar","homepage":null,"size":87510,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"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":"2153cd6babadf11e7be63a137daa7dd2c3ef7230","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":41348334,"name":"apex-malhar","full_name":"apache/apex-malhar","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/apex-malhar","description":"Mirror of Apache Apex malhar","fork":false,"url":"https://api.github.com/repos/apache/apex-malhar","forks_url":"https://api.github.com/repos/apache/apex-malhar/forks","keys_url":"https://api.github.com/repos/apache/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/apex-malhar/teams","hooks_url":"https://api.github.com/repos/apache/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/apache/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/apache/apex-malhar/events","assignees_url":"https://api.github.com/repos/apache/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/apache/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/apache/apex-malhar/tags","blobs_url":"https://api.github.com/repos/apache/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/apache/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/apache/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/apache/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/apache/apex-malhar/subscription","commits_url":"https://api.github.com/repos/apache/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/apache/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/apex-malhar/merges","archive_url":"https://api.github.com/repos/apache/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/apex-malhar/downloads","issues_url":"https://api.github.com/repos/apache/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/apache/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/apache/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/apache/apex-malhar/deployments","created_at":"2015-08-25T07:00:05Z","updated_at":"2016-10-12T15:30:37Z","pushed_at":"2016-10-17T18:06:00Z","git_url":"git://github.com/apache/apex-malhar.git","ssh_url":"git@github.com:apache/apex-malhar.git","clone_url":"https://github.com/apache/apex-malhar.git","svn_url":"https://github.com/apache/apex-malhar","homepage":"","size":98745,"stargazers_count":60,"watchers_count":60,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":101,"mirror_url":"git://git.apache.org/incubator-apex-malhar.git","open_issues_count":33,"forks":101,"open_issues":33,"watchers":60,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/432"},"html":{"href":"https://github.com/apache/apex-malhar/pull/432"},"issue":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/432"},"comments":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/432/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/432/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/432/commits"},"statuses":{"href":"https://api.github.com/repos/apache/apex-malhar/statuses/6e82fbd6ee2b15baa53fdc8a8af338326a322f62"}}}}
{"actor":{"display_login":"tweise"}}