[jira] [Created] (CALCITE-3380) implement power method in Expressions.
xzh_dz created CALCITE-3380: --- Summary: implement power method in Expressions. Key: CALCITE-3380 URL: https://issues.apache.org/jira/browse/CALCITE-3380 Project: Calcite Issue Type: Wish Reporter: xzh_dz implement power method in Expressions. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3379) Support expand atom expression in table to relational node conversion
Danny Chen created CALCITE-3379: --- Summary: Support expand atom expression in table to relational node conversion Key: CALCITE-3379 URL: https://issues.apache.org/jira/browse/CALCITE-3379 Project: Calcite Issue Type: Improvement Components: core Affects Versions: 1.21.0 Reporter: Danny Chen Assignee: Danny Chen Fix For: 1.22.0 Now there are 2 ways to convert a RelOptTable to LogicalTableScan: 1. One way is tp open the Config#sConvertTableAccess[1] flag and the SqlToRelConverter would invoke the #toRel method which transforms the table to a node returned by the user(Usually a table scan). 2. Another way it to use the LogicalTableScan rule, this rule would invoke RelOptTable#toRel and wrap the returned node with a LogicalTableScan. The different between 1 and 2 is that, 2 happens in the planning rule but 1 happens in sql-to-rel conversion, 1 also supports to expand the table columns based on the defined default values expressions, see InitializerExpressionFactory#newColumnDefaultValue. The problem with the InitializerExpressionFactory#newColumnDefaultValue is that it use InitializerContext#convertExpression to convert a SqlNode, if the SqlNode is not validated, we always got a RexCall with SqlUnresolvedFunction. We should give the user change to validate their SqlNode or even we can support pure string expressions because they can be used to persist. Another problem with #toRel is that after the expressions applied as a projection, use has no change to apply any other rel nodes if they want, we can actually support this, the same way as we support the column expressions. [1]https://github.com/apache/calcite/blob/2dc97e6723e1b5bf762540f87b5cd1a848a1/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L5605 -- This message was sent by Atlassian Jira (v8.3.4#803005)
Re: How to get columnName as `COUNT(*)` , not `EXPR$0`
Sorry, It is CALCITE-3261. Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 16:29,Juan Pan wrote: Thanks Danny, Got it. I will watch CALCITE-326. Regards, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 16:15,Danny Chan wrote: No worries, Juan Pan, welcome to contribute to Apache Calcite. Calcite always put the JIRA issues in the first place instead of GitHub page because it is really food for bug/problem tracing. If you have any questions or want to discuss something, welcome to send mail into the DEV mailing list. If it is a known bug or promotion, feel free to fire a JIRA issue and we move the discussion there. The committers would help you and what you need to do is describe your problems/cases clearly in the JIRA issue. Best, Danny Chan 在 2019年9月29日 +0800 PM3:23,Juan Pan ,写道: Actually, i think this problem should be already raised by others, for it is obvious enough. But i visited Calcite gitHub, and can not find issue list, so i sent this email. Yes, Calcite is using Jira for issues, i got. Given Calcite implements the interfaces of ResultSetMetadata, ResultSet and so on, it should return the real columnName or columnLabel from SQL, not the parsing expr(?) which is somewhat... strange to users. When i first got the result `EXPR$0`, i doubted whether my program went wrong? Recently, i am exploring Calcite, and i’d like to do some contributions to Calcite community if i can. But.. for a new one, it seems difficult. Regard, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 14:48,Danny Chan wrote: There is already a JIRA issue to trace this problem[1], maybe we can move the discussion to there. [1] https://issues.apache.org/jira/browse/CALCITE-3261 Best, Danny Chan 在 2019年9月29日 +0800 AM11:39,Juan Pan ,写道: Hi everyone, I executed SQL `select count(*) from tb1` through Calcite and resultSet.getMetaData().getColumnName(i) in my project. But the result is `EXPR$0` not `COUNT(*)`. Is there any way to get real columnName? Thanks for your attention. Regard, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere
Re: How to get columnName as `COUNT(*)` , not `EXPR$0`
Thanks Danny, Got it. I will watch CALCITE-326. Regards, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 16:15,Danny Chan wrote: No worries, Juan Pan, welcome to contribute to Apache Calcite. Calcite always put the JIRA issues in the first place instead of GitHub page because it is really food for bug/problem tracing. If you have any questions or want to discuss something, welcome to send mail into the DEV mailing list. If it is a known bug or promotion, feel free to fire a JIRA issue and we move the discussion there. The committers would help you and what you need to do is describe your problems/cases clearly in the JIRA issue. Best, Danny Chan 在 2019年9月29日 +0800 PM3:23,Juan Pan ,写道: Actually, i think this problem should be already raised by others, for it is obvious enough. But i visited Calcite gitHub, and can not find issue list, so i sent this email. Yes, Calcite is using Jira for issues, i got. Given Calcite implements the interfaces of ResultSetMetadata, ResultSet and so on, it should return the real columnName or columnLabel from SQL, not the parsing expr(?) which is somewhat... strange to users. When i first got the result `EXPR$0`, i doubted whether my program went wrong? Recently, i am exploring Calcite, and i’d like to do some contributions to Calcite community if i can. But.. for a new one, it seems difficult. Regard, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 14:48,Danny Chan wrote: There is already a JIRA issue to trace this problem[1], maybe we can move the discussion to there. [1] https://issues.apache.org/jira/browse/CALCITE-3261 Best, Danny Chan 在 2019年9月29日 +0800 AM11:39,Juan Pan ,写道: Hi everyone, I executed SQL `select count(*) from tb1` through Calcite and resultSet.getMetaData().getColumnName(i) in my project. But the result is `EXPR$0` not `COUNT(*)`. Is there any way to get real columnName? Thanks for your attention. Regard, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere
Re: How to get columnName as `COUNT(*)` , not `EXPR$0`
No worries, Juan Pan, welcome to contribute to Apache Calcite. Calcite always put the JIRA issues in the first place instead of GitHub page because it is really food for bug/problem tracing. If you have any questions or want to discuss something, welcome to send mail into the DEV mailing list. If it is a known bug or promotion, feel free to fire a JIRA issue and we move the discussion there. The committers would help you and what you need to do is describe your problems/cases clearly in the JIRA issue. Best, Danny Chan 在 2019年9月29日 +0800 PM3:23,Juan Pan ,写道: > Actually, i think this problem should be already raised by others, for it is > obvious enough. But i visited Calcite gitHub, and can not find issue list, so > i sent this email. Yes, Calcite is using Jira for issues, i got. > > > Given Calcite implements the interfaces of ResultSetMetadata, ResultSet and > so on, it should return the real columnName or columnLabel from SQL, not the > parsing expr(?) which is somewhat... strange to users. When i first got the > result `EXPR$0`, i doubted whether my program went wrong? > > > Recently, i am exploring Calcite, and i’d like to do some contributions to > Calcite community if i can. But.. for a new one, it seems difficult. > > > Regard, > Trista > > > Juan Pan > > > panj...@apache.org > Juan Pan(Trista), Apache ShardingSphere > > > On 09/29/2019 14:48,Danny Chan wrote: > There is already a JIRA issue to trace this problem[1], maybe we can move the > discussion to there. > > [1] https://issues.apache.org/jira/browse/CALCITE-3261 > > Best, > Danny Chan > 在 2019年9月29日 +0800 AM11:39,Juan Pan ,写道: > > > Hi everyone, > > > I executed SQL `select count(*) from tb1` through Calcite and > resultSet.getMetaData().getColumnName(i) in my project. But the result is > `EXPR$0` not `COUNT(*)`. > > > Is there any way to get real columnName? > > > Thanks for your attention. > > > Regard, > Trista > > > > > Juan Pan > > > panj...@apache.org > Juan Pan(Trista), Apache ShardingSphere >
[jira] [Created] (CALCITE-3378) AssertionError for checking RexNode implify
Wang Yanlin created CALCITE-3378: Summary: AssertionError for checking RexNode implify Key: CALCITE-3378 URL: https://issues.apache.org/jira/browse/CALCITE-3378 Project: Calcite Issue Type: Bug Reporter: Wang Yanlin When checking implify for RexNode with CAST, get AssertionError. The test case in *RexImplicationCheckerTest* is like this {code:java} @Test public void testRexImplifyWithCast() { final Fixture f = new Fixture(); final RexNode left = f.rexBuilder.makeCall( SqlStdOperatorTable.AND, f.rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, f.str, f.cast( f.stringDataType, f.literal(1))), f.rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, f.i, f.literal(1))); final RexNode right = f.rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, f.i, f.literal(1)); f.checkImplies(left, right); } {code} got exception as below {code:java} java.lang.AssertionError: cannot convert DECIMAL literal to class java.lang.String at org.apache.calcite.rex.RexLiteral.getValueAs(RexLiteral.java:1067) at org.apache.calcite.plan.VisitorDataContext.getValue(VisitorDataContext.java:147) at org.apache.calcite.plan.VisitorDataContext.of(VisitorDataContext.java:97) at org.apache.calcite.plan.RexImplicationChecker.implies2(RexImplicationChecker.java:236) at org.apache.calcite.plan.RexImplicationChecker.impliesConjunction(RexImplicationChecker.java:148) at org.apache.calcite.plan.RexImplicationChecker.impliesAny(RexImplicationChecker.java:138) at org.apache.calcite.plan.RexImplicationChecker.implies(RexImplicationChecker.java:124) at org.apache.calcite.test.RexImplicationCheckerTest$Fixture.checkImplies(RexImplicationCheckerTest.java:658) at org.apache.calcite.test.RexImplicationCheckerTest.testRexImplifyWithCast(RexImplicationCheckerTest.java:467) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
Re: How to get columnName as `COUNT(*)` , not `EXPR$0`
Actually, i think this problem should be already raised by others, for it is obvious enough. But i visited Calcite gitHub, and can not find issue list, so i sent this email. Yes, Calcite is using Jira for issues, i got. Given Calcite implements the interfaces of ResultSetMetadata, ResultSet and so on, it should return the real columnName or columnLabel from SQL, not the parsing expr(?) which is somewhat... strange to users. When i first got the result `EXPR$0`, i doubted whether my program went wrong? Recently, i am exploring Calcite, and i’d like to do some contributions to Calcite community if i can. But.. for a new one, it seems difficult. Regard, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 14:48,Danny Chan wrote: There is already a JIRA issue to trace this problem[1], maybe we can move the discussion to there. [1] https://issues.apache.org/jira/browse/CALCITE-3261 Best, Danny Chan 在 2019年9月29日 +0800 AM11:39,Juan Pan ,写道: Hi everyone, I executed SQL `select count(*) from tb1` through Calcite and resultSet.getMetaData().getColumnName(i) in my project. But the result is `EXPR$0` not `COUNT(*)`. Is there any way to get real columnName? Thanks for your attention. Regard, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere
Re: How to get columnName as `COUNT(*)` , not `EXPR$0`
There is already a JIRA issue to trace this problem[1], maybe we can move the discussion to there. [1] https://issues.apache.org/jira/browse/CALCITE-3261 Best, Danny Chan 在 2019年9月29日 +0800 AM11:39,Juan Pan ,写道: > > > Hi everyone, > > > I executed SQL `select count(*) from tb1` through Calcite and > resultSet.getMetaData().getColumnName(i) in my project. But the result is > `EXPR$0` not `COUNT(*)`. > > > Is there any way to get real columnName? > > > Thanks for your attention. > > > Regard, > Trista > > > > > Juan Pan > > > panj...@apache.org > Juan Pan(Trista), Apache ShardingSphere >
Re: How to get columnName as `COUNT(*)` , not `EXPR$0`
It's my pleasure, you are welcome ~ Juan Pan 于2019年9月29日周日 下午2:24写道: > Hi XING, > I appreciate your kindness. :-D Your detailed and prompt replies really > helped me a lot. > I will review the java doc you mentioned. > > > Best wishes, > Trista > > > Juan Pan > > > panj...@apache.org > Juan Pan(Trista), Apache ShardingSphere > > > On 09/29/2019 13:58,XING JIN wrote: > You can check the below doc of SqlValidatorUtil#getAlias for explanation: > > /** > * Derives an alias for a node, and invents a mangled identifier if it > * cannot. > * > * Examples: > * > * > * Alias: "1 + 2 as foo" yields "foo" > * Identifier: "foo.bar.baz" yields "baz" > * Anything else yields "expr$ordinal" > * > * > * @return An alias, if one can be derived; or a synthetic alias > * "expr$ordinal" if ordinal 0; otherwise null > */ > public static String getAlias(SqlNode node, int ordinal) > > But from my experience, you'd better not rely on above logic heavily. If > you really care about the output name, just give it an alias explicitly. > > Juan Pan 于2019年9月29日周日 下午1:27写道: > > That means Calcite can only return real columnName or columnLabel from > simple column or alias. And any aggregate function, or calculate expression > without alias, parsing expression, i.e, `EXPR$0` will be returned? > > > Juan Pan > > > panj...@apache.org > Juan Pan(Trista), Apache ShardingSphere > > > On 09/29/2019 13:16,XING JIN wrote: > If no column name given explicitly, e.g. by alias or simple identifier, > Calcite will derive one but not from the aggregate function. > > Juan Pan 于2019年9月29日周日 下午1:12写道: > > Thank for your reply. It is a indirect way to get columnName. > > > Calcite can not return the real columnName from SQL, is it right? > > > Juan Pan > > > panj...@apache.org > Juan Pan(Trista), Apache ShardingSphere > > > On 09/29/2019 12:21,XING JIN wrote: > You can try to give an alias for the selected column. > > Juan Pan 于2019年9月29日周日 上午11:39写道: > > > > Hi everyone, > > > I executed SQL `select count(*) from tb1` through Calcite and > resultSet.getMetaData().getColumnName(i) in my project. But the result is > `EXPR$0` not `COUNT(*)`. > > > Is there any way to get real columnName? > > > Thanks for your attention. > > > Regard, > Trista > > > > > Juan Pan > > > panj...@apache.org > Juan Pan(Trista), Apache ShardingSphere > > > > >
Re: How to get columnName as `COUNT(*)` , not `EXPR$0`
Hi XING, I appreciate your kindness. :-D Your detailed and prompt replies really helped me a lot. I will review the java doc you mentioned. Best wishes, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 13:58,XING JIN wrote: You can check the below doc of SqlValidatorUtil#getAlias for explanation: /** * Derives an alias for a node, and invents a mangled identifier if it * cannot. * * Examples: * * * Alias: "1 + 2 as foo" yields "foo" * Identifier: "foo.bar.baz" yields "baz" * Anything else yields "expr$ordinal" * * * @return An alias, if one can be derived; or a synthetic alias * "expr$ordinal" if ordinal 0; otherwise null */ public static String getAlias(SqlNode node, int ordinal) But from my experience, you'd better not rely on above logic heavily. If you really care about the output name, just give it an alias explicitly. Juan Pan 于2019年9月29日周日 下午1:27写道: That means Calcite can only return real columnName or columnLabel from simple column or alias. And any aggregate function, or calculate expression without alias, parsing expression, i.e, `EXPR$0` will be returned? Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 13:16,XING JIN wrote: If no column name given explicitly, e.g. by alias or simple identifier, Calcite will derive one but not from the aggregate function. Juan Pan 于2019年9月29日周日 下午1:12写道: Thank for your reply. It is a indirect way to get columnName. Calcite can not return the real columnName from SQL, is it right? Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere On 09/29/2019 12:21,XING JIN wrote: You can try to give an alias for the selected column. Juan Pan 于2019年9月29日周日 上午11:39写道: Hi everyone, I executed SQL `select count(*) from tb1` through Calcite and resultSet.getMetaData().getColumnName(i) in my project. But the result is `EXPR$0` not `COUNT(*)`. Is there any way to get real columnName? Thanks for your attention. Regard, Trista Juan Pan panj...@apache.org Juan Pan(Trista), Apache ShardingSphere