{"action":"created","issue":{"url":"https://api.github.com/repos/prestodb/presto/issues/5439","repository_url":"https://api.github.com/repos/prestodb/presto","labels_url":"https://api.github.com/repos/prestodb/presto/issues/5439/labels{/name}","comments_url":"https://api.github.com/repos/prestodb/presto/issues/5439/comments","events_url":"https://api.github.com/repos/prestodb/presto/issues/5439/events","html_url":"https://github.com/prestodb/presto/issues/5439","id":159913400,"number":5439,"title":"NoSuchElementException in AddExchanges","user":{"login":"yuananf","id":4101738,"avatar_url":"https://avatars.githubusercontent.com/u/4101738?v=3","gravatar_id":"","url":"https://api.github.com/users/yuananf","html_url":"https://github.com/yuananf","followers_url":"https://api.github.com/users/yuananf/followers","following_url":"https://api.github.com/users/yuananf/following{/other_user}","gists_url":"https://api.github.com/users/yuananf/gists{/gist_id}","starred_url":"https://api.github.com/users/yuananf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuananf/subscriptions","organizations_url":"https://api.github.com/users/yuananf/orgs","repos_url":"https://api.github.com/users/yuananf/repos","events_url":"https://api.github.com/users/yuananf/events{/privacy}","received_events_url":"https://api.github.com/users/yuananf/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/prestodb/presto/labels/RELEASE-BLOCKER","name":"RELEASE-BLOCKER","color":"eb6420"}],"state":"closed","locked":false,"assignee":{"login":"erichwang","id":737851,"avatar_url":"https://avatars.githubusercontent.com/u/737851?v=3","gravatar_id":"","url":"https://api.github.com/users/erichwang","html_url":"https://github.com/erichwang","followers_url":"https://api.github.com/users/erichwang/followers","following_url":"https://api.github.com/users/erichwang/following{/other_user}","gists_url":"https://api.github.com/users/erichwang/gists{/gist_id}","starred_url":"https://api.github.com/users/erichwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichwang/subscriptions","organizations_url":"https://api.github.com/users/erichwang/orgs","repos_url":"https://api.github.com/users/erichwang/repos","events_url":"https://api.github.com/users/erichwang/events{/privacy}","received_events_url":"https://api.github.com/users/erichwang/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-06-13T09:57:52Z","updated_at":"2016-06-15T01:44:44Z","closed_at":"2016-06-14T23:19:14Z","body":"When running tpcds queries 5, 77, 80, I get the following error:\r\n```\r\njava.util.NoSuchElementException: No value present\r\n\tat java.util.Optional.get(Optional.java:135)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.selectUnionPartitioning(AddExchanges.java:1078)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitUnion(AddExchanges.java:1101)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitUnion(AddExchanges.java:190)\r\n\tat com.facebook.presto.sql.planner.plan.UnionNode.accept(UnionNode.java:42)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.planChild(AddExchanges.java:1209)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitPlan(AddExchanges.java:217)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitPlan(AddExchanges.java:190)\r\n\tat com.facebook.presto.sql.planner.plan.PlanVisitor.visitGroupId(PlanVisitor.java:155)\r\n\tat com.facebook.presto.sql.planner.plan.GroupIdNode.accept(GroupIdNode.java:125)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.planChild(AddExchanges.java:1209)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitAggregation(AddExchanges.java:284)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitAggregation(AddExchanges.java:190)\r\n\tat com.facebook.presto.sql.planner.plan.AggregationNode.accept(AggregationNode.java:189)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.planChild(AddExchanges.java:1209)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitProject(AddExchanges.java:233)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitProject(AddExchanges.java:190)\r\n\tat com.facebook.presto.sql.planner.plan.ProjectNode.accept(ProjectNode.java:81)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.planChild(AddExchanges.java:1209)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitTopN(AddExchanges.java:522)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitTopN(AddExchanges.java:190)\r\n\tat com.facebook.presto.sql.planner.plan.TopNNode.accept(TopNNode.java:112)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.planChild(AddExchanges.java:1209)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitOutput(AddExchanges.java:239)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges$Rewriter.visitOutput(AddExchanges.java:190)\r\n\tat com.facebook.presto.sql.planner.plan.OutputNode.accept(OutputNode.java:81)\r\n\tat com.facebook.presto.sql.planner.optimizations.AddExchanges.optimize(AddExchanges.java:152)\r\n\tat com.facebook.presto.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:99)\r\n\tat com.facebook.presto.execution.SqlQueryExecution.doAnalyzeQuery(SqlQueryExecution.java:280)\r\n\tat com.facebook.presto.execution.SqlQueryExecution.analyzeQuery(SqlQueryExecution.java:259)\r\n\tat com.facebook.presto.execution.SqlQueryExecution.start(SqlQueryExecution.java:223)\r\n\tat com.facebook.presto.execution.QueuedExecution.lambda$start$1(QueuedExecution.java:62)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n```\r\n\r\n\r\nSample query 80:\r\n```\r\nWITH ssr AS\r\n(SELECT\r\n    s_store_id AS store_id,\r\n    sum(ss_ext_sales_price) AS sales,\r\n    sum(coalesce(sr_return_amt, 0)) AS returns,\r\n    sum(ss_net_profit - coalesce(sr_net_loss, 0)) AS profit\r\n  FROM store_sales\r\n    LEFT OUTER JOIN store_returns ON\r\n                                    (ss_item_sk = sr_item_sk AND\r\n                                      ss_ticket_number = sr_ticket_number)\r\n    ,\r\n    date_dim, store, item, promotion\r\n  WHERE ss_sold_date_sk = d_date_sk\r\n    AND d_date BETWEEN cast('2000-08-23' AS DATE)\r\n  AND (cast('2000-08-23' AS DATE) + INTERVAL '30' day)\r\n    AND ss_store_sk = s_store_sk\r\n    AND ss_item_sk = i_item_sk\r\n    AND i_current_price > 50\r\n    AND ss_promo_sk = p_promo_sk\r\n    AND p_channel_tv = 'N'\r\n  GROUP BY s_store_id),\r\n    csr AS\r\n  (SELECT\r\n    cp_catalog_page_id AS catalog_page_id,\r\n    sum(cs_ext_sales_price) AS sales,\r\n    sum(coalesce(cr_return_amount, 0)) AS returns,\r\n    sum(cs_net_profit - coalesce(cr_net_loss, 0)) AS profit\r\n  FROM catalog_sales\r\n    LEFT OUTER JOIN catalog_returns ON\r\n                                      (cs_item_sk = cr_item_sk AND\r\n                                        cs_order_number = cr_order_number)\r\n    ,\r\n    date_dim, catalog_page, item, promotion\r\n  WHERE cs_sold_date_sk = d_date_sk\r\n    AND d_date BETWEEN cast('2000-08-23' AS DATE)\r\n  AND (cast('2000-08-23' AS DATE) + INTERVAL '30' day)\r\n    AND cs_catalog_page_sk = cp_catalog_page_sk\r\n    AND cs_item_sk = i_item_sk\r\n    AND i_current_price > 50\r\n    AND cs_promo_sk = p_promo_sk\r\n    AND p_channel_tv = 'N'\r\n  GROUP BY cp_catalog_page_id),\r\n    wsr AS\r\n  (SELECT\r\n    web_site_id,\r\n    sum(ws_ext_sales_price) AS sales,\r\n    sum(coalesce(wr_return_amt, 0)) AS returns,\r\n    sum(ws_net_profit - coalesce(wr_net_loss, 0)) AS profit\r\n  FROM web_sales\r\n    LEFT OUTER JOIN web_returns ON\r\n                                  (ws_item_sk = wr_item_sk AND ws_order_number = wr_order_number)\r\n    ,\r\n    date_dim, web_site, item, promotion\r\n  WHERE ws_sold_date_sk = d_date_sk\r\n    AND d_date BETWEEN cast('2000-08-23' AS DATE)\r\n  AND (cast('2000-08-23' AS DATE) + INTERVAL '30' day)\r\n    AND ws_web_site_sk = web_site_sk\r\n    AND ws_item_sk = i_item_sk\r\n    AND i_current_price > 50\r\n    AND ws_promo_sk = p_promo_sk\r\n    AND p_channel_tv = 'N'\r\n  GROUP BY web_site_id)\r\nSELECT\r\n  channel,\r\n  id,\r\n  sum(sales) AS sales,\r\n  sum(returns) AS returns,\r\n  sum(profit) AS profit\r\nFROM (SELECT\r\n        'store channel' AS channel,\r\n        concat('store', store_id) AS id,\r\n        sales,\r\n        returns,\r\n        profit\r\n      FROM ssr\r\n      UNION ALL\r\n      SELECT\r\n        'catalog channel' AS channel,\r\n        concat('catalog_page', catalog_page_id) AS id,\r\n        sales,\r\n        returns,\r\n        profit\r\n      FROM csr\r\n      UNION ALL\r\n      SELECT\r\n        'web channel' AS channel,\r\n        concat('web_site', web_site_id) AS id,\r\n        sales,\r\n        returns,\r\n        profit\r\n      FROM wsr) x\r\nGROUP BY ROLLUP (channel, id)\r\nORDER BY channel, id\r\nLIMIT 100;\r\n```"},"comment":{"url":"https://api.github.com/repos/prestodb/presto/issues/comments/226066311","html_url":"https://github.com/prestodb/presto/issues/5439#issuecomment-226066311","issue_url":"https://api.github.com/repos/prestodb/presto/issues/5439","id":226066311,"user":{"login":"electrum","id":9230,"avatar_url":"https://avatars.githubusercontent.com/u/9230?v=3","gravatar_id":"","url":"https://api.github.com/users/electrum","html_url":"https://github.com/electrum","followers_url":"https://api.github.com/users/electrum/followers","following_url":"https://api.github.com/users/electrum/following{/other_user}","gists_url":"https://api.github.com/users/electrum/gists{/gist_id}","starred_url":"https://api.github.com/users/electrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/electrum/subscriptions","organizations_url":"https://api.github.com/users/electrum/orgs","repos_url":"https://api.github.com/users/electrum/repos","events_url":"https://api.github.com/users/electrum/events{/privacy}","received_events_url":"https://api.github.com/users/electrum/received_events","type":"User","site_admin":false},"created_at":"2016-06-15T01:44:44Z","updated_at":"2016-06-15T01:44:44Z","body":"Thanks for finding this. Fixed now."}}
{"actor":{"display_login":"electrum"}}