[jira] [Commented] (CALCITE-129) Support recursive WITH queries

2023-10-09 Thread Hanumath Rao Maduri (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773446#comment-17773446
 ] 

Hanumath Rao Maduri commented on CALCITE-129:
-

[Stamatis Zampetakis|http://jira/secure/ViewProfile.jspa?name=zabetak] Can I 
assign this Jira to myself, assuming no one is already looking at it. I started 
looking at this support as part of enhancing our SQL engine (which uses CALCITE 
for parsing and planning). 

The basic approach I am planning to take for this work is
 * Build upon the earlier work done as part of CALCITE-2812. I see that the 
algebraic support is already done with the aforementioned JIRA (but tagged as 
Experimental).
 * The grammar mentioned in the 
[docs|[https://calcite.apache.org/docs/algebra.html#recursive-queries]] seems 
relevant with the general syntax followed by other databases (like POSTGRES). I 
am assuming that this is the agreed syntax by the community( Please let me know 
if it's not the case). 
 * I am planning to use the RECURSIVE keyword as necessary instead of optional 
for any recursive query. My experimentation with postgres (9.6) also has a 
similar expectation.

> Support recursive WITH queries
> --
>
> Key: CALCITE-129
> URL: https://issues.apache.org/jira/browse/CALCITE-129
> Project: Calcite
>  Issue Type: Improvement
>Reporter: GitHub Import
>Priority: Major
>  Labels: github-import
>
> Building on https://github.com/julianhyde/optiq/issues/128, enable the 
> RECURSIVE keyword.
> This feature allows relations to be computed iteratively. Whereas 
> ([#128|https://github.com/JulianHyde/optiq/issues/128] | 
> [FLINK-128|https://issues.apache.org/jira/browse/OPTIQ-128]) was mainly a 
> parser/validator change, this feature requires significant changes to the 
> planner and runtime.
>  Imported from GitHub 
> Url: https://github.com/julianhyde/optiq/issues/129
> Created by: [julianhyde|https://github.com/julianhyde]
> Labels: enhancement, 
> Created at: Tue Feb 11 20:29:35 CET 2014
> State: open



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (CALCITE-6040) The operand type inference of SqlMapValueConstructor is incorrect

2023-10-09 Thread Ran Tao (Jira)


 [ 
https://issues.apache.org/jira/browse/CALCITE-6040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Tao updated CALCITE-6040:
-
Summary: The operand type inference of SqlMapValueConstructor is incorrect  
(was: The operandTypeInference of SqlMapValueConstructor is incorrect)

> The operand type inference of SqlMapValueConstructor is incorrect
> -
>
> Key: CALCITE-6040
> URL: https://issues.apache.org/jira/browse/CALCITE-6040
> Project: Calcite
>  Issue Type: Bug
>  Components: tests
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>
> we have a simple test case:
> {code:java}
> f.checkScalar("map[1, null]", "{1=null}",
> "(INTEGER NOT NULL, NULL) MAP NOT NULL"); {code}
> The result is:
> {noformat}
> java.lang.AssertionError: Query: values (map[1, null])
> Expected: is "(INTEGER NOT NULL, NULL) MAP NOT NULL"
>      but: was "(INTEGER NOT NULL, INTEGER) MAP NOT NULL"
> {noformat}
> however, the asserted actual result "(INTEGER NOT NULL, INTEGER) MAP NOT 
> NULL" for this case is wrong. If we switch to  this asserted actual result it 
> throws another exception:
> {noformat}
> java.lang.AssertionError: Query: select map[p0, null] from (values (1)) as 
> t(p0)
> Expected: is "(INTEGER NOT NULL, INTEGER) MAP NOT NULL"
>      but: was "(INTEGER NOT NULL, NULL) MAP NOT NULL"
> {noformat}
> No matter how you write this result type in this test case, it is wrong. 
> by checking the plan, it seems the deduced value type of NULL has converted 
> to INTEGER.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Resolved] (CALCITE-4850) Wrong result retrieving from ARRAY with mixed INTEGER and DECIMAL elements

2023-10-09 Thread Tanner Clary (Jira)


 [ 
https://issues.apache.org/jira/browse/CALCITE-4850?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tanner Clary resolved CALCITE-4850.
---
Fix Version/s: 1.36.0
 Assignee: Ran Tao
   Resolution: Fixed

Merged via 
[342cf60|https://github.com/apache/calcite/commit/342cf606acc954228820f69f83d43298fd874184],
 thanks for the fix, [~taoran]!

> Wrong result retrieving from ARRAY with mixed INTEGER and DECIMAL elements
> --
>
> Key: CALCITE-4850
> URL: https://issues.apache.org/jira/browse/CALCITE-4850
> Project: Calcite
>  Issue Type: Bug
>Reporter: Sergey Nuyanzin
>Assignee: Ran Tao
>Priority: Major
> Fix For: 1.36.0
>
>
> The issue is a follow-up for 
> https://issues.apache.org/jira/browse/CALCITE-4602?focusedCommentId=17427917=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17427917
> to reproduce
> {code:sql}
> select array[1.1, 1];
> +-+
> |   EXPR$0|
> +-+
> | [1.1, 0E+1] |
> +-+
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Ran Tao (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773401#comment-17773401
 ] 

Ran Tao edited comment on CALCITE-5948 at 10/9/23 4:17 PM:
---

[~tanclary] thanks Tanner for patient reviewing.
btw, I think we can safely close/resolve CALCITE-4850  either. Because that 
issue belongs to a specific case of this ticket. The test case such as 
select array[1.1, 1];
can be covered by this patch.


was (Author: lemonjing):
[~tanclary] thanks Tanner for patient reviewing.
btw, I think we can safely close/resolve CALCITE-4850  either. Because that 
issue belongs to a specific case of this ticket.

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Ran Tao (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773401#comment-17773401
 ] 

Ran Tao edited comment on CALCITE-5948 at 10/9/23 4:17 PM:
---

[~tanclary] thanks Tanner for patient reviewing.
btw, I think we can safely close/resolve CALCITE-4850  either. Because that 
issue belongs to a specific case of this ticket. The test case such as 
{code:java}
select array[1.1, 1]; {code}
can be covered by this patch.


was (Author: lemonjing):
[~tanclary] thanks Tanner for patient reviewing.
btw, I think we can safely close/resolve CALCITE-4850  either. Because that 
issue belongs to a specific case of this ticket. The test case such as 
select array[1.1, 1];
can be covered by this patch.

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Tanner Clary (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773402#comment-17773402
 ] 

Tanner Clary commented on CALCITE-5948:
---

[~taoran] Sounds good, will mark that as resolved from the same commit.

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Ran Tao (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773401#comment-17773401
 ] 

Ran Tao edited comment on CALCITE-5948 at 10/9/23 4:14 PM:
---

[~tanclary] thanks Tanner for patient reviewing.
btw, I think we can safely close/resolve CALCITE-4850  either. Because that 
issue belongs to a specific case of this ticket.


was (Author: lemonjing):
[~tanclary] thanks Tanner for patient reviewing.
btw, I think we can safely close CALCITE-4850  either. Because that issue 
belongs to a specific case of this ticket.

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Ran Tao (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773401#comment-17773401
 ] 

Ran Tao commented on CALCITE-5948:
--

[~tanclary] thanks Tanner for patient reviewing! 
btw, I think we can safely close CALCITE-4850  either. Because that issue 
belongs to a specific case of this ticket.

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Ran Tao (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773401#comment-17773401
 ] 

Ran Tao edited comment on CALCITE-5948 at 10/9/23 4:14 PM:
---

[~tanclary] thanks Tanner for patient reviewing.
btw, I think we can safely close CALCITE-4850  either. Because that issue 
belongs to a specific case of this ticket.


was (Author: lemonjing):
[~tanclary] thanks Tanner for patient reviewing~
btw, I think we can safely close CALCITE-4850  either. Because that issue 
belongs to a specific case of this ticket.

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Ran Tao (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773401#comment-17773401
 ] 

Ran Tao edited comment on CALCITE-5948 at 10/9/23 4:14 PM:
---

[~tanclary] thanks Tanner for patient reviewing~
btw, I think we can safely close CALCITE-4850  either. Because that issue 
belongs to a specific case of this ticket.


was (Author: lemonjing):
[~tanclary] thanks Tanner for patient reviewing! 
btw, I think we can safely close CALCITE-4850  either. Because that issue 
belongs to a specific case of this ticket.

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Resolved] (CALCITE-5948) Use explicit casting if element type in ARRAY/MAP does not equal derived component type

2023-10-09 Thread Tanner Clary (Jira)


 [ 
https://issues.apache.org/jira/browse/CALCITE-5948?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tanner Clary resolved CALCITE-5948.
---
Resolution: Fixed

Merged via 
[342cf60|https://github.com/apache/calcite/commit/342cf606acc954228820f69f83d43298fd874184],
 thanks for the fix, [~taoran]!

> Use explicit casting if element type in ARRAY/MAP does not equal derived 
> component type
> ---
>
> Key: CALCITE-5948
> URL: https://issues.apache.org/jira/browse/CALCITE-5948
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Ran Tao
>Assignee: Ran Tao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> First, we need to reach a consensus to allow types of the same family to 
> coexist in multiset such as array and map.
> It means the form like `{*}array(1, cast(2 as tinyint)){*}` is correct(the 
> LeastRestrictiveType is Integer). However, this function validate success in 
> calcite but it failed in runtime, exception stack is:
> {code:java}
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class 
> java.lang.Integer
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:522)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.convertValue(AbstractCursor.java:1396)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getObject(AbstractCursor.java:1377)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getArray(AbstractCursor.java:1432)
>     at 
> org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1444)
>     at 
> org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:241)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:112)
>     at org.apache.calcite.util.JdbcTypeImpl$10.get(JdbcTypeImpl.java:109)
>     at 
> org.apache.calcite.sql.test.ResultCheckers.compareResultSetWithMatcher(ResultCheckers.java:248)
>     at 
> org.apache.calcite.sql.test.ResultCheckers$MatcherResultChecker.checkResult(ResultCheckers
>  {code}
>  
> And `{*}map[1, 1, 2, cast(1 as tinyint)]{*}` is correct but calcite throw 
> exception:
> {code:java}
> java.lang.AssertionError: Expected query to throw exception, but it did not; 
> query [values (map[1, 1, 2, cast(1 as tinyint)])]; expected [Parameters must 
> be of the same type]
>   at org.apache.calcite.sql.test.SqlTests.checkEx(SqlTests.java:240)  
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.assertExceptionIsThrown(AbstractSqlTester.java:111)
> at 
> org.apache.calcite.test.SqlOperatorFixtureImpl.checkQueryFails(SqlOperatorFixtureImpl.java:174)
>  {code}
>  
> std ArrayConstructor.
> {code:java}
> public class SqlArrayValueConstructor extends SqlMultisetValueConstructor {
>   public SqlArrayValueConstructor() {
> super("ARRAY", SqlKind.ARRAY_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> RelDataType type =
> getComponentType(
> opBinding.getTypeFactory(),
> opBinding.collectOperandTypes());
> --> we need explicit cast here
> requireNonNull(type, "inferred array element type");
> return SqlTypeUtil.createArrayType(
> opBinding.getTypeFactory(), type, false);
>   }
> } {code}
> std map constructor:
> {code:java}
> public class SqlMapValueConstructor extends SqlMultisetValueConstructor {
>   public SqlMapValueConstructor() {
> super("MAP", SqlKind.MAP_VALUE_CONSTRUCTOR);
>   }
>   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
> Pair<@Nullable RelDataType, @Nullable RelDataType> type =
> getComponentTypes(
> opBinding.getTypeFactory(), opBinding.collectOperandTypes());
>      --> we need explicit cast here   
>      return SqlTypeUtil.createMapType(
> opBinding.getTypeFactory(),
> requireNonNull(type.left, "inferred key type"),
> requireNonNull(type.right, "inferred value type"),
> false);
>   }
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-6031) Add the planner rule that pushes the Filter past a Sample

2023-10-09 Thread LakeShen (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-6031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773182#comment-17773182
 ] 

LakeShen commented on CALCITE-6031:
---

Hi [~taoran] ,thanks for your reviewing.

I'm sure that there's no planner rule satisfy this case,so I added this planner 
rule for calcite.

> Add the planner rule that pushes the Filter past a Sample
> -
>
> Key: CALCITE-6031
> URL: https://issues.apache.org/jira/browse/CALCITE-6031
> Project: Calcite
>  Issue Type: New Feature
>  Components: core
>Reporter: LakeShen
>Assignee: LakeShen
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> The Filter could be pushed past the Sample.
> For example:
> {code:java}
> select deptno from "scott".dept tablesample system(50) where  deptno > 
> 10{code}
> The plan tree is :
> {code:java}
>  LogicalProject(o_orderkey=[$0])
>   LogicalFilter(condition=[>($0, 0)])
>     Sample(mode=[system], rate=[0.5], repeatableSeed=[-])
>       LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> Could be rewrite to :
> {code:java}
>   LogicalProject(o_orderkey=[$0])
>     Sample(mode=[system], rate=[0.5], repeatableSeed=[-])
>       LogicalFilter(condition=[>($0, 0)])      
> LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> The same logic could see Presto/Trino: 
> [PredicatePushDown.Rewriter#visitSample|https://github.com/prestodb/presto/blob/597272cea3eb39c35ed40ffc100f830dd4ab055c/presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/PredicatePushDown.java#L1670C9-L1674C10]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (CALCITE-6043) The hintable RelNode should display hint's infomation in explainTerms method

2023-10-09 Thread LakeShen (Jira)


 [ 
https://issues.apache.org/jira/browse/CALCITE-6043?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

LakeShen updated CALCITE-6043:
--
Description: 
Now in Calcite, almost all types of RelNode implement the Hintable interface, 
which means that this type of RelNode could do hint propagation and attach.

However, in these RelNodes which implements the Hintable interface, their 
`explainTerms` method does not display hint information.When users viewing a 
RelNode plan tree,this will cause users who use Calcite's hint don't know what 
each RelNode Hint is,such as using the `RelOptUtil.toString` method to display 
the RelNode tree.

So I propose to add hints information in the `explainTerms` method of RelNode 
that implements Hintable interface.In this way, users who use Calcite can 
easily know the information of Hint, and it is also convenient for them to 
debug Hint.

This proposal will minimize adding hint information in the `explainTerms` 
method of common RelNode.

  was:
Now in Calcite, almost all types of RelNode implement the Hintable interface, 
which means that this type of RelNode could do hint propagation and attach.

However, in these RelNodes which implements the Hintable interface, their 
`explainTerms` method does not display hint information.When users viewing a 
RelNode plan tree,this will cause users who use Calcite's hint don't know what 
each RelNode Hint is,such as using the `RelOptUtil.toString` method to display 
the RelNode tree.

So I propose to add hints information in the `explainTerms` method of RelNode 
that implements Hintable interface.In this way, users who use Calcite can 
easily know the propagation information of Hint, and it is also convenient for 
them to debug Hint.

This proposal will minimize adding hint information in the `explainTerms` 
method of common RelNode.


> The hintable RelNode should display hint's infomation in explainTerms method
> 
>
> Key: CALCITE-6043
> URL: https://issues.apache.org/jira/browse/CALCITE-6043
> Project: Calcite
>  Issue Type: New Feature
>Reporter: LakeShen
>Priority: Major
>
> Now in Calcite, almost all types of RelNode implement the Hintable interface, 
> which means that this type of RelNode could do hint propagation and attach.
> However, in these RelNodes which implements the Hintable interface, their 
> `explainTerms` method does not display hint information.When users viewing a 
> RelNode plan tree,this will cause users who use Calcite's hint don't know 
> what each RelNode Hint is,such as using the `RelOptUtil.toString` method to 
> display the RelNode tree.
> So I propose to add hints information in the `explainTerms` method of RelNode 
> that implements Hintable interface.In this way, users who use Calcite can 
> easily know the information of Hint, and it is also convenient for them to 
> debug Hint.
> This proposal will minimize adding hint information in the `explainTerms` 
> method of common RelNode.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (CALCITE-6043) The hintable RelNode should display hint's infomation in explainTerms method

2023-10-09 Thread LakeShen (Jira)


 [ 
https://issues.apache.org/jira/browse/CALCITE-6043?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

LakeShen updated CALCITE-6043:
--
Description: 
Now in Calcite, almost all types of RelNode implement the Hintable interface, 
which means that this type of RelNode could do hint propagation and attach.

However, in these RelNodes which implements the Hintable interface, their 
`explainTerms` method does not display hint information.When users viewing a 
RelNode plan tree,this will cause users who use Calcite's hint don't know what 
each RelNode Hint is,such as using the `RelOptUtil.toString` method to display 
the RelNode tree.

So I propose to add hints information in the `explainTerms` method of RelNode 
that implements Hintable interface.In this way, users who use Calcite can 
easily know the propagation information of Hint, and it is also convenient for 
them to debug Hint.

This proposal will minimize adding hint information in the `explainTerms` 
method of common RelNode.

> The hintable RelNode should display hint's infomation in explainTerms method
> 
>
> Key: CALCITE-6043
> URL: https://issues.apache.org/jira/browse/CALCITE-6043
> Project: Calcite
>  Issue Type: New Feature
>Reporter: LakeShen
>Priority: Major
>
> Now in Calcite, almost all types of RelNode implement the Hintable interface, 
> which means that this type of RelNode could do hint propagation and attach.
> However, in these RelNodes which implements the Hintable interface, their 
> `explainTerms` method does not display hint information.When users viewing a 
> RelNode plan tree,this will cause users who use Calcite's hint don't know 
> what each RelNode Hint is,such as using the `RelOptUtil.toString` method to 
> display the RelNode tree.
> So I propose to add hints information in the `explainTerms` method of RelNode 
> that implements Hintable interface.In this way, users who use Calcite can 
> easily know the propagation information of Hint, and it is also convenient 
> for them to debug Hint.
> This proposal will minimize adding hint information in the `explainTerms` 
> method of common RelNode.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (CALCITE-6043) The hintable RelNode should display hint's infomation in explainTerms method

2023-10-09 Thread LakeShen (Jira)
LakeShen created CALCITE-6043:
-

 Summary: The hintable RelNode should display hint's infomation in 
explainTerms method
 Key: CALCITE-6043
 URL: https://issues.apache.org/jira/browse/CALCITE-6043
 Project: Calcite
  Issue Type: New Feature
Reporter: LakeShen






--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Resolved] (CALCITE-6033) Broken links on adapter page

2023-10-09 Thread Ruben Q L (Jira)


 [ 
https://issues.apache.org/jira/browse/CALCITE-6033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ruben Q L resolved CALCITE-6033.

Resolution: Fixed

Fixed via 
[{{0291e1e}}|https://github.com/apache/calcite/commit/0291e1eeb4c5e01dccbac14e1a6eeeb79d87282b]

Thanks [~duanzhengqiang] for the patch! 

> Broken links on adapter page
> 
>
> Key: CALCITE-6033
> URL: https://issues.apache.org/jira/browse/CALCITE-6033
> Project: Calcite
>  Issue Type: Bug
>  Components: site
>Affects Versions: 1.35.0
>Reporter: Zhengqiang Duan
>Assignee: Zhengqiang Duan
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> Hi, Calcite community, I found the following dead link in the adapter 
> document:
>  * 
> [https://calcite.apache.org/avatica/apidocs/org/apache/calcite/avatica/ConnectStringParser.html]
>  * 
> [https://calcite.apache.org/javadocAggregate/org/apache/calcite/sql/fun/SqlGroupedWindowFunction.html]
>  * [https://pig.apache.org/docs/r0.7.0/piglatin_ref1.html]
>  * 
> [https://calcite.apache.org/javadocAggregate/org/apache/calcite/rel/cassandra/CassandraProject.html]
>  * 
> https://calcite.apache.org/javadocAggregate/org/apache/calcite/rel/metadata/RelMetadataQuery.html{_}#getSelectivity-org.apache.calcite.rel.RelNode-org.apache.calcite.rex.RexNode-{_}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (CALCITE-6031) Add the planner rule that pushes the Filter past a Sample

2023-10-09 Thread Ran Tao (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-6031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17773135#comment-17773135
 ] 

Ran Tao edited comment on CALCITE-6031 at 10/9/23 6:40 AM:
---

Can you confirm that the existing filter push-down rule can satisfy this case? 
I'm asking this because it seems a simple ability, maybe calcite already has 
this. 

However, the PR looks good to me. good work.


was (Author: lemonjing):
Can you confirm that the existing filter push-down rule can satisfy this case? 
I'm asking this because it seems a simple ability, maybe calcite already has 
this.

> Add the planner rule that pushes the Filter past a Sample
> -
>
> Key: CALCITE-6031
> URL: https://issues.apache.org/jira/browse/CALCITE-6031
> Project: Calcite
>  Issue Type: New Feature
>  Components: core
>Reporter: LakeShen
>Assignee: LakeShen
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> The Filter could be pushed past the Sample.
> For example:
> {code:java}
> select deptno from "scott".dept tablesample system(50) where  deptno > 
> 10{code}
> The plan tree is :
> {code:java}
>  LogicalProject(o_orderkey=[$0])
>   LogicalFilter(condition=[>($0, 0)])
>     Sample(mode=[system], rate=[0.5], repeatableSeed=[-])
>       LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> Could be rewrite to :
> {code:java}
>   LogicalProject(o_orderkey=[$0])
>     Sample(mode=[system], rate=[0.5], repeatableSeed=[-])
>       LogicalFilter(condition=[>($0, 0)])      
> LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> The same logic could see Presto/Trino: 
> [PredicatePushDown.Rewriter#visitSample|https://github.com/prestodb/presto/blob/597272cea3eb39c35ed40ffc100f830dd4ab055c/presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/PredicatePushDown.java#L1670C9-L1674C10]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)