[ https://issues.apache.org/jira/browse/CALCITE-1488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15657351#comment-15657351 ]
Julian Hyde edited comment on CALCITE-1488 at 11/11/16 4:32 PM: ---------------------------------------------------------------- Thanks [~julianhyde]! I applied this patch locally and it works for me. I still have a problem with Aggregates that lack a group set, like {{SELECT COUNT\(\*) FROM s.foo WHERE 1 = 0}}. PruneEmptyRules doesn't reduce that, since the result is going to be one row, not empty. The ValuesReduceRules don't either, because they don't touch Aggregates. I ended up addressing this with a rule on my end: https://gist.github.com/gianm/1c192a47a7ce284be8af986f97e6dd8f Does that approach make sense? If so do you think it makes sense to contribute to Calcite? One thing I'm not sure about is if there's a better way to figure out what should be 0 and what should be NULL other than hard-coding COUNT and SUM0. was (Author: gian): Thanks [~julianhyde]! I applied this patch locally and it works for me. I still have a problem with Aggregates that lack a group set, like {{SELECT COUNT(*) FROM s.foo WHERE 1 = 0}}. PruneEmptyRules doesn't reduce that, since the result is going to be one row, not empty. The ValuesReduceRules don't either, because they don't touch Aggregates. I ended up addressing this with a rule on my end: https://gist.github.com/gianm/1c192a47a7ce284be8af986f97e6dd8f Does that approach make sense? If so do you think it makes sense to contribute to Calcite? One thing I'm not sure about is if there's a better way to figure out what should be 0 and what should be NULL other than hard-coding COUNT and SUM0. > ValuesReduceRule should ignore empty Values > ------------------------------------------- > > Key: CALCITE-1488 > URL: https://issues.apache.org/jira/browse/CALCITE-1488 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.10.0 > Reporter: Gian Merlino > Assignee: Julian Hyde > Fix For: 1.11.0 > > > ValuesReduceRule doesn't propagate rowType on Project of empty Values. If > ValuesReduceRule is trying to reduce a Project on top of an empty Values, > then changeCount ends up 0, and it returns the underlying Values. This leads > to an assertion failure because the returned Values does not have the > expected rowType. > One way to fix this is changing the "Filter had no effect" logic from > "{{changeCount == 0}}" to "{{changeCount == 0 && projectExprs == null}}". -- This message was sent by Atlassian JIRA (v6.3.4#6332)