{"action":"created","comment":{"url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments/60180168","id":60180168,"diff_hunk":"@@ -0,0 +1,350 @@\n+package org.apache.spark.sql.store\n+\n+import java.math.{BigInteger, BigDecimal}\n+import java.sql.DriverManager\n+import java.util.Date\n+\n+import com.gemstone.gemfire.cache.{PartitionResolver, RegionAttributes, Region, CacheFactory, Cache}\n+import com.pivotal.gemfirexd.TestUtil\n+import com.pivotal.gemfirexd.internal.engine.Misc\n+import com.pivotal.gemfirexd.internal.engine.ddl.resolver.GfxdPartitionByExpressionResolver\n+import com.pivotal.gemfirexd.internal.iapi.types._\n+import io.snappydata.SnappyFunSuite\n+import io.snappydata.core.{Data1, TestData2}\n+import org.scalatest.{BeforeAndAfterAll, BeforeAndAfter}\n+\n+import org.apache.spark.Logging\n+import org.apache.spark.sql.ColumnName\n+import org.apache.spark.sql.catalyst.expressions.GenericMutableRow\n+import org.apache.spark.sql.execution.QueryExecution\n+import org.apache.spark.unsafe.types.UTF8String\n+\n+/**\n+ * This test checks the validity of various functionality when we use Spark's partitioner logic for underlying\n+ * GemXD storage.\n+ */\n+class UnifiedPartitionerTest extends SnappyFunSuite\n+with Logging\n+with BeforeAndAfter\n+with BeforeAndAfterAll {\n+\n+  after {\n+    snc.dropTable(RowTableName2, ifExists = true)\n+    snc.dropTable(RowTableName1, ifExists = true)\n+    snc.dropTable(ColumnTableName2, ifExists = true)\n+    snc.dropTable(ColumnTableName1, ifExists = true)\n+\n+\n+  }\n+\n+  val ColumnTableName1: String = \"ColumnTable1\"\n+  val ColumnTableName2: String = \"ColumnTable2\"\n+  val RowTableName1: String = \"RowTable1\"\n+  val RowTableName2: String = \"RowTable2\"\n+\n+  val props = Map.empty[String, String]\n+\n+\n+  val options = \"OPTIONS (PARTITION_BY 'col1')\"\n+\n+  val optionsWithURL = \"OPTIONS (PARTITION_BY 'Col1', URL 'jdbc:snappydata:;')\"\n+\n+\n+  test(\" Test hash codes for all Sql types \") {\n+    snc.sql(s\"CREATE TABLE $ColumnTableName1(OrderId INT ,ItemId INT, ItemRef INT) \" +\n+        \"USING column \" +\n+        \"options \" +\n+        \"(\" +\n+        \"PARTITION_BY 'OrderId',\" +\n+        \"PERSISTENT 'ASYNCHRONOUS')\")\n+\n+    val regtwo: Region[_, _] = Misc.getRegion(\"/APP/COLUMNTABLE1\", true, true)\n+    val rattr: RegionAttributes[_, _] = regtwo.getAttributes\n+    val pr: PartitionResolver[_, _] = rattr.getPartitionAttributes.getPartitionResolver\n+    val rpr: GfxdPartitionByExpressionResolver = pr.asInstanceOf[GfxdPartitionByExpressionResolver]\n+    assert(rpr != null)\n+\n+    // Check All Datatypes\n+    val row = new GenericMutableRow(1)\n+    var dvd: DataValueDescriptor = new SQLInteger(200)\n+    row.update(0, 200)\n+\n+\n+    assert(rpr.getRoutingKeyForColumn(dvd) == row.hashCode)\n+\n+    row.update(0, new BigInteger(\"200000\"))\n+    dvd = new SQLInteger(200000)\n+    assert(rpr.getRoutingKeyForColumn(dvd) == row.hashCode)\n+\n+    row.update(0, true)\n+    dvd = new SQLBoolean(true)\n+    assert(rpr.getRoutingKeyForColumn(dvd) == row.hashCode)\n+\n+    row.update(0, new java.sql.Date(1, 1, 2011))\n+    dvd = new SQLDate(new java.sql.Date(1, 1, 2011))\n+    assert(rpr.getRoutingKeyForColumn(dvd) == row.hashCode)\n+\n+\n+    val ipaddr: Array[Byte] = Array(192.toByte, 168.toByte, 1.toByte, 9.toByte)\n+    row.update(0, ipaddr)\n+    dvd = new SQLBit(ipaddr)\n+    assert(rpr.getRoutingKeyForColumn(dvd) == row.hashCode)\n+\n+    dvd = new SQLReal(10.5F)\n+    row.update(0, 10.5F)\n+    assert(rpr.getRoutingKeyForColumn(dvd) == row.hashCode)\n+\n+    dvd = new SQLLongint(479L)\n+    row.update(0, 479L)\n+    assert(rpr.getRoutingKeyForColumn(dvd) == row.hashCode)\n+\n+    dvd = new SQLVarchar(\"xxxx\");\n+    row.update(0, UTF8String.fromString(\"xxxx\")) // As catalyst converts String to UtfString","path":"core/src/test/scala/org/apache/spark/sql/store/UnifiedPartitionerTest.scala","position":102,"original_position":102,"commit_id":"3c1023313bf67e5397d17e52b9ba7f2d84c28521","original_commit_id":"3c1023313bf67e5397d17e52b9ba7f2d84c28521","user":{"login":"sumwale","id":11540628,"avatar_url":"https://avatars.githubusercontent.com/u/11540628?v=3","gravatar_id":"","url":"https://api.github.com/users/sumwale","html_url":"https://github.com/sumwale","followers_url":"https://api.github.com/users/sumwale/followers","following_url":"https://api.github.com/users/sumwale/following{/other_user}","gists_url":"https://api.github.com/users/sumwale/gists{/gist_id}","starred_url":"https://api.github.com/users/sumwale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumwale/subscriptions","organizations_url":"https://api.github.com/users/sumwale/orgs","repos_url":"https://api.github.com/users/sumwale/repos","events_url":"https://api.github.com/users/sumwale/events{/privacy}","received_events_url":"https://api.github.com/users/sumwale/received_events","type":"User","site_admin":false},"body":"Let's just use mutable internalrow throughout this test. Then you would have discovered issues with date, timestamp and possibly others I may have missed.","created_at":"2016-04-19T06:48:06Z","updated_at":"2016-04-19T06:48:06Z","html_url":"https://github.com/SnappyDataInc/snappydata/pull/210#discussion_r60180168","pull_request_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210","_links":{"self":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments/60180168"},"html":{"href":"https://github.com/SnappyDataInc/snappydata/pull/210#discussion_r60180168"},"pull_request":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210"}}},"pull_request":{"url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210","id":65282434,"html_url":"https://github.com/SnappyDataInc/snappydata/pull/210","diff_url":"https://github.com/SnappyDataInc/snappydata/pull/210.diff","patch_url":"https://github.com/SnappyDataInc/snappydata/pull/210.patch","issue_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/210","number":210,"state":"open","locked":false,"title":"Snap 646: Unified Partitioner For Spark & Snappy Store","user":{"login":"rishitesh","id":793775,"avatar_url":"https://avatars.githubusercontent.com/u/793775?v=3","gravatar_id":"","url":"https://api.github.com/users/rishitesh","html_url":"https://github.com/rishitesh","followers_url":"https://api.github.com/users/rishitesh/followers","following_url":"https://api.github.com/users/rishitesh/following{/other_user}","gists_url":"https://api.github.com/users/rishitesh/gists{/gist_id}","starred_url":"https://api.github.com/users/rishitesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rishitesh/subscriptions","organizations_url":"https://api.github.com/users/rishitesh/orgs","repos_url":"https://api.github.com/users/rishitesh/repos","events_url":"https://api.github.com/users/rishitesh/events{/privacy}","received_events_url":"https://api.github.com/users/rishitesh/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-05T10:34:46Z","updated_at":"2016-04-19T06:48:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac0445f2aec7f0aa49f788256627ef1e13091bd1","assignee":{"login":"sumwale","id":11540628,"avatar_url":"https://avatars.githubusercontent.com/u/11540628?v=3","gravatar_id":"","url":"https://api.github.com/users/sumwale","html_url":"https://github.com/sumwale","followers_url":"https://api.github.com/users/sumwale/followers","following_url":"https://api.github.com/users/sumwale/following{/other_user}","gists_url":"https://api.github.com/users/sumwale/gists{/gist_id}","starred_url":"https://api.github.com/users/sumwale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumwale/subscriptions","organizations_url":"https://api.github.com/users/sumwale/orgs","repos_url":"https://api.github.com/users/sumwale/repos","events_url":"https://api.github.com/users/sumwale/events{/privacy}","received_events_url":"https://api.github.com/users/sumwale/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210/commits","review_comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210/comments","review_comment_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/210/comments","statuses_url":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/3c1023313bf67e5397d17e52b9ba7f2d84c28521","head":{"label":"SnappyDataInc:SNAP-646","ref":"SNAP-646","sha":"3c1023313bf67e5397d17e52b9ba7f2d84c28521","user":{"login":"SnappyDataInc","id":11342682,"avatar_url":"https://avatars.githubusercontent.com/u/11342682?v=3","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"repo":{"id":42580991,"name":"snappydata","full_name":"SnappyDataInc/snappydata","owner":{"login":"SnappyDataInc","id":11342682,"avatar_url":"https://avatars.githubusercontent.com/u/11342682?v=3","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SnappyDataInc/snappydata","description":"SnappyData: OLTP + OLAP Database built on Apache Spark","fork":false,"url":"https://api.github.com/repos/SnappyDataInc/snappydata","forks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/forks","keys_url":"https://api.github.com/repos/SnappyDataInc/snappydata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SnappyDataInc/snappydata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SnappyDataInc/snappydata/teams","hooks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/hooks","issue_events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/events{/number}","events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/events","assignees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/assignees{/user}","branches_url":"https://api.github.com/repos/SnappyDataInc/snappydata/branches{/branch}","tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/tags","blobs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/refs{/sha}","trees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/{sha}","languages_url":"https://api.github.com/repos/SnappyDataInc/snappydata/languages","stargazers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/stargazers","contributors_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contributors","subscribers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscribers","subscription_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscription","commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/commits{/sha}","git_commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/commits{/sha}","comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/comments{/number}","issue_comment_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/comments{/number}","contents_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contents/{+path}","compare_url":"https://api.github.com/repos/SnappyDataInc/snappydata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SnappyDataInc/snappydata/merges","archive_url":"https://api.github.com/repos/SnappyDataInc/snappydata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SnappyDataInc/snappydata/downloads","issues_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues{/number}","pulls_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls{/number}","milestones_url":"https://api.github.com/repos/SnappyDataInc/snappydata/milestones{/number}","notifications_url":"https://api.github.com/repos/SnappyDataInc/snappydata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SnappyDataInc/snappydata/labels{/name}","releases_url":"https://api.github.com/repos/SnappyDataInc/snappydata/releases{/id}","deployments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/deployments","created_at":"2015-09-16T10:36:36Z","updated_at":"2016-04-18T17:50:20Z","pushed_at":"2016-04-19T06:00:51Z","git_url":"git://github.com/SnappyDataInc/snappydata.git","ssh_url":"git@github.com:SnappyDataInc/snappydata.git","clone_url":"https://github.com/SnappyDataInc/snappydata.git","svn_url":"https://github.com/SnappyDataInc/snappydata","homepage":"http://www.snappydata.io","size":142106,"stargazers_count":248,"watchers_count":248,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":29,"mirror_url":null,"open_issues_count":10,"forks":29,"open_issues":10,"watchers":248,"default_branch":"master"}},"base":{"label":"SnappyDataInc:master","ref":"master","sha":"392b9d3638492e945898e712629f06b465e1d21d","user":{"login":"SnappyDataInc","id":11342682,"avatar_url":"https://avatars.githubusercontent.com/u/11342682?v=3","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"repo":{"id":42580991,"name":"snappydata","full_name":"SnappyDataInc/snappydata","owner":{"login":"SnappyDataInc","id":11342682,"avatar_url":"https://avatars.githubusercontent.com/u/11342682?v=3","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SnappyDataInc/snappydata","description":"SnappyData: OLTP + OLAP Database built on Apache Spark","fork":false,"url":"https://api.github.com/repos/SnappyDataInc/snappydata","forks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/forks","keys_url":"https://api.github.com/repos/SnappyDataInc/snappydata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SnappyDataInc/snappydata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SnappyDataInc/snappydata/teams","hooks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/hooks","issue_events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/events{/number}","events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/events","assignees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/assignees{/user}","branches_url":"https://api.github.com/repos/SnappyDataInc/snappydata/branches{/branch}","tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/tags","blobs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/refs{/sha}","trees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/{sha}","languages_url":"https://api.github.com/repos/SnappyDataInc/snappydata/languages","stargazers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/stargazers","contributors_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contributors","subscribers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscribers","subscription_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscription","commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/commits{/sha}","git_commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/commits{/sha}","comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/comments{/number}","issue_comment_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/comments{/number}","contents_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contents/{+path}","compare_url":"https://api.github.com/repos/SnappyDataInc/snappydata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SnappyDataInc/snappydata/merges","archive_url":"https://api.github.com/repos/SnappyDataInc/snappydata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SnappyDataInc/snappydata/downloads","issues_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues{/number}","pulls_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls{/number}","milestones_url":"https://api.github.com/repos/SnappyDataInc/snappydata/milestones{/number}","notifications_url":"https://api.github.com/repos/SnappyDataInc/snappydata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SnappyDataInc/snappydata/labels{/name}","releases_url":"https://api.github.com/repos/SnappyDataInc/snappydata/releases{/id}","deployments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/deployments","created_at":"2015-09-16T10:36:36Z","updated_at":"2016-04-18T17:50:20Z","pushed_at":"2016-04-19T06:00:51Z","git_url":"git://github.com/SnappyDataInc/snappydata.git","ssh_url":"git@github.com:SnappyDataInc/snappydata.git","clone_url":"https://github.com/SnappyDataInc/snappydata.git","svn_url":"https://github.com/SnappyDataInc/snappydata","homepage":"http://www.snappydata.io","size":142106,"stargazers_count":248,"watchers_count":248,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":29,"mirror_url":null,"open_issues_count":10,"forks":29,"open_issues":10,"watchers":248,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210"},"html":{"href":"https://github.com/SnappyDataInc/snappydata/pull/210"},"issue":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/210"},"comments":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/210/comments"},"review_comments":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210/comments"},"review_comment":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/210/commits"},"statuses":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/3c1023313bf67e5397d17e52b9ba7f2d84c28521"}}}}