[GitHub] [calcite] sonarcloud[bot] commented on pull request #3352: [CALCITE-5184] Core parser allow "LIMIT start, ALL"

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3352:
URL: https://github.com/apache/calcite/pull/3352#issuecomment-1668870237

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3352)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3352=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3352=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3352=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=CODE_SMELL)
 [2 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=CODE_SMELL)
   
   
[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png
 
'100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3355: [CALCITE-5893] Wrong NULL operand behavior of ARRAY_CONTAINS/ARRAY_EXCEPT/ARRAY_INTERSECT In Spark Library

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3355:
URL: https://github.com/apache/calcite/pull/3355#issuecomment-1668840919

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3355)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3355=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3355=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3355=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=CODE_SMELL)
 [2 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=CODE_SMELL)
   
   
[![91.7%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'91.7%')](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_coverage=list)
 [91.7% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3355: [CALCITE-5893] Wrong NULL operand behavior of ARRAY_CONTAINS/ARRAY_EXCEPT/ARRAY_INTERSECT In Spark Library

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3355:
URL: https://github.com/apache/calcite/pull/3355#issuecomment-1668839970

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3355)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3355=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3355=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3355=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=CODE_SMELL)
 [2 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3355=false=CODE_SMELL)
   
   
[![91.7%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'91.7%')](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_coverage=list)
 [91.7% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3355=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] chucheng92 opened a new pull request, #3355: [CALCITE-5893] Wrong NULL literal behavior of ARRAY_CONTAINS/ARRAY_EXCEPT/ARRAY_INTERSECT In Spark Library

2023-08-07 Thread via GitHub


chucheng92 opened a new pull request, #3355:
URL: https://github.com/apache/calcite/pull/3355

   https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-5893


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3314: [CALCITE-5843] Constant expression with nested casts causes a compiler crash

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3314:
URL: https://github.com/apache/calcite/pull/3314#issuecomment-1668680321

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3314)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3314=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3314=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3314=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=CODE_SMELL)
   
   
[![87.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'87.1%')](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_coverage=list)
 [87.1% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] walterddr commented on pull request #3288: [CALCITE-5740] support aggregate semi-join rule

2023-08-07 Thread via GitHub


walterddr commented on PR #3288:
URL: https://github.com/apache/calcite/pull/3288#issuecomment-1668663566

   @chunweilei could you share any additional follow up comments or if this is 
ready for merge? thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3314: [CALCITE-5843] Constant expression with nested casts causes a compiler crash

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3314:
URL: https://github.com/apache/calcite/pull/3314#issuecomment-1668643924

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3314)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3314=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3314=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3314=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3314=false=CODE_SMELL)
   
   
[![87.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'87.1%')](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_coverage=list)
 [87.1% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3314=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] mihaibudiu commented on pull request #3314: [CALCITE-5843] Constant expression with nested casts causes a compiler crash

2023-08-07 Thread via GitHub


mihaibudiu commented on PR #3314:
URL: https://github.com/apache/calcite/pull/3314#issuecomment-1668635096

   @rubenada hopefully I have addressed your comments. The commits are already 
squashed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3303:
URL: https://github.com/apache/calcite/pull/3303#issuecomment-1668223737

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3303)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3303=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3303=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3303=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=CODE_SMELL)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3303=false=CODE_SMELL)
   
   
[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png
 
'100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3303=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3303=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3303=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3303=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-08-07 Thread via GitHub


tanclary commented on PR #3303:
URL: https://github.com/apache/calcite/pull/3303#issuecomment-1668224893

   @herunkang2018 Could you elaborate on your comment about the decimal 
testing? is that blocking this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on pull request #3336: [CALCITE-5869] LEAST_RESTRICTIVE does not use inner type of MEASURE f…

2023-08-07 Thread via GitHub


tanclary commented on PR #3336:
URL: https://github.com/apache/calcite/pull/3336#issuecomment-1668222785

   @tjbanghart @julianhyde Do either of you have additional comments? Thanks 
for your suggestions so far!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3336: [CALCITE-5869] LEAST_RESTRICTIVE does not use inner type of MEASURE f…

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3336:
URL: https://github.com/apache/calcite/pull/3336#issuecomment-1668192965

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3336)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3336=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3336=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3336=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3336=false=CODE_SMELL)
   
   
[![92.3%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'92.3%')](https://sonarcloud.io/component_measures?id=apache_calcite=3336=new_coverage=list)
 [92.3% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3336=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3336=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3336=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3147: [CALCITE-5644] Add CONTAINS_SUBSTR function (enabled in BigQuery library)

2023-08-07 Thread via GitHub


tanclary commented on code in PR #3147:
URL: https://github.com/apache/calcite/pull/3147#discussion_r1286109761


##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -562,6 +564,91 @@ public static List split(ByteString s, 
ByteString delimiter) {
 }
   }
 
+  public static @Nullable Boolean containsSubstr(@Nullable Object @Nullable [] 
s0, String s1) {
+// If s0 has null arguments, it should return TRUE if substring is found, 
otherwise NULL
+boolean nullFlag = false;
+if (s0 == null) {
+  return false;
+}
+for (Object obj : s0) {
+  if (obj == null) {
+nullFlag = true;
+  } else if (obj instanceof Object[]) {
+return containsSubstr((Object[]) obj, s1);
+  } else if (obj instanceof ArrayList) {
+return containsSubstr((List) obj, s1);
+  } else if (normalize(obj.toString()).contains(normalize(s1))) {
+return true;
+  }
+}
+return nullFlag ? null : false;
+  }
+
+  public static @Nullable Boolean containsSubstr(List s0, String s1) {
+// If s0 has null arguments, it should return TRUE if substring is found, 
otherwise NULL
+boolean nullFlag = false;
+for (Object item : s0) {
+  if (item == null) {
+nullFlag = true;
+  }
+  if (item != null && containsSubstr(item, s1)) {
+return true;
+  }
+}
+return nullFlag ? null : false;
+  }
+
+  public static @Nullable Boolean containsSubstr(String s0, String s1, String 
s2) {
+// The third argument specifies the json_scope, either keys, values, or 
both
+LinkedHashMap map = (LinkedHashMap) 
JsonFunctions.dejsonize(s0);
+Set keys = map.keySet();
+Collection values = map.values();
+if (s2.equals("JSON_KEYS")) {

Review Comment:
   Done



##
core/src/main/java/org/apache/calcite/sql/SqlKind.java:
##
@@ -839,6 +839,8 @@ public enum SqlKind {
* TABLE(udx(CURSOR(SELECT ...), x, y, z)). */
   CURSOR,
 
+  CONTAINS_SUBSTR,

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3147: [CALCITE-5644] Add CONTAINS_SUBSTR function (enabled in BigQuery library)

2023-08-07 Thread via GitHub


tanclary commented on code in PR #3147:
URL: https://github.com/apache/calcite/pull/3147#discussion_r1286109962


##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -562,6 +564,91 @@ public static List split(ByteString s, 
ByteString delimiter) {
 }
   }
 
+  public static @Nullable Boolean containsSubstr(@Nullable Object @Nullable [] 
s0, String s1) {
+// If s0 has null arguments, it should return TRUE if substring is found, 
otherwise NULL
+boolean nullFlag = false;
+if (s0 == null) {
+  return false;
+}
+for (Object obj : s0) {
+  if (obj == null) {
+nullFlag = true;
+  } else if (obj instanceof Object[]) {
+return containsSubstr((Object[]) obj, s1);
+  } else if (obj instanceof ArrayList) {
+return containsSubstr((List) obj, s1);
+  } else if (normalize(obj.toString()).contains(normalize(s1))) {
+return true;
+  }
+}
+return nullFlag ? null : false;
+  }
+
+  public static @Nullable Boolean containsSubstr(List s0, String s1) {
+// If s0 has null arguments, it should return TRUE if substring is found, 
otherwise NULL
+boolean nullFlag = false;
+for (Object item : s0) {
+  if (item == null) {
+nullFlag = true;
+  }
+  if (item != null && containsSubstr(item, s1)) {
+return true;
+  }
+}
+return nullFlag ? null : false;
+  }
+
+  public static @Nullable Boolean containsSubstr(String s0, String s1, String 
s2) {
+// The third argument specifies the json_scope, either keys, values, or 
both

Review Comment:
   Done



##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -562,6 +564,91 @@ public static List split(ByteString s, 
ByteString delimiter) {
 }
   }
 
