{"action":"created","comment":{"url":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/comments/238974988","pull_request_review_id":181644109,"id":238974988,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODk3NDk4OA==","diff_hunk":"@@ -20,29 +15,74 @@ object PushdownTree extends Rule[LogicalPlan] {\n   /** @inheritdoc*/\n   def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {\n     case logical.Project(Seq(), child) => child\n-\n     case n@logical.Project(\n-    list,\n+    projectExpressions,\n     r@DataSourceV2Relation(_, DefaultReader(servers, _, query))) =>\n       if (containsGroupBy(query)) {\n         r\n-      } else if (!canBeHandled(list) || containsDuplicates(list)) {\n+      } else if (containsDuplicates(projectExpressions)) {\n         fixAttributeReferences(n)\n-      } else {\n+      } else if (!query.hasProjection) {\n+        // Split expressions in supported and unsupported to push down\n+        // only the supported ones and keep upside the unsupported\n+        val (supportedProject, unsupportedProject) =\n+        projectExpressions.map { exp =>\n+          var supported: Seq[NamedExpression] = Nil\n+          var unsupported: Option[NamedExpression] = None\n+          exp.foreach {\n+            // this expression cannot be handled but its children can\n+            case e if !canBeHandled(e :: Nil) && canBeHandled(e.children) && unsupported.isEmpty =>\n+              val (supportedExp, supportedReference) =\n+                e.children.map { e =>\n+                  val namedExpression = toNamedExpression(e)\n+                  (namedExpression,\n+                    AttributeReference(\n+                      namedExpression.name,\n+                      namedExpression.dataType,\n+                      namedExpression.nullable,\n+                      namedExpression.metadata)()\n+                  )\n+                }.unzip\n+\n+              val unsupportedNamedExp = toNamedExpression(e.withNewChildren(supportedReference))\n+\n+              supported = supportedExp\n+              unsupported = Some(unsupportedNamedExp)\n+            // this expression can be handled and it have no children","path":"src/main/scala/tech/sourced/gitbase/spark/rule/PushdownTree.scala","position":55,"original_position":55,"commit_id":"05cca84aebbffece8199969369b2139ee39a579f","original_commit_id":"05cca84aebbffece8199969369b2139ee39a579f","user":{"login":"ajnavarro","id":1196465,"node_id":"MDQ6VXNlcjExOTY0NjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1196465?v=4","gravatar_id":"","url":"https://api.github.com/users/ajnavarro","html_url":"https://github.com/ajnavarro","followers_url":"https://api.github.com/users/ajnavarro/followers","following_url":"https://api.github.com/users/ajnavarro/following{/other_user}","gists_url":"https://api.github.com/users/ajnavarro/gists{/gist_id}","starred_url":"https://api.github.com/users/ajnavarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajnavarro/subscriptions","organizations_url":"https://api.github.com/users/ajnavarro/orgs","repos_url":"https://api.github.com/users/ajnavarro/repos","events_url":"https://api.github.com/users/ajnavarro/events{/privacy}","received_events_url":"https://api.github.com/users/ajnavarro/received_events","type":"User","site_admin":false},"body":"```suggestion\r\n            // this expression can be handled and it doesn't have children\r\n```","created_at":"2018-12-05T08:51:48Z","updated_at":"2018-12-05T08:51:48Z","html_url":"https://github.com/src-d/gitbase-spark-connector/pull/51#discussion_r238974988","pull_request_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/comments/238974988"},"html":{"href":"https://github.com/src-d/gitbase-spark-connector/pull/51#discussion_r238974988"},"pull_request":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51","id":235867621,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1ODY3NjIx","html_url":"https://github.com/src-d/gitbase-spark-connector/pull/51","diff_url":"https://github.com/src-d/gitbase-spark-connector/pull/51.diff","patch_url":"https://github.com/src-d/gitbase-spark-connector/pull/51.patch","issue_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/issues/51","number":51,"state":"open","locked":false,"title":"[WIP] Push down only supported expressions on Projects","user":{"login":"ajnavarro","id":1196465,"node_id":"MDQ6VXNlcjExOTY0NjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1196465?v=4","gravatar_id":"","url":"https://api.github.com/users/ajnavarro","html_url":"https://github.com/ajnavarro","followers_url":"https://api.github.com/users/ajnavarro/followers","following_url":"https://api.github.com/users/ajnavarro/following{/other_user}","gists_url":"https://api.github.com/users/ajnavarro/gists{/gist_id}","starred_url":"https://api.github.com/users/ajnavarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajnavarro/subscriptions","organizations_url":"https://api.github.com/users/ajnavarro/orgs","repos_url":"https://api.github.com/users/ajnavarro/repos","events_url":"https://api.github.com/users/ajnavarro/events{/privacy}","received_events_url":"https://api.github.com/users/ajnavarro/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Antonio Jesus Navarro Perez <antnavper@gmail.com>","created_at":"2018-12-04T16:10:52Z","updated_at":"2018-12-05T08:51:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"491e5018111783003dd37ea8def87ec3f9476a85","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51/commits","review_comments_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51/comments","review_comment_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/issues/51/comments","statuses_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/statuses/05cca84aebbffece8199969369b2139ee39a579f","head":{"label":"ajnavarro:push-only-supported-expressions-on-project","ref":"push-only-supported-expressions-on-project","sha":"05cca84aebbffece8199969369b2139ee39a579f","user":{"login":"ajnavarro","id":1196465,"node_id":"MDQ6VXNlcjExOTY0NjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1196465?v=4","gravatar_id":"","url":"https://api.github.com/users/ajnavarro","html_url":"https://github.com/ajnavarro","followers_url":"https://api.github.com/users/ajnavarro/followers","following_url":"https://api.github.com/users/ajnavarro/following{/other_user}","gists_url":"https://api.github.com/users/ajnavarro/gists{/gist_id}","starred_url":"https://api.github.com/users/ajnavarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajnavarro/subscriptions","organizations_url":"https://api.github.com/users/ajnavarro/orgs","repos_url":"https://api.github.com/users/ajnavarro/repos","events_url":"https://api.github.com/users/ajnavarro/events{/privacy}","received_events_url":"https://api.github.com/users/ajnavarro/received_events","type":"User","site_admin":false},"repo":{"id":154486661,"node_id":"MDEwOlJlcG9zaXRvcnkxNTQ0ODY2NjE=","name":"gitbase-spark-connector","full_name":"ajnavarro/gitbase-spark-connector","private":false,"owner":{"login":"ajnavarro","id":1196465,"node_id":"MDQ6VXNlcjExOTY0NjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1196465?v=4","gravatar_id":"","url":"https://api.github.com/users/ajnavarro","html_url":"https://github.com/ajnavarro","followers_url":"https://api.github.com/users/ajnavarro/followers","following_url":"https://api.github.com/users/ajnavarro/following{/other_user}","gists_url":"https://api.github.com/users/ajnavarro/gists{/gist_id}","starred_url":"https://api.github.com/users/ajnavarro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajnavarro/subscriptions","organizations_url":"https://api.github.com/users/ajnavarro/orgs","repos_url":"https://api.github.com/users/ajnavarro/repos","events_url":"https://api.github.com/users/ajnavarro/events{/privacy}","received_events_url":"https://api.github.com/users/ajnavarro/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ajnavarro/gitbase-spark-connector","description":null,"fork":true,"url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector","forks_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/forks","keys_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/teams","hooks_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/hooks","issue_events_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/issues/events{/number}","events_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/events","assignees_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/assignees{/user}","branches_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/branches{/branch}","tags_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/tags","blobs_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/languages","stargazers_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/stargazers","contributors_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/contributors","subscribers_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/subscribers","subscription_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/subscription","commits_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/contents/{+path}","compare_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/merges","archive_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/downloads","issues_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/issues{/number}","pulls_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/labels{/name}","releases_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/releases{/id}","deployments_url":"https://api.github.com/repos/ajnavarro/gitbase-spark-connector/deployments","created_at":"2018-10-24T11:05:10Z","updated_at":"2018-10-24T11:07:14Z","pushed_at":"2018-12-04T17:05:00Z","git_url":"git://github.com/ajnavarro/gitbase-spark-connector.git","ssh_url":"git@github.com:ajnavarro/gitbase-spark-connector.git","clone_url":"https://github.com/ajnavarro/gitbase-spark-connector.git","svn_url":"https://github.com/ajnavarro/gitbase-spark-connector","homepage":null,"size":4695,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"src-d:master","ref":"master","sha":"44534f1e30b0a708557a545b48366c2e46b2824e","user":{"login":"src-d","id":15128793,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTI4Nzkz","avatar_url":"https://avatars2.githubusercontent.com/u/15128793?v=4","gravatar_id":"","url":"https://api.github.com/users/src-d","html_url":"https://github.com/src-d","followers_url":"https://api.github.com/users/src-d/followers","following_url":"https://api.github.com/users/src-d/following{/other_user}","gists_url":"https://api.github.com/users/src-d/gists{/gist_id}","starred_url":"https://api.github.com/users/src-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/src-d/subscriptions","organizations_url":"https://api.github.com/users/src-d/orgs","repos_url":"https://api.github.com/users/src-d/repos","events_url":"https://api.github.com/users/src-d/events{/privacy}","received_events_url":"https://api.github.com/users/src-d/received_events","type":"Organization","site_admin":false},"repo":{"id":153249177,"node_id":"MDEwOlJlcG9zaXRvcnkxNTMyNDkxNzc=","name":"gitbase-spark-connector","full_name":"src-d/gitbase-spark-connector","private":false,"owner":{"login":"src-d","id":15128793,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTI4Nzkz","avatar_url":"https://avatars2.githubusercontent.com/u/15128793?v=4","gravatar_id":"","url":"https://api.github.com/users/src-d","html_url":"https://github.com/src-d","followers_url":"https://api.github.com/users/src-d/followers","following_url":"https://api.github.com/users/src-d/following{/other_user}","gists_url":"https://api.github.com/users/src-d/gists{/gist_id}","starred_url":"https://api.github.com/users/src-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/src-d/subscriptions","organizations_url":"https://api.github.com/users/src-d/orgs","repos_url":"https://api.github.com/users/src-d/repos","events_url":"https://api.github.com/users/src-d/events{/privacy}","received_events_url":"https://api.github.com/users/src-d/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/src-d/gitbase-spark-connector","description":null,"fork":false,"url":"https://api.github.com/repos/src-d/gitbase-spark-connector","forks_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/forks","keys_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/teams","hooks_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/hooks","issue_events_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/issues/events{/number}","events_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/events","assignees_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/assignees{/user}","branches_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/branches{/branch}","tags_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/tags","blobs_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/languages","stargazers_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/stargazers","contributors_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/contributors","subscribers_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/subscribers","subscription_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/subscription","commits_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/contents/{+path}","compare_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/merges","archive_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/downloads","issues_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/issues{/number}","pulls_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/labels{/name}","releases_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/releases{/id}","deployments_url":"https://api.github.com/repos/src-d/gitbase-spark-connector/deployments","created_at":"2018-10-16T08:21:43Z","updated_at":"2018-12-04T13:05:59Z","pushed_at":"2018-12-04T18:56:57Z","git_url":"git://github.com/src-d/gitbase-spark-connector.git","ssh_url":"git@github.com:src-d/gitbase-spark-connector.git","clone_url":"https://github.com/src-d/gitbase-spark-connector.git","svn_url":"https://github.com/src-d/gitbase-spark-connector","homepage":null,"size":4689,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":6,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51"},"html":{"href":"https://github.com/src-d/gitbase-spark-connector/pull/51"},"issue":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/issues/51"},"comments":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/src-d/gitbase-spark-connector/statuses/05cca84aebbffece8199969369b2139ee39a579f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ajnavarro"}}