[jira] [Updated] (CALCITE-2480) NameSet.contains wrongly returns false when element in set is upper-case and seek is lower-case
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Julian Hyde updated CALCITE-2480: - Summary: NameSet.contains wrongly returns false when element in set is upper-case and seek is lower-case (was: calcite.util.NameSet#contains does not always work) > NameSet.contains wrongly returns false when element in set is upper-case and > seek is lower-case > --- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > Fix For: 1.18.0 > > > {code:java} @Test public void testNameSetContains() { > final NameSet names = new NameSet(); > names.add("COUNT"); > names.add("COVAR_POP"); > assertThat(names.contains("count", true), is(false)); > assertNsContains(names, "count", false, true); > } > private void assertNsContains(NameSet names, String item, boolean > caseSensitive, boolean result) { > assertEquals(names + ", contains(" + item + (caseSensitive ? ", > caseSensitive" : "") > + ")", > result, names.contains(item, caseSensitive)); > }{code} > Output > {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) > Expected :true > Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Resolved] (CALCITE-2480) calcite.util.NameSet#contains does not always work
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Julian Hyde resolved CALCITE-2480. -- Resolution: Fixed Fix Version/s: 1.18.0 Fixed in [6d6421c8| http://git-wip-us.apache.org/repos/asf/calcite/commit/6d6421c8]. > calcite.util.NameSet#contains does not always work > -- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > Fix For: 1.18.0 > > > {code:java} @Test public void testNameSetContains() { > final NameSet names = new NameSet(); > names.add("COUNT"); > names.add("COVAR_POP"); > assertThat(names.contains("count", true), is(false)); > assertNsContains(names, "count", false, true); > } > private void assertNsContains(NameSet names, String item, boolean > caseSensitive, boolean result) { > assertEquals(names + ", contains(" + item + (caseSensitive ? ", > caseSensitive" : "") > + ")", > result, names.contains(item, caseSensitive)); > }{code} > Output > {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) > Expected :true > Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2440) SQL with UNNEST fail in volcano planner in some cases
[ https://issues.apache.org/jira/browse/CALCITE-2440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585420#comment-16585420 ] Shuyi Chen commented on CALCITE-2440: - [~vvysotskyi], thanks a lot. There are 52 rules together, it's hard to identify the set. After running the volcanoplanner, the relsubset.best is null and bestCost is {inf}. Do you have any idea on what might be the cause so I can narrow down the search space? > SQL with UNNEST fail in volcano planner in some cases > - > > Key: CALCITE-2440 > URL: https://issues.apache.org/jira/browse/CALCITE-2440 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Shuyi Chen >Assignee: Julian Hyde >Priority: Major > > After [CALCITE-2291|https://issues.apache.org/jira/browse/CALCITE-2291], > specifically, [this > line|https://github.com/apache/calcite/blob/7088dc7261d294b7c6d5c9f4463435e95f0b9c15/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L1952] > causes volcano planner to fail to find the best plan for query > {code:java} > SELECT a, s FROM T, UNNEST(T.c) as A (s) > {code} > . I'll try to write a unittest in Calcite to reproduce. [~cshi] [~vvysotskyi] > [~HanumathRao], can you provide some context? Thanks a lot. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-2480) calcite.util.NameSet#contains does not work
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimir Sitnikov updated CALCITE-2480: --- Summary: calcite.util.NameSet#contains does not work (was: calcite.util.NameSet does not work) > calcite.util.NameSet#contains does not work > --- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > {code:java} @Test public void testNameSetContains() { > final NameSet names = new NameSet(); > names.add("COUNT"); > names.add("COVAR_POP"); > assertThat(names.contains("count", true), is(false)); > assertNsContains(names, "count", false, true); > } > private void assertNsContains(NameSet names, String item, boolean > caseSensitive, boolean result) { > assertEquals(names + ", contains(" + item + (caseSensitive ? ", > caseSensitive" : "") > + ")", > result, names.contains(item, caseSensitive)); > }{code} > Output > {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) > Expected :true > Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-2480) calcite.util.NameSet#contains does not always work
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimir Sitnikov updated CALCITE-2480: --- Summary: calcite.util.NameSet#contains does not always work (was: calcite.util.NameSet#contains does not work) > calcite.util.NameSet#contains does not always work > -- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > {code:java} @Test public void testNameSetContains() { > final NameSet names = new NameSet(); > names.add("COUNT"); > names.add("COVAR_POP"); > assertThat(names.contains("count", true), is(false)); > assertNsContains(names, "count", false, true); > } > private void assertNsContains(NameSet names, String item, boolean > caseSensitive, boolean result) { > assertEquals(names + ", contains(" + item + (caseSensitive ? ", > caseSensitive" : "") > + ")", > result, names.contains(item, caseSensitive)); > }{code} > Output > {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) > Expected :true > Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Issue Comment Deleted] (CALCITE-2479) SqlAdvisor: automatically quote identifiers that look like SQL keywords
[ https://issues.apache.org/jira/browse/CALCITE-2479?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimir Sitnikov updated CALCITE-2479: --- Comment: was deleted (was: Note: the PR 773 adds just an ignored test case. The solution is to be investigated.) > SqlAdvisor: automatically quote identifiers that look like SQL keywords > --- > > Key: CALCITE-2479 > URL: https://issues.apache.org/jira/browse/CALCITE-2479 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Case for SqlAdvisorTest: > {code:java} @Test @WithLex(Lex.JAVA) public void testAdviceExpression() { > String sql; > sql = "select s.`count`+s.co^ from (select 1 `count` from emp) s"; > assertComplete(sql, "COLUMN(count)\n", "co", > ImmutableMap.of("COLUMN(count)", "`count`")); > } > {code} > It should automatically quote the suggested column name {{count}} since > otherwise it is confused with {{count}} keyword. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-2479) SqlAdvisor: automatically quote identifiers that look like SQL keywords
[ https://issues.apache.org/jira/browse/CALCITE-2479?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimir Sitnikov updated CALCITE-2479: --- Summary: SqlAdvisor: automatically quote identifiers that look like SQL keywords (was: SqlAdvisor: automatically quote SQL keywords) > SqlAdvisor: automatically quote identifiers that look like SQL keywords > --- > > Key: CALCITE-2479 > URL: https://issues.apache.org/jira/browse/CALCITE-2479 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Case for SqlAdvisorTest: > {code:java} @Test @WithLex(Lex.JAVA) public void testAdviceExpression() { > String sql; > sql = "select s.`count`+s.co^ from (select 1 `count` from emp) s"; > assertComplete(sql, "COLUMN(count)\n", "co", > ImmutableMap.of("COLUMN(count)", "`count`")); > } > {code} > It should automatically quote the suggested column name {{count}} since > otherwise it is confused with {{count}} keyword. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-2479) SqlAdvisor: automatically quote SQL keywords
[ https://issues.apache.org/jira/browse/CALCITE-2479?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimir Sitnikov updated CALCITE-2479: --- Summary: SqlAdvisor: automatically quote SQL keywords (was: SqlAdvisor: lack of hints for select s.count SQL) > SqlAdvisor: automatically quote SQL keywords > > > Key: CALCITE-2479 > URL: https://issues.apache.org/jira/browse/CALCITE-2479 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Case for SqlAdvisorTest: > {code:java} @Ignore("It looks like s.count clashes with COUNT keyword, > however the same SQL executes just fine") > @Test @WithLex(Lex.JAVA) public void testAdviceExpression() { > String sql; > sql = "select s.count+s.co^ from (select 1 count from emp) s"; > assertComplete(sql, "COLUMN(count)\n", "co", > ImmutableMap.of("COLUMN(count)", "count")); > } > {code} > It is not clear why SQL fails to advise, however the same query works just > fine via JDBC. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Comment Edited] (CALCITE-2480) calcite.util.NameSet does not work
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585262#comment-16585262 ] Vladimir Sitnikov edited comment on CALCITE-2480 at 8/19/18 7:54 PM: - [~julianhyde], please add toString to {{NameSet}} as well: {code:java} @Override public String toString() { return names.toString(); } {code} + some more tests {code:java} @Test public void testNameSetContains1() { final NameSet names = new NameSet(); names.add("COUNT"); names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); assertNsContains(names,"cOunt", true, false); assertNsContains(names, "cOunt", false, true); } @Test public void testNameSetContains2() { final NameSet names = new NameSet(); names.add("count"); names.add("COVAR_POP"); assertNsContains(names,"COUNT", true, false); assertNsContains(names, "COUNT", false, true); assertNsContains(names,"CoUNT", true, false); assertNsContains(names, "CoUNT", false, true); } @Test public void testNameSetContains3() { final NameSet names = new NameSet(); names.add("cOunt"); names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); assertNsContains(names,"COUNT", true, false); assertNsContains(names, "COUNT", false, true); assertNsContains(names,"cOunt", true, true); assertNsContains(names, "cOunt", false, true); } @Test public void testNameSetContains4() { List tst = Arrays.asList("cOunt", "coUnt", "couNt"); final NameSet names = new NameSet(); for (String s : tst) { names.add(s); } names.add("COVAR_POP"); for (String s : tst) { assertNsContains(names, s, true, true); assertNsContains(names, s, false, true); } List caseInsensitive = Arrays.asList("count", "cOUnt", "cOuNt", "Count"); for (String s : caseInsensitive) { assertNsContains(names, s, true, false); assertNsContains(names, s, false, true); } } private void assertNsContains(NameSet names, String item, boolean caseSensitive, boolean result) { assertEquals( names + ", contains(" + item + (caseSensitive ? ", caseSensitive" : "") + ")", result, names.contains(item, caseSensitive)); } {code} was (Author: vladimirsitnikov): [~julianhyde], please add toString to {{NameSet}} as well: {code:java} @Override public String toString() { return names.toString(); } {code} + some more tests {code:java} @Test public void testNameSetContains1() { final NameSet names = new NameSet(); names.add("COUNT"); names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); assertNsContains(names,"cOunt", true, false); assertNsContains(names, "cOunt", false, true); } @Test public void testNameSetContains2() { final NameSet names = new NameSet(); names.add("count"); names.add("COVAR_POP"); assertNsContains(names,"COUNT", true, false); assertNsContains(names, "COUNT", false, true); assertNsContains(names,"CoUNT", true, false); assertNsContains(names, "CoUNT", false, true); } @Test public void testNameSetContains3() { final NameSet names = new NameSet(); names.add("cOunt"); names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); assertNsContains(names,"COUNT", true, false); assertNsContains(names, "COUNT", false, true); assertNsContains(names,"cOunt", true, true); assertNsContains(names, "cOunt", false, true); } @Test public void testNameSetContains4() { List tst = Arrays.asList("cOunt", "coUnt", "couNt"); final NameSet names = new NameSet(); for (String s : tst) { names.add(s); } names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); for (String s : tst) { assertNsContains(names, s, true, true); assertNsContains(names, s, false, true); } List caseInsensitive = Arrays.asList("cOUnt", "cOuNt", "Count"); for (String s : caseInsensitive) { assertNsContains(names, s, true, false); assertNsContains(names, s, false, true); } } private void assertNsContains(NameSet names, String item, boolean caseSensitive, boolean result) { assertEquals( names + ", contains(" + item + (caseSensitive ? ", caseSensitive" : "") + ")", result, names.contains(item, caseSensitive)); } {code} > calcite.util.NameSet does not work > -- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite >
[jira] [Commented] (CALCITE-2480) calcite.util.NameSet does not work
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585262#comment-16585262 ] Vladimir Sitnikov commented on CALCITE-2480: [~julianhyde], please add toString to {{NameSet}} as well: {code:java} @Override public String toString() { return names.toString(); } {code} + some more tests {code:java} @Test public void testNameSetContains1() { final NameSet names = new NameSet(); names.add("COUNT"); names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); assertNsContains(names,"cOunt", true, false); assertNsContains(names, "cOunt", false, true); } @Test public void testNameSetContains2() { final NameSet names = new NameSet(); names.add("count"); names.add("COVAR_POP"); assertNsContains(names,"COUNT", true, false); assertNsContains(names, "COUNT", false, true); assertNsContains(names,"CoUNT", true, false); assertNsContains(names, "CoUNT", false, true); } @Test public void testNameSetContains3() { final NameSet names = new NameSet(); names.add("cOunt"); names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); assertNsContains(names,"COUNT", true, false); assertNsContains(names, "COUNT", false, true); assertNsContains(names,"cOunt", true, true); assertNsContains(names, "cOunt", false, true); } @Test public void testNameSetContains4() { List tst = Arrays.asList("cOunt", "coUnt", "couNt"); final NameSet names = new NameSet(); for (String s : tst) { names.add(s); } names.add("COVAR_POP"); assertNsContains(names,"count", true, false); assertNsContains(names, "count", false, true); for (String s : tst) { assertNsContains(names, s, true, true); assertNsContains(names, s, false, true); } List caseInsensitive = Arrays.asList("cOUnt", "cOuNt", "Count"); for (String s : caseInsensitive) { assertNsContains(names, s, true, false); assertNsContains(names, s, false, true); } } private void assertNsContains(NameSet names, String item, boolean caseSensitive, boolean result) { assertEquals( names + ", contains(" + item + (caseSensitive ? ", caseSensitive" : "") + ")", result, names.contains(item, caseSensitive)); } {code} > calcite.util.NameSet does not work > -- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > {code:java} @Test public void testNameSetContains() { > final NameSet names = new NameSet(); > names.add("COUNT"); > names.add("COVAR_POP"); > assertThat(names.contains("count", true), is(false)); > assertNsContains(names, "count", false, true); > } > private void assertNsContains(NameSet names, String item, boolean > caseSensitive, boolean result) { > assertEquals(names + ", contains(" + item + (caseSensitive ? ", > caseSensitive" : "") > + ")", > result, names.contains(item, caseSensitive)); > }{code} > Output > {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) > Expected :true > Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2480) calcite.util.NameSet does not work
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585236#comment-16585236 ] Julian Hyde commented on CALCITE-2480: -- I'm working on this. > calcite.util.NameSet does not work > -- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Vladimir Sitnikov >Assignee: Vladimir Sitnikov >Priority: Major > > {code:java} @Test public void testNameSetContains() { > final NameSet names = new NameSet(); > names.add("COUNT"); > names.add("COVAR_POP"); > assertThat(names.contains("count", true), is(false)); > assertNsContains(names, "count", false, true); > } > private void assertNsContains(NameSet names, String item, boolean > caseSensitive, boolean result) { > assertEquals(names + ", contains(" + item + (caseSensitive ? ", > caseSensitive" : "") > + ")", > result, names.contains(item, caseSensitive)); > }{code} > Output > {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) > Expected :true > Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Assigned] (CALCITE-2480) calcite.util.NameSet does not work
[ https://issues.apache.org/jira/browse/CALCITE-2480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Julian Hyde reassigned CALCITE-2480: Assignee: Julian Hyde (was: Vladimir Sitnikov) > calcite.util.NameSet does not work > -- > > Key: CALCITE-2480 > URL: https://issues.apache.org/jira/browse/CALCITE-2480 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > {code:java} @Test public void testNameSetContains() { > final NameSet names = new NameSet(); > names.add("COUNT"); > names.add("COVAR_POP"); > assertThat(names.contains("count", true), is(false)); > assertNsContains(names, "count", false, true); > } > private void assertNsContains(NameSet names, String item, boolean > caseSensitive, boolean result) { > assertEquals(names + ", contains(" + item + (caseSensitive ? ", > caseSensitive" : "") > + ")", > result, names.contains(item, caseSensitive)); > }{code} > Output > {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) > Expected :true > Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2480) calcite.util.NameSet does not work
Vladimir Sitnikov created CALCITE-2480: -- Summary: calcite.util.NameSet does not work Key: CALCITE-2480 URL: https://issues.apache.org/jira/browse/CALCITE-2480 Project: Calcite Issue Type: Bug Components: core Reporter: Vladimir Sitnikov Assignee: Vladimir Sitnikov {code:java} @Test public void testNameSetContains() { final NameSet names = new NameSet(); names.add("COUNT"); names.add("COVAR_POP"); assertThat(names.contains("count", true), is(false)); assertNsContains(names, "count", false, true); } private void assertNsContains(NameSet names, String item, boolean caseSensitive, boolean result) { assertEquals(names + ", contains(" + item + (caseSensitive ? ", caseSensitive" : "") + ")", result, names.contains(item, caseSensitive)); }{code} Output {noformat}java.lang.AssertionError: [COUNT, COVAR_POP], contains(count) Expected :true Actual :false{noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Comment Edited] (CALCITE-2479) SqlAdvisor: lack of hints for select s.count SQL
[ https://issues.apache.org/jira/browse/CALCITE-2479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585212#comment-16585212 ] Vladimir Sitnikov edited comment on CALCITE-2479 at 8/19/18 5:10 PM: - My bad: it turns out {{select s.count ...}} does not work, and it requires {{count}} to be quoted. Then advisor should automatically quote identifiers that look like keywords. was (Author: vladimirsitnikov): My bad: it turns out {{select s.count ... }} does not work, and it requires {{count}} to be quoted. Then advisor should automatically quote identifiers that look like keywords. > SqlAdvisor: lack of hints for select s.count SQL > > > Key: CALCITE-2479 > URL: https://issues.apache.org/jira/browse/CALCITE-2479 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Case for SqlAdvisorTest: > {code:java} @Ignore("It looks like s.count clashes with COUNT keyword, > however the same SQL executes just fine") > @Test @WithLex(Lex.JAVA) public void testAdviceExpression() { > String sql; > sql = "select s.count+s.co^ from (select 1 count from emp) s"; > assertComplete(sql, "COLUMN(count)\n", "co", > ImmutableMap.of("COLUMN(count)", "count")); > } > {code} > It is not clear why SQL fails to advise, however the same query works just > fine via JDBC. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2479) SqlAdvisor: lack of hints for select s.count SQL
[ https://issues.apache.org/jira/browse/CALCITE-2479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585212#comment-16585212 ] Vladimir Sitnikov commented on CALCITE-2479: My bad: it turns out {{select s.count ... }} does not work, and it requires {{count}} to be quoted. Then advisor should automatically quote identifiers that look like keywords. > SqlAdvisor: lack of hints for select s.count SQL > > > Key: CALCITE-2479 > URL: https://issues.apache.org/jira/browse/CALCITE-2479 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Case for SqlAdvisorTest: > {code:java} @Ignore("It looks like s.count clashes with COUNT keyword, > however the same SQL executes just fine") > @Test @WithLex(Lex.JAVA) public void testAdviceExpression() { > String sql; > sql = "select s.count+s.co^ from (select 1 count from emp) s"; > assertComplete(sql, "COLUMN(count)\n", "co", > ImmutableMap.of("COLUMN(count)", "count")); > } > {code} > It is not clear why SQL fails to advise, however the same query works just > fine via JDBC. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2434) SqlAdvisor.getCompletionHints does not work for nested identifiers sub-match
[ https://issues.apache.org/jira/browse/CALCITE-2434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585207#comment-16585207 ] Vladimir Sitnikov commented on CALCITE-2434: It turns out cases like {{select scott.emp.deptno from scott.emp;}} do not work at all. SqlValidatorImpl ends up in lookupNameCompletionHints, and it is trying to find scope for "CATALOG": {code:java} for (String name : subNames) { if (ns == null) { final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); scope.resolve(ImmutableList.of(name), nameMatcher, false, resolved); // <-- name === "CATALOG" if (resolved.count() == 1) { ns = resolved.only().namespace; } {code} however the lookup fails, thus the whole thing stops. I suggest to fork those cases in a separate JIRA issue. I've added the cases in https://github.com/apache/calcite/pull/773/commits/204c8e747c2c37d7579cd45e9df90a31fc90ddf0, so it is clear what works and what does not. > SqlAdvisor.getCompletionHints does not work for nested identifiers sub-match > > > Key: CALCITE-2434 > URL: https://issues.apache.org/jira/browse/CALCITE-2434 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Vladimir Sitnikov >Priority: Major > > Test (SqlAdvisorTest): > {code:java} @Test public void testNestSchema() throws Exception { > String sql; > sql = "select * from sales.n^"; > assertComplete( > sql, > ...); > } > {code} > Expected output: "SALES.NEST" schema and tables inside and so on > Actual output: empty. > The thing is it properly uses {{n}} for prefix search, however it uses > {{hint.toString()}} and it fails for multi-name identifiers: > {code:java}// Regular identifier. Case-insensitive match. > for (SqlMoniker hint : completionHints) { > String cname = hint.toString(); > if ((cname.length() >= word.length()) > && cname.substring(0, word.length()).equalsIgnoreCase(word)) { > result.add(hint); > } > } > {code} > Hints are like "CATALOG.SALES.NEST", and they fail {{cname.substring(0, > word.length()).equalsIgnoreCase(word)}} check -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Issue Comment Deleted] (CALCITE-2434) SqlAdvisor.getCompletionHints does not work for nested identifiers sub-match
[ https://issues.apache.org/jira/browse/CALCITE-2434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimir Sitnikov updated CALCITE-2434: --- Comment: was deleted (was: {code:sql}select catalog.sales.em^ from catalog.sales.emp{code} simplifies to {code:sql}select catalog.sales. _sugest_ from catalog.sales.emp{code} and validator produces the following exception: {noformat}org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line 1, column 20: Table 'CATALOG.SALES' not found at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4776) at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:330) at org.apache.calcite.sql.validate.SqlValidatorImpl.findTableColumnPair(SqlValidatorImpl.java:3428) at org.apache.calcite.sql.validate.SqlValidatorImpl.isRolledUpColumn(SqlValidatorImpl.java:3461) at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUp(SqlValidatorImpl.java:3385) at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUp(SqlValidatorImpl.java:3398) at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUpInSelectList(SqlValidatorImpl.java:3324) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3312) at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:973) at org.apache.calcite.sql.advise.SqlAdvisorValidator.validateNamespace(SqlAdvisorValidator.java:185) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:949) at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:924) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:341) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:210) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:173) at org.apache.calcite.sql.test.SqlAdvisorTest.assertComplete(SqlAdvisorTest.java:499) at org.apache.calcite.sql.test.SqlAdvisorTest.testNestTable(SqlAdvisorTest.java:1462) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.apache.calcite.test.SqlValidatorTestCase$TesterConfigurationRule$1.evaluate(SqlValidatorTestCase.java:663) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at
[jira] [Commented] (CALCITE-2434) SqlAdvisor.getCompletionHints does not work for nested identifiers sub-match
[ https://issues.apache.org/jira/browse/CALCITE-2434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585200#comment-16585200 ] Vladimir Sitnikov commented on CALCITE-2434: {code:sql}select catalog.sales.em^ from catalog.sales.emp{code} simplifies to {code:sql}select catalog.sales. _sugest_ from catalog.sales.emp{code} and validator produces the following exception: {noformat}org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line 1, column 20: Table 'CATALOG.SALES' not found at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4776) at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:330) at org.apache.calcite.sql.validate.SqlValidatorImpl.findTableColumnPair(SqlValidatorImpl.java:3428) at org.apache.calcite.sql.validate.SqlValidatorImpl.isRolledUpColumn(SqlValidatorImpl.java:3461) at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUp(SqlValidatorImpl.java:3385) at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUp(SqlValidatorImpl.java:3398) at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUpInSelectList(SqlValidatorImpl.java:3324) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3312) at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:973) at org.apache.calcite.sql.advise.SqlAdvisorValidator.validateNamespace(SqlAdvisorValidator.java:185) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:949) at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:924) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:341) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:210) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:173) at org.apache.calcite.sql.test.SqlAdvisorTest.assertComplete(SqlAdvisorTest.java:499) at org.apache.calcite.sql.test.SqlAdvisorTest.testNestTable(SqlAdvisorTest.java:1462) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.apache.calcite.test.SqlValidatorTestCase$TesterConfigurationRule$1.evaluate(SqlValidatorTestCase.java:663) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at
[jira] [Commented] (CALCITE-2439) Smart complete for SqlAdvisor
[ https://issues.apache.org/jira/browse/CALCITE-2439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585193#comment-16585193 ] Julian Hyde commented on CALCITE-2439: -- I have no objection to that. I don't think that SqlMoniker is used outside of SqlAdvisor, and if it is not fit for purpose, we can extend it. > Smart complete for SqlAdvisor > - > > Key: CALCITE-2439 > URL: https://issues.apache.org/jira/browse/CALCITE-2439 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Current implementation of SqlAdvisor provides no way to perform smart > complete. > For example, > 1) A valid completion for {{select cd^ from clients}} might be {{select > client_id from clients}}. > That is completion is valid if all input characters are represented in final > word in a proper sequence. > 2) Completion might be case-insensitive if all input characters have the same > upper/lower case. > 3) "Contains" might be valid completion option as well. That is {{select id^ > from ...}} might be completed to \{{select client_id from...} as well. > Of course, exact match should be sorted the first, then partial matches and > so on. > It is not clear if smart complete logic belongs to {{SqlAdvisor}} or not. > Current client-facing API provides no way to skip default "case-sensitive > prefix filtering", so there's no way to implement smart complete at the > client side only. > It is not clear where this logic belongs: > a) Ultimate solution would be "skip filtering the identifiers at SqlAdvisor > side". Then client can filter and sort the way it wants. The downside of the > approach is it would force client to pipe large amount of items across JDBC > bridge > b) It might be helpful if Calcite had pre-defined implementations that would > filter and sort the results. The good part is it simplifies client > development, however various clients might have various filters applied. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2476) SqlAdvisor: lack of hints when sub-query has STAR (simplifySql produces 0 AS "*")
[ https://issues.apache.org/jira/browse/CALCITE-2476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585192#comment-16585192 ] Vladimir Sitnikov commented on CALCITE-2476: PR 773 comments call to purgeSelectExprsKeepAliases > SqlAdvisor: lack of hints when sub-query has STAR (simplifySql produces 0 AS > "*") > - > > Key: CALCITE-2476 > URL: https://issues.apache.org/jira/browse/CALCITE-2476 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > {{SimpleSqlParser.purgeSelectExprsKeepAliases}} tries to replace expressions > in {{select}} clause with aliases, and it often produces invalid SQL: > {{select * from dummy}} is replaced with {{select 0 AS "*" from dummy}} which > is invalid > {{select a.x+ b.y from dummy}} is replaced with {{select 0 AS "b.y" from > dummy}} and so on. > Testcase: > {code:sql}select ax^ from (select * from dummy a){code} > Actual output: > {code:sql}SELECT ax _suggest_ FROM ( SELECT 0 AS * FROM dummy a ){code} > I'm inclined to comment {{purgeSelectExprsKeepAliases}} out for now. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2479) SqlAdvisor: lack of hints for select s.count SQL
[ https://issues.apache.org/jira/browse/CALCITE-2479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585191#comment-16585191 ] Vladimir Sitnikov commented on CALCITE-2479: Note: the PR 773 adds just an ignored test case. The solution is to be investigated. > SqlAdvisor: lack of hints for select s.count SQL > > > Key: CALCITE-2479 > URL: https://issues.apache.org/jira/browse/CALCITE-2479 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Case for SqlAdvisorTest: > {code:java} @Ignore("It looks like s.count clashes with COUNT keyword, > however the same SQL executes just fine") > @Test @WithLex(Lex.JAVA) public void testAdviceExpression() { > String sql; > sql = "select s.count+s.co^ from (select 1 count from emp) s"; > assertComplete(sql, "COLUMN(count)\n", "co", > ImmutableMap.of("COLUMN(count)", "count")); > } > {code} > It is not clear why SQL fails to advise, however the same query works just > fine via JDBC. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2439) Smart complete for SqlAdvisor
[ https://issues.apache.org/jira/browse/CALCITE-2439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585188#comment-16585188 ] Vladimir Sitnikov commented on CALCITE-2439: For the record: we might want suggest things like "tableAlias + column". For instance: {{select ena^ from emp e, dept d}} might be matched by {{e.ename}}. {{SqlMoniker}} forces everything to be "dot-separated-list", and it might be not that good fit for extended cases. > Smart complete for SqlAdvisor > - > > Key: CALCITE-2439 > URL: https://issues.apache.org/jira/browse/CALCITE-2439 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Current implementation of SqlAdvisor provides no way to perform smart > complete. > For example, > 1) A valid completion for {{select cd^ from clients}} might be {{select > client_id from clients}}. > That is completion is valid if all input characters are represented in final > word in a proper sequence. > 2) Completion might be case-insensitive if all input characters have the same > upper/lower case. > 3) "Contains" might be valid completion option as well. That is {{select id^ > from ...}} might be completed to \{{select client_id from...} as well. > Of course, exact match should be sorted the first, then partial matches and > so on. > It is not clear if smart complete logic belongs to {{SqlAdvisor}} or not. > Current client-facing API provides no way to skip default "case-sensitive > prefix filtering", so there's no way to implement smart complete at the > client side only. > It is not clear where this logic belongs: > a) Ultimate solution would be "skip filtering the identifiers at SqlAdvisor > side". Then client can filter and sort the way it wants. The downside of the > approach is it would force client to pipe large amount of items across JDBC > bridge > b) It might be helpful if Calcite had pre-defined implementations that would > filter and sort the results. The good part is it simplifies client > development, however various clients might have various filters applied. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Comment Edited] (CALCITE-2439) Smart complete for SqlAdvisor
[ https://issues.apache.org/jira/browse/CALCITE-2439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585188#comment-16585188 ] Vladimir Sitnikov edited comment on CALCITE-2439 at 8/19/18 4:09 PM: - For the record: we might want suggest things like "tableAlias + column". For instance: {{select ena^ from emp e, dept d}} might be matched by {{e.ename}}. {{SqlMoniker}} forces everything to be a dot-separated-list, and it might be not that good fit for extended cases. was (Author: vladimirsitnikov): For the record: we might want suggest things like "tableAlias + column". For instance: {{select ena^ from emp e, dept d}} might be matched by {{e.ename}}. {{SqlMoniker}} forces everything to be "dot-separated-list", and it might be not that good fit for extended cases. > Smart complete for SqlAdvisor > - > > Key: CALCITE-2439 > URL: https://issues.apache.org/jira/browse/CALCITE-2439 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Julian Hyde >Priority: Major > > Current implementation of SqlAdvisor provides no way to perform smart > complete. > For example, > 1) A valid completion for {{select cd^ from clients}} might be {{select > client_id from clients}}. > That is completion is valid if all input characters are represented in final > word in a proper sequence. > 2) Completion might be case-insensitive if all input characters have the same > upper/lower case. > 3) "Contains" might be valid completion option as well. That is {{select id^ > from ...}} might be completed to \{{select client_id from...} as well. > Of course, exact match should be sorted the first, then partial matches and > so on. > It is not clear if smart complete logic belongs to {{SqlAdvisor}} or not. > Current client-facing API provides no way to skip default "case-sensitive > prefix filtering", so there's no way to implement smart complete at the > client side only. > It is not clear where this logic belongs: > a) Ultimate solution would be "skip filtering the identifiers at SqlAdvisor > side". Then client can filter and sort the way it wants. The downside of the > approach is it would force client to pipe large amount of items across JDBC > bridge > b) It might be helpful if Calcite had pre-defined implementations that would > filter and sort the results. The good part is it simplifies client > development, however various clients might have various filters applied. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2472) {fn IFNULL(value1, value2)} doesn't work when value1 and value2 are different types
[ https://issues.apache.org/jira/browse/CALCITE-2472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585183#comment-16585183 ] Julian Hyde commented on CALCITE-2472: -- It's an ODBC/JDBC standard function, so look in their standards. There's often plenty of info on the Microsoft site. > {fn IFNULL(value1, value2)} doesn't work when value1 and value2 are different > types > --- > > Key: CALCITE-2472 > URL: https://issues.apache.org/jira/browse/CALCITE-2472 > Project: Calcite > Issue Type: Bug >Reporter: Zhaotong Guo >Assignee: Julian Hyde >Priority: Major > > {quote} > {code:java} > select {fn IFNULL(value1, value2)} from table1 where id = 3{code} > {quote} > When value1 and value2 are the same types, it works. > When value1 can be cast to value2, for example, value1 is an int and value2 > is a double, both of them are not null. It will return value1 which is cast > to double. > When value1 and value2 are different types, it doesn't work. > I use Calcite 1.17.0. > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2479) SqlAdvisor: lack of hints for select s.count SQL
Vladimir Sitnikov created CALCITE-2479: -- Summary: SqlAdvisor: lack of hints for select s.count SQL Key: CALCITE-2479 URL: https://issues.apache.org/jira/browse/CALCITE-2479 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.17.0 Reporter: Vladimir Sitnikov Assignee: Julian Hyde Case for SqlAdvisorTest: {code:java} @Ignore("It looks like s.count clashes with COUNT keyword, however the same SQL executes just fine") @Test @WithLex(Lex.JAVA) public void testAdviceExpression() { String sql; sql = "select s.count+s.co^ from (select 1 count from emp) s"; assertComplete(sql, "COLUMN(count)\n", "co", ImmutableMap.of("COLUMN(count)", "count")); } {code} It is not clear why SQL fails to advise, however the same query works just fine via JDBC. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2478) SqlAdvisor: purge from_clause when _suggest_ token is located in one of the from sub-queries
Vladimir Sitnikov created CALCITE-2478: -- Summary: SqlAdvisor: purge from_clause when _suggest_ token is located in one of the from sub-queries Key: CALCITE-2478 URL: https://issues.apache.org/jira/browse/CALCITE-2478 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.17.0 Reporter: Vladimir Sitnikov Assignee: Vladimir Sitnikov Testcase: {code:sql}select axc from (select (select ^ from dummy) axc from dummy a), dummy b{code} Expected output: {code:sql}SELECT * FROM ( SELECT ( SELECT _suggest_ FROM dummy ) axc FROM dummy a ){code} Actual output: {code:sql}SELECT * FROM ( SELECT ( SELECT _suggest_ FROM dummy ) axc FROM dummy a ) , dummy b{code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2477) SqlAdvisor: scalar sub-query support
Vladimir Sitnikov created CALCITE-2477: -- Summary: SqlAdvisor: scalar sub-query support Key: CALCITE-2477 URL: https://issues.apache.org/jira/browse/CALCITE-2477 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.17.0 Reporter: Vladimir Sitnikov Assignee: Vladimir Sitnikov {code:sql}select ax^ from (select (select * from dummy) axc from dummy a){code} After simplify: {code:sql}SELECT ax _suggest_ FROM ( SELECT ( SELECT * FROM dummy ) axc FROM dummy a ) ){code} Note the extra closing brace. TL;DR: {{consumeQuery}} assumes {{axc FROM dummy...}} is a "union-kind of" continuation of a query started in {{select *...}}. The solution is keep advancing in {{consumeQuery}} only if known tokens are ahead (e.g. {{union}}, {{intersect}}, ...) -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2476) SqlAdvisor: lack of hints when sub-query has STAR (simplifySql produces 0 AS "*")
Vladimir Sitnikov created CALCITE-2476: -- Summary: SqlAdvisor: lack of hints when sub-query has STAR (simplifySql produces 0 AS "*") Key: CALCITE-2476 URL: https://issues.apache.org/jira/browse/CALCITE-2476 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.17.0 Reporter: Vladimir Sitnikov Assignee: Julian Hyde {{SimpleSqlParser.purgeSelectExprsKeepAliases}} tries to replace expressions in {{select}} clause with aliases, and it often produces invalid SQL: {{select * from dummy}} is replaced with {{select 0 AS "*" from dummy}} which is invalid {{select a.x+ b.y from dummy}} is replaced with {{select 0 AS "b.y" from dummy}} and so on. Testcase: {code:sql}select ax^ from (select * from dummy a){code} Actual output: {code:sql}SELECT ax _suggest_ FROM ( SELECT 0 AS * FROM dummy a ){code} I'm inclined to comment {{purgeSelectExprsKeepAliases}} out for now. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2475) SqlAdvisor: support MINUS
Vladimir Sitnikov created CALCITE-2475: -- Summary: SqlAdvisor: support MINUS Key: CALCITE-2475 URL: https://issues.apache.org/jira/browse/CALCITE-2475 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.17.0 Reporter: Vladimir Sitnikov Assignee: Vladimir Sitnikov -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2472) {fn IFNULL(value1, value2)} doesn't work when value1 and value2 are different types
[ https://issues.apache.org/jira/browse/CALCITE-2472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16585138#comment-16585138 ] Zhaotong Guo commented on CALCITE-2472: --- [https://calcite.apache.org/docs/reference.html#system] I saw the function here. Where can I see the spec for this function? > {fn IFNULL(value1, value2)} doesn't work when value1 and value2 are different > types > --- > > Key: CALCITE-2472 > URL: https://issues.apache.org/jira/browse/CALCITE-2472 > Project: Calcite > Issue Type: Bug >Reporter: Zhaotong Guo >Assignee: Julian Hyde >Priority: Major > > {quote} > {code:java} > select {fn IFNULL(value1, value2)} from table1 where id = 3{code} > {quote} > When value1 and value2 are the same types, it works. > When value1 can be cast to value2, for example, value1 is an int and value2 > is a double, both of them are not null. It will return value1 which is cast > to double. > When value1 and value2 are different types, it doesn't work. > I use Calcite 1.17.0. > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2474) SqlAdvisor: NPE in lookupFromHints where FROM is empty
Vladimir Sitnikov created CALCITE-2474: -- Summary: SqlAdvisor: NPE in lookupFromHints where FROM is empty Key: CALCITE-2474 URL: https://issues.apache.org/jira/browse/CALCITE-2474 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.17.0 Reporter: Vladimir Sitnikov Assignee: Vladimir Sitnikov {code:sql}select * from{code} {noformat}java.lang.NullPointerException at org.apache.calcite.sql.validate.SqlValidatorImpl.getNamespace(SqlValidatorImpl.java:1070) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupFromHints(SqlValidatorImpl.java:707) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:685) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:698) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupHints(SqlValidatorImpl.java:652) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:350) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:210) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:173) at org.apache.calcite.sql.test.SqlAdvisorTest.assertComplete(SqlAdvisorTest.java:498) at org.apache.calcite.sql.test.SqlAdvisorTest.testAdviceEmptyFrom(SqlAdvisorTest.java:1349) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.apache.calcite.test.SqlValidatorTestCase$TesterConfigurationRule$1.evaluate(SqlValidatorTestCase.java:663){noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-2474) SqlAdvisor: NPE in lookupFromHints where FROM is empty
[ https://issues.apache.org/jira/browse/CALCITE-2474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vladimir Sitnikov updated CALCITE-2474: --- Description: {code:sql}select * from^{code} {noformat}java.lang.NullPointerException at org.apache.calcite.sql.validate.SqlValidatorImpl.getNamespace(SqlValidatorImpl.java:1070) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupFromHints(SqlValidatorImpl.java:707) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:685) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:698) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupHints(SqlValidatorImpl.java:652) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:350) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:210) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:173) at org.apache.calcite.sql.test.SqlAdvisorTest.assertComplete(SqlAdvisorTest.java:498) at org.apache.calcite.sql.test.SqlAdvisorTest.testAdviceEmptyFrom(SqlAdvisorTest.java:1349) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.apache.calcite.test.SqlValidatorTestCase$TesterConfigurationRule$1.evaluate(SqlValidatorTestCase.java:663){noformat} was: {code:sql}select * from{code} {noformat}java.lang.NullPointerException at org.apache.calcite.sql.validate.SqlValidatorImpl.getNamespace(SqlValidatorImpl.java:1070) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupFromHints(SqlValidatorImpl.java:707) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:685) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:698) at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupHints(SqlValidatorImpl.java:652) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:350) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:210) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:173) at org.apache.calcite.sql.test.SqlAdvisorTest.assertComplete(SqlAdvisorTest.java:498) at org.apache.calcite.sql.test.SqlAdvisorTest.testAdviceEmptyFrom(SqlAdvisorTest.java:1349) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.apache.calcite.test.SqlValidatorTestCase$TesterConfigurationRule$1.evaluate(SqlValidatorTestCase.java:663){noformat} > SqlAdvisor: NPE in lookupFromHints where FROM is empty > -- > > Key: CALCITE-2474 > URL: https://issues.apache.org/jira/browse/CALCITE-2474 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.17.0 >Reporter: Vladimir Sitnikov >Assignee: Vladimir Sitnikov >Priority: Major > > {code:sql}select * from^{code} > {noformat}java.lang.NullPointerException > at > org.apache.calcite.sql.validate.SqlValidatorImpl.getNamespace(SqlValidatorImpl.java:1070) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.lookupFromHints(SqlValidatorImpl.java:707) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:685) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:698) >