+  public static @Nullable Boolean containsSubstr(@Nullable Object @Nullable [] 
s0, String s1) {
+// If s0 has null arguments, it should return TRUE if substring is found, 
otherwise NULL
+boolean nullFlag = false;
+if (s0 == null) {
+  return false;
+}
+for (Object obj : s0) {
+  if (obj == null) {
+nullFlag = true;
+  } else if (obj instanceof Object[]) {
+return containsSubstr((Object[]) obj, s1);
+  } else if (obj instanceof ArrayList) {
+return containsSubstr((List) obj, s1);
+  } else if (normalize(obj.toString()).contains(normalize(s1))) {
+return true;
+  }
+}
+return nullFlag ? null : false;
+  }
+
+  public static @Nullable Boolean containsSubstr(List s0, String s1) {
+// If s0 has null arguments, it should return TRUE if substring is found, 
otherwise NULL
+boolean nullFlag = false;
+for (Object item : s0) {
+  if (item == null) {
+nullFlag = true;
+  }
+  if (item != null && containsSubstr(item, s1)) {
+return true;
+  }
+}
+return nullFlag ? null : false;
+  }
+
+  public static @Nullable Boolean containsSubstr(String s0, String s1, String 
s2) {
+// The third argument specifies the json_scope, either keys, values, or 
both
+LinkedHashMap map = (LinkedHashMap) 
JsonFunctions.dejsonize(s0);
+Set keys = map.keySet();
+Collection values = map.values();
+if (s2.equals("JSON_KEYS")) {
+  return keys.contains(s1);
+} else if (s2.equals("JSON_VALUES")) {
+  return values.contains(s1);
+} else if (s2.equals("JSON_KEYS_AND_VALUES")) {
+  return keys.contains(s1) || values.contains(s1);
+} else {
+  throw new IllegalArgumentException("json_scope argument must be one of: 
\"JSON_KEYS\", "
+  + "\"JSON_VALUES\", \"JSON_KEYS_AND_VALUES\".");
+}
+  }
+
+  /** SQL {@code CONTAINS_SUBSTR(string, string)} function. */

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-08-07 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1286101447


##
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##
@@ -6618,6 +6618,64 @@ private static void checkIf(SqlOperatorFixture f) {
 f.checkNull("pow(cast(null as integer), 2)");
   }
 
+  @Test void testInfinity() {
+final SqlOperatorFixture f = fixture();
+f.checkScalar("cast('Infinity' as double)", "Infinity",
+"DOUBLE NOT NULL");
+f.checkScalar("cast('-Infinity' as double)", "-Infinity",
+"DOUBLE NOT NULL");
+f.checkScalar("cast('Infinity' as real)", "Infinity",
+"REAL NOT NULL");
+f.checkScalar("cast('-Infinity' as real)", "-Infinity",
+"REAL NOT NULL");
+  }
+
+  @Test void testNaN() {
+final SqlOperatorFixture f = fixture();
+f.checkScalar("cast('NaN' as double)", "NaN",
+"DOUBLE NOT NULL");
+f.checkScalar("cast('NaN' as real)", "NaN",
+"REAL NOT NULL");
+  }
+
+  @Test void testIsInfFunc() {
+final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.IS_INF);
+f0.checkFails("^is_inf(3)^",
+"No match found for function signature IS_INF\\(\\)",
+false);
+final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+f.checkBoolean("is_inf(3)", false);
+f.checkBoolean("is_inf(1.2345)", false);
+f.checkBoolean("is_inf(cast('NaN' as double))", false);
+f.checkBoolean("is_inf(cast('NaN' as real))", false);
+f.checkBoolean("is_inf(cast('Infinity' as double))", true);
+f.checkBoolean("is_inf(cast('Infinity' as float))", true);
+f.checkBoolean("is_inf(cast('Infinity' as real))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as double))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as float))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as real))", true);
+f.checkNull("is_inf(cast(null as double))");
+  }
+
+  @Test void testIsNaNFunc() {
+final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.IS_NAN);
+f0.checkFails("^is_nan(3)^",
+"No match found for function signature IS_NAN\\(\\)",
+false);
+final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+f.checkBoolean("is_nan(3)", false);
+f.checkBoolean("is_nan(1.2345)", false);
+f.checkBoolean("is_nan(cast('Infinity' as double))", false);
+f.checkBoolean("is_nan(cast('Infinity' as float))", false);
+f.checkBoolean("is_nan(cast('Infinity' as real))", false);
+f.checkBoolean("is_nan(cast('-Infinity' as double))", false);
+f.checkBoolean("is_inf(cast('-Infinity' as float))", false);

Review Comment:
   Yes thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] rubenada commented on a diff in pull request #3314: [CALCITE-5843] Prevent crash during evaluation of constant expressions in linq4j

2023-08-07 Thread via GitHub


rubenada commented on code in PR #3314:
URL: https://github.com/apache/calcite/pull/3314#discussion_r1286101426


##
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##
@@ -687,6 +687,17 @@ void testCastToExactNumeric(CastType castType, 
SqlOperatorFixture f) {
 "654342432412312");
   }
 
+  /**
+   * Test case for https://issues.apache.org/jira/browse/CALCITE-5843;>
+   * Legal constant SQL expression with cast causes a parse error. */

Review Comment:
   Please align the javadoc with the new Jira/commit title



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] rubenada commented on a diff in pull request #3314: [CALCITE-5843] Prevent crash during evaluation of constant expressions in linq4j

2023-08-07 Thread via GitHub


rubenada commented on code in PR #3314:
URL: https://github.com/apache/calcite/pull/3314#discussion_r1286100494


##
linq4j/src/main/java/org/apache/calcite/linq4j/tree/Expressions.java:
##
@@ -570,7 +570,37 @@ public static ConstantExpression constant(@Nullable Object 
value, Type type) {
   value = new BigInteger(stringValue);
 }
 if (primitive != null) {
-  value = primitive.parse(stringValue);
+  if (value instanceof Number) {

Review Comment:
   Would it make sense to put this logic inside `Primitive` class, in a new 
method (something similar to the existing `Primitive#parse`) e.g.:
   ```
   public enum Primitive {
   ...
 public Object numberValue(Number number) {
   switch (this) {
   case BYTE:
 return number.byteValue();
   case CHAR:
 return (char) number.intValue();
   case DOUBLE:
 return number.doubleValue();
   case FLOAT:
 return number.floatValue();
   case INT:
 return number.intValue();
   case LONG:
 return number.longValue();
   case SHORT:
 return number.shortValue();
   default:
 throw new AssertionError(number);
   }
 }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] rubenada commented on a diff in pull request #3314: [CALCITE-5843] Prevent crash during evaluation of constant expressions in linq4j

2023-08-07 Thread via GitHub


rubenada commented on code in PR #3314:
URL: https://github.com/apache/calcite/pull/3314#discussion_r1286096496


##
linq4j/src/main/java/org/apache/calcite/linq4j/tree/Expressions.java:
##
@@ -570,7 +570,37 @@ public static ConstantExpression constant(@Nullable Object 
value, Type type) {
   value = new BigInteger(stringValue);
 }
 if (primitive != null) {
-  value = primitive.parse(stringValue);
+  if (value instanceof Number) {
+Number valueNumber = (Number) value;
+switch (primitive) {
+case BYTE:
+  value = valueNumber.byteValue();
+  break;
+case CHAR:
+  value = (char) valueNumber.intValue();
+  break;
+case SHORT:
+  value = (short) valueNumber.intValue();

Review Comment:
   Why not using directly `valueNumber.shortValue()`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3354: [CALCITE-5904] The result should be empty list when table sample rate is 0

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3354:
URL: https://github.com/apache/calcite/pull/3354#issuecomment-1668138384

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3354)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3354=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3354=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3354=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3354=false=CODE_SMELL)
   
   
[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png
 
'100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3354=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3354=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3354=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3354=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen opened a new pull request, #3354: [CALCITE-5904] The result should be empty list when table sample rate is 0

2023-08-07 Thread via GitHub


LakeShen opened a new pull request, #3354:
URL: https://github.com/apache/calcite/pull/3354

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on PR #3345:
URL: https://github.com/apache/calcite/pull/3345#issuecomment-1668059287

   Another point,Do you need add a class GeneratedMetadata_ForeignXXX like 
GeneratedMetadata_CollationHandler.java?
   
![image](https://github.com/apache/calcite/assets/8057451/311c50ef-75f1-48f6-8108-73ab39ec875a)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on pull request #3353: [CALCITE-5903] RelMdCollation does not define collations for EnumerableLimit

2023-08-07 Thread via GitHub


LakeShen commented on PR #3353:
URL: https://github.com/apache/calcite/pull/3353#issuecomment-1668053040

   The PR looks good.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3353: [CALCITE-5903] RelMdCollation does not define collations for EnumerableLimit

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3353:
URL: https://github.com/apache/calcite/pull/3353#issuecomment-1667988795

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3353)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3353=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3353=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3353=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3353=false=CODE_SMELL)
   
   
[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png
 
'100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3353=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3353=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3353=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3353=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] rubenada opened a new pull request, #3353: [CALCITE-5903] RelMdCollation does not define collations for EnumerableLimit

2023-08-07 Thread via GitHub


rubenada opened a new pull request, #3353:
URL: https://github.com/apache/calcite/pull/3353

   Jira: CALCITE-5903


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3352: [CALCITE-5184] Core parser allow "LIMIT start, ALL"

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3352:
URL: https://github.com/apache/calcite/pull/3352#issuecomment-1667926843

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3352)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3352=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3352=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3352=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3352=false=CODE_SMELL)
   
   
[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png
 
'100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3352=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] macroguo-ghy opened a new pull request, #3352: [CALCITE-5184] Core parser allow "LIMIT start, ALL"

2023-08-07 Thread via GitHub


macroguo-ghy opened a new pull request, #3352:
URL: https://github.com/apache/calcite/pull/3352

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285783800


##
core/src/test/java/org/apache/calcite/test/RelMetadataTest.java:
##
@@ -971,6 +989,1025 @@ final RelMetadataFixture sql(String sql) {
 is(1D));
   }
 
+  // --
+  // Tests for getForeignKeys
+  // --
+
+  @Test void testForeignKeysAggregateEmpty() {
+sql("select hiredate, sum(sal), count(deptno) from emp group by hiredate")
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
false)
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
true);
+  }
+
+  @Test void testForeignKeysIgnoreNullsAggregateEmpty() {
+sql("select hiredate, sum(sal), count(deptno) from empnullables group by 
hiredate")
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
false)
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
true);
+  }
+
+  @Test void testForeignKeysAggregateKey() {
+Set foreignKeys =
+Sets.newHashSet(
+RelOptForeignKey.of(
+Lists.newArrayList(
+Pair.of(
+InferredConstraintKey.of(EMP_QNAME, 7, false),
+InferredConstraintKey.of(DEPT_QNAME, 0, false))),
+bitSetOf(1), ImmutableBitSet.of()));
+sql("select count(sal), deptno, count(deptno) from emp group by deptno")
+.assertForeignKeys(equalTo(foreignKeys), 
equalTo(EMPTY_FOREIGN_KEY_SET), false)
+.assertForeignKeys(equalTo(foreignKeys), 
equalTo(EMPTY_FOREIGN_KEY_SET), true);
+  }
+
+  @Test void testForeignKeysIgnoreNullsAggregateKey() {
+Set foreignKeys =
+Sets.newHashSet(
+RelOptForeignKey.of(
+Lists.newArrayList(
+Pair.of(
+InferredConstraintKey.of(EMPNULLABLES_QNAME, 7, false),
+InferredConstraintKey.of(DEPT_QNAME, 0, false))),
+bitSetOf(1), ImmutableBitSet.of()));
+sql("select count(sal), deptno, count(deptno) from empnullables group by 
deptno")
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
false)
+.assertForeignKeys(
+equalTo(foreignKeys), equalTo(EMPTY_FOREIGN_KEY_SET), true);
+  }
+
+  @Test void testForeignKeysTableOnly() {
+Set foreignKeys =
+Sets.newHashSet(
+RelOptForeignKey.of(
+Lists.newArrayList(
+Pair.of(
+InferredConstraintKey.of(),
+InferredConstraintKey.of(EMP_QNAME, 0, false))),
+ImmutableBitSet.of(), bitSetOf(0)),
+RelOptForeignKey.of(
+Lists.newArrayList(
+Pair.of(
+InferredConstraintKey.of(EMP_QNAME, 7, false),
+InferredConstraintKey.of(DEPT_QNAME, 0, false))),
+bitSetOf(1), ImmutableBitSet.of()),
+RelOptForeignKey.of(
+Lists.newArrayList(
+Pair.of(
+InferredConstraintKey.of(EMP_QNAME, 7, false),
+InferredConstraintKey.of(DEPT_QNAME, 0, false))),
+bitSetOf(3), ImmutableBitSet.of()));
+sql("select empno, deptno, ename, deptno from emp")
+.assertForeignKeys(equalTo(foreignKeys), 
equalTo(EMPTY_FOREIGN_KEY_SET), false)
+.assertForeignKeys(equalTo(foreignKeys), 
equalTo(EMPTY_FOREIGN_KEY_SET), true);
+  }
+
+  @Test void testForeignKeysIgnoreNullsTableOnly() {
+Set foreignKeys =
+Sets.newHashSet(
+RelOptForeignKey.of(
+Lists.newArrayList(
+Pair.of(
+InferredConstraintKey.of(EMPNULLABLES_QNAME, 7, false),
+InferredConstraintKey.of(DEPT_QNAME, 0, false))),
+bitSetOf(0), ImmutableBitSet.of()));
+sql("select deptno, ename from empnullables")
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
false)
+.assertForeignKeys(equalTo(foreignKeys), 
equalTo(EMPTY_FOREIGN_KEY_SET), true);
+  }
+
+  @Test void testForeignKeysTableOnlyEmpty() {
+sql("select ename, job from emp")
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
false)
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
true);
+  }
+
+  @Test void testForeignKeysIgnoreNullsTableOnlyEmpty() {
+sql("select ename, job from empnullables")
+.assertForeignKeys(
+equalTo(EMPTY_FOREIGN_KEY_SET), equalTo(EMPTY_FOREIGN_KEY_SET), 
false)
+.assertForeignKeys(
+

[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285777370


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * ForeignKey represents the foreign and unique key constraint relationship
+ * on the current {@link org.apache.calcite.rel.RelNode}.
+ *
+ * constraints field {@link #constraints} are
+ * constraints that foreign key and unique key relationships in bottom-up 
derivation.
+ *
+ * foreignColumns field {@link #foreignColumns} indicates the
+ * position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}
+ * if not or not be confirmed, it is an empty set.
+ *
+ * uniqueColumns field {@link #uniqueColumns} indicates the position 
of
+ * the unique key on the current {@link org.apache.calcite.rel.RelNode},
+ * if not or not be confirmed, it is an empty set, the position in 
uniqueColumns
+ * corresponds to foreignColumns.
+ *
+ * The element positions in {@code uniqueColumns} and {@code foreignColumns}
+ * correspond to each other. The order of elements in {@code uniqueColumns}
+ * and {@code foreignColumns} is consistent with the order of constraints in
+ * the constraints list.
+ *
+ * For instance,
+ * 
+ * select e.deptno, e.ename, d.deptno
+ * from emp as e
+ * inner join dept as d
+ * on e.deptno = d.deptno
+ *
+ * the foreign key is the DEPTNO column of CATALOG.SALES.EMP table,
+ * reference the DEPTNO unique column of CATALOG.SALES.DEPT table.
+ *
+ * Invoke the {@link RelMetadataQuery#getConfirmedForeignKeys} method which
+ * input param is the top {@link org.apache.calcite.rel.core.Project},
+ * the following results can be obtained.
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#true, right: [CATALOG, SALES, 
DEPT].$0.#true}]
+ * {@code foreignColumns} is {0}
+ * {@code uniqueColumns} is {2}
+ *
+ * For instance,
+ * 
+ * select name, deptno
+ * from dept
+ *
+ * {@code constraints} is
+ * [{left: null.null.#false, right: [CATALOG, SALES, DEPT].$0.#false}]
+ * {@code foreignColumns} is {}
+ * {@code uniqueColumns} is {1}
+ *
+ * For instance,
+ * 
+ * select ename, sal, deptno
+ * from emp
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#false, right: [CATALOG, SALES, 
DEPT].$0.#false}]
+ * {@code foreignColumns} is {2}
+ * {@code uniqueColumns} is {}
+ *
+ * @see InferredConstraintKey
+ * @see org.apache.calcite.plan.RelOptForeignKey
+ */
+public class RelOptForeignKey {
+
+  /** Foreign key and unique key relationships in bottom-up derivation. */
+  private final List> 
constraints;
+  /** Position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet foreignColumns;
+  /** Position of the unique key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet uniqueColumns;
+
+  private RelOptForeignKey(
+  List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+this.constraints = constraints;
+this.foreignColumns = foreignColumns;
+this.uniqueColumns = uniqueColumns;
+  }
+
+  public static RelOptForeignKey of(List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+return new RelOptForeignKey(constraints, foreignColumns, uniqueColumns);
+  }
+
+  public ImmutableBitSet getForeignColumns() {
+return foreignColumns;
+  }
+
+  public ImmutableBitSet 

[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285776926


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * ForeignKey represents the foreign and unique key constraint relationship
+ * on the current {@link org.apache.calcite.rel.RelNode}.
+ *
+ * constraints field {@link #constraints} are
+ * constraints that foreign key and unique key relationships in bottom-up 
derivation.
+ *
+ * foreignColumns field {@link #foreignColumns} indicates the
+ * position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}
+ * if not or not be confirmed, it is an empty set.
+ *
+ * uniqueColumns field {@link #uniqueColumns} indicates the position 
of
+ * the unique key on the current {@link org.apache.calcite.rel.RelNode},
+ * if not or not be confirmed, it is an empty set, the position in 
uniqueColumns
+ * corresponds to foreignColumns.
+ *
+ * The element positions in {@code uniqueColumns} and {@code foreignColumns}
+ * correspond to each other. The order of elements in {@code uniqueColumns}
+ * and {@code foreignColumns} is consistent with the order of constraints in
+ * the constraints list.
+ *
+ * For instance,
+ * 
+ * select e.deptno, e.ename, d.deptno
+ * from emp as e
+ * inner join dept as d
+ * on e.deptno = d.deptno
+ *
+ * the foreign key is the DEPTNO column of CATALOG.SALES.EMP table,
+ * reference the DEPTNO unique column of CATALOG.SALES.DEPT table.
+ *
+ * Invoke the {@link RelMetadataQuery#getConfirmedForeignKeys} method which
+ * input param is the top {@link org.apache.calcite.rel.core.Project},
+ * the following results can be obtained.
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#true, right: [CATALOG, SALES, 
DEPT].$0.#true}]
+ * {@code foreignColumns} is {0}
+ * {@code uniqueColumns} is {2}
+ *
+ * For instance,
+ * 
+ * select name, deptno
+ * from dept
+ *
+ * {@code constraints} is
+ * [{left: null.null.#false, right: [CATALOG, SALES, DEPT].$0.#false}]
+ * {@code foreignColumns} is {}
+ * {@code uniqueColumns} is {1}
+ *
+ * For instance,
+ * 
+ * select ename, sal, deptno
+ * from emp
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#false, right: [CATALOG, SALES, 
DEPT].$0.#false}]
+ * {@code foreignColumns} is {2}
+ * {@code uniqueColumns} is {}
+ *
+ * @see InferredConstraintKey
+ * @see org.apache.calcite.plan.RelOptForeignKey
+ */
+public class RelOptForeignKey {
+
+  /** Foreign key and unique key relationships in bottom-up derivation. */
+  private final List> 
constraints;
+  /** Position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet foreignColumns;
+  /** Position of the unique key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet uniqueColumns;
+
+  private RelOptForeignKey(
+  List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+this.constraints = constraints;
+this.foreignColumns = foreignColumns;
+this.uniqueColumns = uniqueColumns;
+  }
+
+  public static RelOptForeignKey of(List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+return new RelOptForeignKey(constraints, foreignColumns, uniqueColumns);
+  }
+
+  public ImmutableBitSet getForeignColumns() {
+return foreignColumns;
+  }
+
+  public ImmutableBitSet 

[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285772183


##
testkit/src/main/java/org/apache/calcite/test/RelMetadataFixture.java:
##
@@ -264,6 +265,18 @@ public RelMetadataFixture 
assertPercentageOriginalRows(Matcher matcher)
 return this;
   }
 
+  public RelMetadataFixture assertForeignKeys(Matcher> 
matcher,
+  Matcher> confirmedMatcher,
+  boolean ignoreNulls) {
+RelNode rel = toRel();
+RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
+Set foreignKeys = mq.getForeignKeys(rel, ignoreNulls);

Review Comment:
   You could write more test cases, just like you have getForeignKeys method in 
RelMdForeignKeys for different relNodes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285772183


##
testkit/src/main/java/org/apache/calcite/test/RelMetadataFixture.java:
##
@@ -264,6 +265,18 @@ public RelMetadataFixture 
assertPercentageOriginalRows(Matcher matcher)
 return this;
   }
 
+  public RelMetadataFixture assertForeignKeys(Matcher> 
matcher,
+  Matcher> confirmedMatcher,
+  boolean ignoreNulls) {
+RelNode rel = toRel();
+RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
+Set foreignKeys = mq.getForeignKeys(rel, ignoreNulls);

Review Comment:
   You could write more test cases, just like you have getForeignKeys method in 
RelMdForeignKeys for different relNodes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285767798


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * ForeignKey represents the foreign and unique key constraint relationship
+ * on the current {@link org.apache.calcite.rel.RelNode}.
+ *
+ * constraints field {@link #constraints} are
+ * constraints that foreign key and unique key relationships in bottom-up 
derivation.
+ *
+ * foreignColumns field {@link #foreignColumns} indicates the
+ * position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}
+ * if not or not be confirmed, it is an empty set.
+ *
+ * uniqueColumns field {@link #uniqueColumns} indicates the position 
of
+ * the unique key on the current {@link org.apache.calcite.rel.RelNode},
+ * if not or not be confirmed, it is an empty set, the position in 
uniqueColumns
+ * corresponds to foreignColumns.
+ *
+ * The element positions in {@code uniqueColumns} and {@code foreignColumns}
+ * correspond to each other. The order of elements in {@code uniqueColumns}
+ * and {@code foreignColumns} is consistent with the order of constraints in
+ * the constraints list.
+ *
+ * For instance,
+ * 
+ * select e.deptno, e.ename, d.deptno
+ * from emp as e
+ * inner join dept as d
+ * on e.deptno = d.deptno
+ *
+ * the foreign key is the DEPTNO column of CATALOG.SALES.EMP table,
+ * reference the DEPTNO unique column of CATALOG.SALES.DEPT table.
+ *
+ * Invoke the {@link RelMetadataQuery#getConfirmedForeignKeys} method which
+ * input param is the top {@link org.apache.calcite.rel.core.Project},
+ * the following results can be obtained.
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#true, right: [CATALOG, SALES, 
DEPT].$0.#true}]
+ * {@code foreignColumns} is {0}
+ * {@code uniqueColumns} is {2}
+ *
+ * For instance,
+ * 
+ * select name, deptno
+ * from dept
+ *
+ * {@code constraints} is
+ * [{left: null.null.#false, right: [CATALOG, SALES, DEPT].$0.#false}]
+ * {@code foreignColumns} is {}
+ * {@code uniqueColumns} is {1}
+ *
+ * For instance,
+ * 
+ * select ename, sal, deptno
+ * from emp
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#false, right: [CATALOG, SALES, 
DEPT].$0.#false}]
+ * {@code foreignColumns} is {2}
+ * {@code uniqueColumns} is {}
+ *
+ * @see InferredConstraintKey
+ * @see org.apache.calcite.plan.RelOptForeignKey
+ */
+public class RelOptForeignKey {
+
+  /** Foreign key and unique key relationships in bottom-up derivation. */
+  private final List> 
constraints;
+  /** Position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet foreignColumns;
+  /** Position of the unique key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet uniqueColumns;
+
+  private RelOptForeignKey(
+  List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+this.constraints = constraints;
+this.foreignColumns = foreignColumns;
+this.uniqueColumns = uniqueColumns;
+  }
+
+  public static RelOptForeignKey of(List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+return new RelOptForeignKey(constraints, foreignColumns, uniqueColumns);
+  }
+
+  public ImmutableBitSet getForeignColumns() {
+return foreignColumns;
+  }
+
+  public ImmutableBitSet 

[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285766949


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * ForeignKey represents the foreign and unique key constraint relationship
+ * on the current {@link org.apache.calcite.rel.RelNode}.
+ *
+ * constraints field {@link #constraints} are
+ * constraints that foreign key and unique key relationships in bottom-up 
derivation.
+ *
+ * foreignColumns field {@link #foreignColumns} indicates the
+ * position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}
+ * if not or not be confirmed, it is an empty set.
+ *
+ * uniqueColumns field {@link #uniqueColumns} indicates the position 
of
+ * the unique key on the current {@link org.apache.calcite.rel.RelNode},
+ * if not or not be confirmed, it is an empty set, the position in 
uniqueColumns
+ * corresponds to foreignColumns.
+ *
+ * The element positions in {@code uniqueColumns} and {@code foreignColumns}
+ * correspond to each other. The order of elements in {@code uniqueColumns}
+ * and {@code foreignColumns} is consistent with the order of constraints in
+ * the constraints list.
+ *
+ * For instance,
+ * 
+ * select e.deptno, e.ename, d.deptno
+ * from emp as e
+ * inner join dept as d
+ * on e.deptno = d.deptno
+ *
+ * the foreign key is the DEPTNO column of CATALOG.SALES.EMP table,
+ * reference the DEPTNO unique column of CATALOG.SALES.DEPT table.
+ *
+ * Invoke the {@link RelMetadataQuery#getConfirmedForeignKeys} method which
+ * input param is the top {@link org.apache.calcite.rel.core.Project},
+ * the following results can be obtained.
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#true, right: [CATALOG, SALES, 
DEPT].$0.#true}]
+ * {@code foreignColumns} is {0}
+ * {@code uniqueColumns} is {2}
+ *
+ * For instance,
+ * 
+ * select name, deptno
+ * from dept
+ *
+ * {@code constraints} is
+ * [{left: null.null.#false, right: [CATALOG, SALES, DEPT].$0.#false}]
+ * {@code foreignColumns} is {}
+ * {@code uniqueColumns} is {1}
+ *
+ * For instance,
+ * 
+ * select ename, sal, deptno
+ * from emp
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#false, right: [CATALOG, SALES, 
DEPT].$0.#false}]
+ * {@code foreignColumns} is {2}
+ * {@code uniqueColumns} is {}
+ *
+ * @see InferredConstraintKey
+ * @see org.apache.calcite.plan.RelOptForeignKey
+ */
+public class RelOptForeignKey {
+
+  /** Foreign key and unique key relationships in bottom-up derivation. */
+  private final List> 
constraints;
+  /** Position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet foreignColumns;
+  /** Position of the unique key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet uniqueColumns;
+
+  private RelOptForeignKey(
+  List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+this.constraints = constraints;
+this.foreignColumns = foreignColumns;
+this.uniqueColumns = uniqueColumns;
+  }
+
+  public static RelOptForeignKey of(List> constraints,
+  ImmutableBitSet foreignColumns,
+  ImmutableBitSet uniqueColumns) {
+return new RelOptForeignKey(constraints, foreignColumns, uniqueColumns);
+  }
+
+  public ImmutableBitSet getForeignColumns() {
+return foreignColumns;
+  }
+
+  public ImmutableBitSet 

[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285764802


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**

Review Comment:
   Good code comments are very important. Can you make your comments concise 
and clear so that others can understand them easily?



##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**

Review Comment:
   Good code comments are very important. Can you make your comments concise 
and clear so that others can understand them easily?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285763589


##
core/src/main/java/org/apache/calcite/rel/metadata/BuiltInMetadata.java:
##
@@ -105,6 +106,43 @@ interface Handler extends MetadataHandler {
 }
   }
 
+  /**
+   * Metadata about which columns have foreign keys.
+   */
+  public interface ForeignKeys extends Metadata {
+MetadataDef DEF =
+MetadataDef.of(ForeignKeys.class, ForeignKeys.Handler.class,
+BuiltInMethod.FOREIGN_KEYS.method);
+
+/**
+ * Extract foreign keys from {@link org.apache.calcite.rel.RelNode}.
+ * Foreign keys are represented as an {@link 
org.apache.calcite.util.ImmutableBitSet},
+ * where each bit position represents a 0-based output column ordinal.
+ *
+ * @param ignoreNulls if true, allow containing null values when 
determining
+ * whether the keys are foreign keys
+ *
+ * @return bit set of foreign keys(contains intermediate inferred foreign 
keys),
+ * or empty if not enough information is available to make that 
determination
+ */
+Set getForeignKeys(boolean ignoreNulls);

Review Comment:
   Is it @Nullable ? Like this method:
   ```sql
   @Nullable Set getUniqueKeys(boolean ignoreNulls);
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285760940


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * ForeignKey represents the foreign and unique key constraint relationship
+ * on the current {@link org.apache.calcite.rel.RelNode}.
+ *
+ * constraints field {@link #constraints} are
+ * constraints that foreign key and unique key relationships in bottom-up 
derivation.
+ *
+ * foreignColumns field {@link #foreignColumns} indicates the
+ * position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}
+ * if not or not be confirmed, it is an empty set.
+ *
+ * uniqueColumns field {@link #uniqueColumns} indicates the position 
of
+ * the unique key on the current {@link org.apache.calcite.rel.RelNode},
+ * if not or not be confirmed, it is an empty set, the position in 
uniqueColumns
+ * corresponds to foreignColumns.
+ *
+ * The element positions in {@code uniqueColumns} and {@code foreignColumns}
+ * correspond to each other. The order of elements in {@code uniqueColumns}
+ * and {@code foreignColumns} is consistent with the order of constraints in
+ * the constraints list.
+ *
+ * For instance,
+ * 
+ * select e.deptno, e.ename, d.deptno
+ * from emp as e
+ * inner join dept as d
+ * on e.deptno = d.deptno
+ *
+ * the foreign key is the DEPTNO column of CATALOG.SALES.EMP table,
+ * reference the DEPTNO unique column of CATALOG.SALES.DEPT table.
+ *
+ * Invoke the {@link RelMetadataQuery#getConfirmedForeignKeys} method which
+ * input param is the top {@link org.apache.calcite.rel.core.Project},
+ * the following results can be obtained.
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#true, right: [CATALOG, SALES, 
DEPT].$0.#true}]
+ * {@code foreignColumns} is {0}
+ * {@code uniqueColumns} is {2}
+ *
+ * For instance,
+ * 
+ * select name, deptno
+ * from dept
+ *
+ * {@code constraints} is
+ * [{left: null.null.#false, right: [CATALOG, SALES, DEPT].$0.#false}]
+ * {@code foreignColumns} is {}
+ * {@code uniqueColumns} is {1}
+ *
+ * For instance,
+ * 
+ * select ename, sal, deptno
+ * from emp
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#false, right: [CATALOG, SALES, 
DEPT].$0.#false}]
+ * {@code foreignColumns} is {2}
+ * {@code uniqueColumns} is {}
+ *
+ * @see InferredConstraintKey
+ * @see org.apache.calcite.plan.RelOptForeignKey
+ */
+public class RelOptForeignKey {
+
+  /** Foreign key and unique key relationships in bottom-up derivation. */
+  private final List> 
constraints;
+  /** Position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet foreignColumns;
+  /** Position of the unique key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet uniqueColumns;

Review Comment:
   I think a foreign key is a reference to the Primary key of another 
table,make uniqueColumns to referredPrimaryKeys.
   
   Anyway make the name reflect its true meaning
   
   WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285760940


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * ForeignKey represents the foreign and unique key constraint relationship
+ * on the current {@link org.apache.calcite.rel.RelNode}.
+ *
+ * constraints field {@link #constraints} are
+ * constraints that foreign key and unique key relationships in bottom-up 
derivation.
+ *
+ * foreignColumns field {@link #foreignColumns} indicates the
+ * position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}
+ * if not or not be confirmed, it is an empty set.
+ *
+ * uniqueColumns field {@link #uniqueColumns} indicates the position 
of
+ * the unique key on the current {@link org.apache.calcite.rel.RelNode},
+ * if not or not be confirmed, it is an empty set, the position in 
uniqueColumns
+ * corresponds to foreignColumns.
+ *
+ * The element positions in {@code uniqueColumns} and {@code foreignColumns}
+ * correspond to each other. The order of elements in {@code uniqueColumns}
+ * and {@code foreignColumns} is consistent with the order of constraints in
+ * the constraints list.
+ *
+ * For instance,
+ * 
+ * select e.deptno, e.ename, d.deptno
+ * from emp as e
+ * inner join dept as d
+ * on e.deptno = d.deptno
+ *
+ * the foreign key is the DEPTNO column of CATALOG.SALES.EMP table,
+ * reference the DEPTNO unique column of CATALOG.SALES.DEPT table.
+ *
+ * Invoke the {@link RelMetadataQuery#getConfirmedForeignKeys} method which
+ * input param is the top {@link org.apache.calcite.rel.core.Project},
+ * the following results can be obtained.
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#true, right: [CATALOG, SALES, 
DEPT].$0.#true}]
+ * {@code foreignColumns} is {0}
+ * {@code uniqueColumns} is {2}
+ *
+ * For instance,
+ * 
+ * select name, deptno
+ * from dept
+ *
+ * {@code constraints} is
+ * [{left: null.null.#false, right: [CATALOG, SALES, DEPT].$0.#false}]
+ * {@code foreignColumns} is {}
+ * {@code uniqueColumns} is {1}
+ *
+ * For instance,
+ * 
+ * select ename, sal, deptno
+ * from emp
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#false, right: [CATALOG, SALES, 
DEPT].$0.#false}]
+ * {@code foreignColumns} is {2}
+ * {@code uniqueColumns} is {}
+ *
+ * @see InferredConstraintKey
+ * @see org.apache.calcite.plan.RelOptForeignKey
+ */
+public class RelOptForeignKey {
+
+  /** Foreign key and unique key relationships in bottom-up derivation. */
+  private final List> 
constraints;
+  /** Position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet foreignColumns;
+  /** Position of the unique key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet uniqueColumns;

Review Comment:
   I think a foreign key is a reference to the Primary key of another 
table,make uniqueColumns to referredPrimaryKeys.
   
   Make the name reflect its true meaning
   
   WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285755688


##
core/src/main/java/org/apache/calcite/rel/metadata/BuiltInMetadata.java:
##
@@ -105,6 +106,43 @@ interface Handler extends MetadataHandler {
 }
   }
 
+  /**
+   * Metadata about which columns have foreign keys.
+   */
+  public interface ForeignKeys extends Metadata {
+MetadataDef DEF =
+MetadataDef.of(ForeignKeys.class, ForeignKeys.Handler.class,
+BuiltInMethod.FOREIGN_KEYS.method);
+
+/**
+ * Extract foreign keys from {@link org.apache.calcite.rel.RelNode}.
+ * Foreign keys are represented as an {@link 
org.apache.calcite.util.ImmutableBitSet},
+ * where each bit position represents a 0-based output column ordinal.
+ *
+ * @param ignoreNulls if true, allow containing null values when 
determining
+ * whether the keys are foreign keys
+ *
+ * @return bit set of foreign keys(contains intermediate inferred foreign 
keys),
+ * or empty if not enough information is available to make that 
determination
+ */
+Set getForeignKeys(boolean ignoreNulls);
+
+/**
+ * Handler API.
+ */
+@FunctionalInterface
+interface Handler extends MetadataHandler {
+  Set getForeignKeys(
+  RelNode rel,
+  RelMetadataQuery mq,

Review Comment:
   Is it @Nullable,like the method:
   ```sql
   @Nullable Set getUniqueKeys(RelNode r, RelMetadataQuery mq,
 boolean ignoreNulls);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285753858


##
core/src/main/java/org/apache/calcite/rel/metadata/BuiltInMetadata.java:
##
@@ -105,6 +106,43 @@ interface Handler extends MetadataHandler {
 }
   }
 
+  /**
+   * Metadata about which columns have foreign keys.
+   */
+  public interface ForeignKeys extends Metadata {
+MetadataDef DEF =
+MetadataDef.of(ForeignKeys.class, ForeignKeys.Handler.class,
+BuiltInMethod.FOREIGN_KEYS.method);
+
+/**
+ * Extract foreign keys from {@link org.apache.calcite.rel.RelNode}.
+ * Foreign keys are represented as an {@link 
org.apache.calcite.util.ImmutableBitSet},
+ * where each bit position represents a 0-based output column ordinal.
+ *
+ * @param ignoreNulls if true, allow containing null values when 
determining
+ * whether the keys are foreign keys
+ *
+ * @return bit set of foreign keys(contains intermediate inferred foreign 
keys),
+ * or empty if not enough information is available to make that 
determination
+ */
+Set getForeignKeys(boolean ignoreNulls);

Review Comment:
   Is it @Nullable?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3351: [CALCITE-5899] Add HAMMING_DISTANCE function (enabled in Presto Library)

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3351:
URL: https://github.com/apache/calcite/pull/3351#issuecomment-1667701773

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3351)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3351=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3351=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3351=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=CODE_SMELL)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=CODE_SMELL)
   
   
[![88.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'88.9%')](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_coverage=list)
 [88.9% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285753858


##
core/src/main/java/org/apache/calcite/rel/metadata/BuiltInMetadata.java:
##
@@ -105,6 +106,43 @@ interface Handler extends MetadataHandler {
 }
   }
 
+  /**
+   * Metadata about which columns have foreign keys.
+   */
+  public interface ForeignKeys extends Metadata {
+MetadataDef DEF =
+MetadataDef.of(ForeignKeys.class, ForeignKeys.Handler.class,
+BuiltInMethod.FOREIGN_KEYS.method);
+
+/**
+ * Extract foreign keys from {@link org.apache.calcite.rel.RelNode}.
+ * Foreign keys are represented as an {@link 
org.apache.calcite.util.ImmutableBitSet},
+ * where each bit position represents a 0-based output column ordinal.
+ *
+ * @param ignoreNulls if true, allow containing null values when 
determining
+ * whether the keys are foreign keys
+ *
+ * @return bit set of foreign keys(contains intermediate inferred foreign 
keys),
+ * or empty if not enough information is available to make that 
determination
+ */
+Set getForeignKeys(boolean ignoreNulls);

Review Comment:
   Is it @Nullable?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] LakeShen commented on a diff in pull request #3345: [CALCITE-5881] Support to get foreign keys metadata in RelMetadataQuery

2023-08-07 Thread via GitHub


LakeShen commented on code in PR #3345:
URL: https://github.com/apache/calcite/pull/3345#discussion_r1285749110


##
core/src/main/java/org/apache/calcite/plan/RelOptForeignKey.java:
##
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.InferredConstraintKey;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * ForeignKey represents the foreign and unique key constraint relationship
+ * on the current {@link org.apache.calcite.rel.RelNode}.
+ *
+ * constraints field {@link #constraints} are
+ * constraints that foreign key and unique key relationships in bottom-up 
derivation.
+ *
+ * foreignColumns field {@link #foreignColumns} indicates the
+ * position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}
+ * if not or not be confirmed, it is an empty set.
+ *
+ * uniqueColumns field {@link #uniqueColumns} indicates the position 
of
+ * the unique key on the current {@link org.apache.calcite.rel.RelNode},
+ * if not or not be confirmed, it is an empty set, the position in 
uniqueColumns
+ * corresponds to foreignColumns.
+ *
+ * The element positions in {@code uniqueColumns} and {@code foreignColumns}
+ * correspond to each other. The order of elements in {@code uniqueColumns}
+ * and {@code foreignColumns} is consistent with the order of constraints in
+ * the constraints list.
+ *
+ * For instance,
+ * 
+ * select e.deptno, e.ename, d.deptno
+ * from emp as e
+ * inner join dept as d
+ * on e.deptno = d.deptno
+ *
+ * the foreign key is the DEPTNO column of CATALOG.SALES.EMP table,
+ * reference the DEPTNO unique column of CATALOG.SALES.DEPT table.
+ *
+ * Invoke the {@link RelMetadataQuery#getConfirmedForeignKeys} method which
+ * input param is the top {@link org.apache.calcite.rel.core.Project},
+ * the following results can be obtained.
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#true, right: [CATALOG, SALES, 
DEPT].$0.#true}]
+ * {@code foreignColumns} is {0}
+ * {@code uniqueColumns} is {2}
+ *
+ * For instance,
+ * 
+ * select name, deptno
+ * from dept
+ *
+ * {@code constraints} is
+ * [{left: null.null.#false, right: [CATALOG, SALES, DEPT].$0.#false}]
+ * {@code foreignColumns} is {}
+ * {@code uniqueColumns} is {1}
+ *
+ * For instance,
+ * 
+ * select ename, sal, deptno
+ * from emp
+ *
+ * {@code constraints} is
+ * [{left: [CATALOG, SALES, EMP].$7.#false, right: [CATALOG, SALES, 
DEPT].$0.#false}]
+ * {@code foreignColumns} is {2}
+ * {@code uniqueColumns} is {}
+ *
+ * @see InferredConstraintKey
+ * @see org.apache.calcite.plan.RelOptForeignKey
+ */
+public class RelOptForeignKey {
+
+  /** Foreign key and unique key relationships in bottom-up derivation. */
+  private final List> 
constraints;
+  /** Position of the foreign key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet foreignColumns;
+  /** Position of the unique key on the current {@link 
org.apache.calcite.rel.RelNode}. */
+  private final ImmutableBitSet uniqueColumns;

Review Comment:
   Why is there information about a unique key in the RelOptForeignKey class?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] chucheng92 commented on pull request #3320: [CALCITE-5830] Add ARRAY_INSERT function(enabled in Spark library)

2023-08-07 Thread via GitHub


chucheng92 commented on PR #3320:
URL: https://github.com/apache/calcite/pull/3320#issuecomment-1667627032

   @NobiGo hi, I have solved all your comments. If you have time, pls help to 
re-check it. thank you.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] chucheng92 commented on a diff in pull request #3320: [CALCITE-5830] Add ARRAY_INSERT function(enabled in Spark library)

2023-08-07 Thread via GitHub


chucheng92 commented on code in PR #3320:
URL: https://github.com/apache/calcite/pull/3320#discussion_r1285699097


##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -4107,6 +4113,97 @@ public static List arrayExcept(List list1, List list2) {
 return new ArrayList<>(result);
   }
 
+  /** Support the ARRAY_INSERT(array, pos, val) function. */
+  public static @Nullable List arrayInsert(List baselist, Object pos, Object 
val) {
+if (baselist == null || pos == null) {
+  return null;
+}
+int posInt = (int) pos;
+if (posInt == 0) {
+  throw new IllegalArgumentException("The index 0 is invalid. "
+  + "An index shall be either < 0 or > 0 (the first element has index 
1)");
+}
+
+boolean usePositivePos = posInt > 0;
+
+if (usePositivePos) {
+  int newArrayLength = Math.max(baselist.size() + 1, posInt);

Review Comment:
   @NobiGo yes. you are right. `System.arraycopy()` may has better performance 
when array is large. I have fixed it. PTAL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3320: [CALCITE-5830] Add ARRAY_INSERT function(enabled in Spark library)

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3320:
URL: https://github.com/apache/calcite/pull/3320#issuecomment-1667588055

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3320)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3320=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3320=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3320=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=CODE_SMELL)
 [9 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=CODE_SMELL)
   
   
[![83.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'83.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_coverage=list)
 [83.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3320: [CALCITE-5830] Add ARRAY_INSERT function(enabled in Spark library)

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3320:
URL: https://github.com/apache/calcite/pull/3320#issuecomment-1667566829

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3320)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3320=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3320=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3320=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=CODE_SMELL)
 [9 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3320=false=CODE_SMELL)
   
   
[![83.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'83.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_coverage=list)
 [83.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3320=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] chucheng92 commented on a diff in pull request #3320: [CALCITE-5830] Add ARRAY_INSERT function(enabled in Spark library)

2023-08-07 Thread via GitHub


chucheng92 commented on code in PR #3320:
URL: https://github.com/apache/calcite/pull/3320#discussion_r1285651475


##
site/_docs/reference.md:
##
@@ -2658,6 +2658,7 @@ BigQuery's type system uses confusingly different names 
for types and functions:
 | s | ARRAY_CONTAINS(array, element) | Returns true if the 
*array* contains the *element*
 | s | ARRAY_DISTINCT(array)  | Removes duplicate 
values from the *array* that keeps ordering of elements
 | s | ARRAY_EXCEPT(array1, array2)   | Returns an array of the 
elements in *array1* but not in *array2*, without duplicates
+| s | ARRAY_INSERT(array, pos, element)  | Places *element* into 
index *pos* of *array*. Array index start at 1, or start from the end if index 
is negative. Index above array size appends the array, or prepends the array if 
index is negative, with 'null' elements.

Review Comment:
   yes. fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[calcite-avatica] branch main updated (2736c2795 -> db4cd704a)

2023-08-07 Thread stoty
This is an automated email from the ASF dual-hosted git repository.

stoty pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/calcite-avatica.git


from 2736c2795 [CALCITE-5748] Support Guava 32.1.1-jre
 add db4cd704a [CALCITE-5890] Handle non-JKS truststores in Avatica client

No new revisions were added by this update.

Summary of changes:
 .../calcite/avatica/BuiltInConnectionProperty.java |  3 +++
 .../apache/calcite/avatica/ConnectionConfig.java   |  2 ++
 .../calcite/avatica/ConnectionConfigImpl.java  |  5 +
 .../avatica/remote/CommonsHttpClientPoolCache.java |  4 
 .../org/apache/calcite/avatica/SslDriverTest.java  | 25 ++
 site/_docs/client_reference.md | 12 +++
 6 files changed, 51 insertions(+)



[GitHub] [calcite-avatica] stoty closed pull request #224: [CALCITE-5890] Handle non-JKS truststores in Avatica client

2023-08-07 Thread via GitHub


stoty closed pull request #224: [CALCITE-5890] Handle non-JKS truststores in 
Avatica client
URL: https://github.com/apache/calcite-avatica/pull/224


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3351: [CALCITE-5899] Add HAMMING_DISTANCE function (enabled in Presto Library)

2023-08-07 Thread via GitHub


sonarcloud[bot] commented on PR #3351:
URL: https://github.com/apache/calcite/pull/3351#issuecomment-1667413813

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3351)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3351=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3351=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3351=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=CODE_SMELL)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3351=false=CODE_SMELL)
   
   
[![88.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'88.9%')](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_coverage=list)
 [88.9% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3351=new_duplicated_lines_density=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] macroguo-ghy opened a new pull request, #3351: [CALCITE-5899] Add HAMMING_DISTANCE function (enabled in Presto Library)

2023-08-07 Thread via GitHub


macroguo-ghy opened a new pull request, #3351:
URL: https://github.com/apache/calcite/pull/3351

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite-avatica] stoty commented on pull request #224: [CALCITE-5890] Handle non-JKS truststores in Avatica client

2023-08-07 Thread via GitHub


stoty commented on PR #224:
URL: https://github.com/apache/calcite-avatica/pull/224#issuecomment-1667363989

   Is this test sufficient, @snuyanzin  ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] NobiGo commented on a diff in pull request #3320: [CALCITE-5830] Add ARRAY_INSERT function(enabled in Spark library)

2023-08-07 Thread via GitHub


NobiGo commented on code in PR #3320:
URL: https://github.com/apache/calcite/pull/3320#discussion_r1285482457


##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -4107,6 +4113,97 @@ public static List arrayExcept(List list1, List list2) {
 return new ArrayList<>(result);
   }
 
+  /** Support the ARRAY_INSERT(array, pos, val) function. */
+  public static @Nullable List arrayInsert(List baselist, Object pos, Object 
val) {
+if (baselist == null || pos == null) {
+  return null;
+}
+int posInt = (int) pos;
+if (posInt == 0) {
+  throw new IllegalArgumentException("The index 0 is invalid. "
+  + "An index shall be either < 0 or > 0 (the first element has index 
1)");
+}
+
+boolean usePositivePos = posInt > 0;
+
+if (usePositivePos) {
+  int newArrayLength = Math.max(baselist.size() + 1, posInt);

Review Comment:
   I get it. Thanks for your explanation. How about we use the 
`System.arraycopy()` and `Arrays.fill()` to implement this? Others are good to 
me. 



##
site/_docs/reference.md:
##
@@ -2658,6 +2658,7 @@ BigQuery's type system uses confusingly different names 
for types and functions:
 | s | ARRAY_CONTAINS(array, element) | Returns true if the 
*array* contains the *element*
 | s | ARRAY_DISTINCT(array)  | Removes duplicate 
values from the *array* that keeps ordering of elements
 | s | ARRAY_EXCEPT(array1, array2)   | Returns an array of the 
elements in *array1* but not in *array2*, without duplicates
+| s | ARRAY_INSERT(array, pos, element)  | Places *element* into 
index *pos* of *array*. Array index start at 1, or start from the end if index 
is negative. Index above array size appends the array, or prepends the array if 
index is negative, with 'null' elements.

Review Comment:
   `NULL` value is better?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org