Re: [PR] [CALCITE-5949] RexExecutable should return unchanged original expressions when it fails [calcite]

2023-10-04 Thread via GitHub


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

   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=3390)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3390=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=3390=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3390=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=3390=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=3390=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3390=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=3390=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=3390=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3390=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=3390=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=3390=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3390=false=CODE_SMELL)
   
   
[![83.3%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'83.3%')](https://sonarcloud.io/component_measures?id=apache_calcite=3390=new_coverage=list)
 [83.3% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3390=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=3390=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3390=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



Re: [PR] [CALCITE-5949] RexExecutable should return unchanged original expressions when it fails [calcite]

2023-10-04 Thread via GitHub


arkanovicz commented on code in PR #3390:
URL: https://github.com/apache/calcite/pull/3390#discussion_r1346778853


##
core/src/main/java/org/apache/calcite/rex/RexExecutable.java:
##
@@ -87,11 +88,14 @@ public void reduce(RexBuilder rexBuilder, List 
constExps,
 values = new Object[constExps.size()];
   } else {
 assert values.length == constExps.size();
+final List successfullyReduced = new ArrayList<>();

Review Comment:
   Added.



-- 
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



Re: [PR] Update project.copy() in RelBuilder.aggregate_ to reuse the traitSet() [calcite]

2023-10-04 Thread via GitHub


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

   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=3454)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3454=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=3454=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3454=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=3454=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=3454=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3454=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=3454=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=3454=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3454=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=3454=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=3454=false=CODE_SMELL)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3454=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=3454=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3454=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=3454=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3454=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



Re: [PR] Update project.copy() in RelBuilder.aggregate_ to reuse the traitSet() [calcite]

2023-10-04 Thread via GitHub


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

   A bug that is fixed by this change would help a lot.


-- 
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



[PR] Update project.copy() in RelBuilder.aggregate_ to reuse the traitSet() [calcite]

2023-10-04 Thread via GitHub


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

   I use Calcite in the project I work on, and I encountered a bug where 
pruning columns with aggregate_ was dropping trait information when attempting 
to do this project.copy(). I believe this is because rather than using the 
cluster traitSet, this call should reuse the traitSet of the original 
projection (as all this projection does is prune unused columns).
   
   I'm not sure the best way to test this, so any suggestions would be greatly 
appreciated. In addition if I have any misconceptions/misunderstandings about 
how the traitSet should be used and this should not be changed, my apologies 
for taking your time.


-- 
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



Re: [PR] [CALCITE-5387] Type-mismatch on nullability in JoinPushTransitivePredicatesRule RelRule [calcite]

2023-10-04 Thread via GitHub


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

   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=3452)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3452=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=3452=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3452=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=3452=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=3452=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3452=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=3452=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=3452=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3452=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=3452=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=3452=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3452=false=CODE_SMELL)
   
   
[![92.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'92.9%')](https://sonarcloud.io/component_measures?id=apache_calcite=3452=new_coverage=list)
 [92.9% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3452=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=3452=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3452=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



Re: [PR] [CALCITE-5387] Type-mismatch on nullability in JoinPushTransitivePredicatesRule RelRule [calcite]

2023-10-04 Thread via GitHub


keatn commented on code in PR #3452:
URL: https://github.com/apache/calcite/pull/3452#discussion_r1346428537


##
core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java:
##
@@ -666,6 +666,29 @@ static class JoinConditionBasedPredicateInference {
   equivalence = BitSets.closure(equivalence);
 }
 
+/**
+ * As RexPermuteInputsShuttle, with one exception. When visiting an 
inputRef,
+ * it will replace the type of the InputRef with the type found in the 
input fields,
+ * instead of keeping the original type. This is used within
+ * when generating the Left/RightInferredPredicates, to avoid nullability 
mismatches
+ * between the types of the join and the types of the inputs.
+ */
+private class TypeChangingRexPermuteInputsShuttle
+extends org.apache.calcite.rex.RexPermuteInputsShuttle {
+
+  TypeChangingRexPermuteInputsShuttle(Mappings.TargetMapping mapping, 
RelNode... inputs) {
+super(mapping, inputs);
+  }
+
+  @Override public RexNode visitInputRef(RexInputRef local) {
+final int index = local.getIndex();
+int target = mapping.getTarget(index);
+return new RexInputRef(
+target,
+fields.get(target).getType());

Review Comment:
   I think in order to check that the two types are equivalent except for 
nullability, I would need to have access to a typefactory, so I could do 
something like `typefatory.createTypeWithNullability(t1, 
t2.isNullable()).equals(t1)`.
   
   For now, I added a sanity check to confirm that the two types are of the 
same type family. I'm not certain if this is a good check for compatibility, 
and am open to changing it.



-- 
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



Re: [PR] [CALCITE-5387] Type-mismatch on nullability in JoinPushTransitivePredicatesRule RelRule [calcite]

2023-10-04 Thread via GitHub


keatn commented on code in PR #3452:
URL: https://github.com/apache/calcite/pull/3452#discussion_r1346428283


##
core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java:
##
@@ -666,6 +666,29 @@ static class JoinConditionBasedPredicateInference {
   equivalence = BitSets.closure(equivalence);
 }
 
+/**
+ * As RexPermuteInputsShuttle, with one exception. When visiting an 
inputRef,
+ * it will replace the type of the InputRef with the type found in the 
input fields,
+ * instead of keeping the original type. This is used within
+ * when generating the Left/RightInferredPredicates, to avoid nullability 
mismatches
+ * between the types of the join and the types of the inputs.
+ */
+private class TypeChangingRexPermuteInputsShuttle
+extends org.apache.calcite.rex.RexPermuteInputsShuttle {

Review Comment:
   I tried doing something like this in `RexPermuteInputsShuttle` 
   
   ```
   if (fields.isEmpty()) {
 return new RexInputRef(
 target,
 local.getType());
   } else {
 return new RexInputRef(
 target,
 fields.get(target).getType());
   }
   ```
   (Note that the if statement is needed because it's valid to create a 
`RexPermuteInputsShuttle` without any backing fields.)
   
   This caused several tests to fail with index out of bound errors. The reason 
wasn't obvious to me. I'll do a bit of poking around and see if I can figure 
out why.
   
   



-- 
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



Re: [PR] [CALCITE-5523] RelToSql converter generates GROUP BY clause with wind… [calcite]

2023-10-04 Thread via GitHub


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

   Hi @JiajunBernoulli 
   
   It looks like the title and commit's description is not clear.


-- 
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



Re: [PR] [CALCITE-4455] Babel parser support Spark INSERT OVERWRITE TABLE/DIRECTORY statement [calcite]

2023-10-04 Thread via GitHub


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

   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=2949)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=2949=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=2949=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=2949=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=2949=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=2949=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=2949=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=2949=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=2949=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=2949=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=2949=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=2949=false=CODE_SMELL)
 [4 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=2949=false=CODE_SMELL)
   
   
[![96.6%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'96.6%')](https://sonarcloud.io/component_measures?id=apache_calcite=2949=new_coverage=list)
 [96.6% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=2949=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=2949=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=2949=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



Re: [PR] [CALCITE-4455] Babel parser support Spark INSERT OVERWRITE TABLE/DIRECTORY statement [calcite]

2023-10-04 Thread via GitHub


JiajunBernoulli commented on code in PR #2949:
URL: https://github.com/apache/calcite/pull/2949#discussion_r1345327822


##
core/src/main/java/org/apache/calcite/sql/SqlInsertOverwrite.java:
##
@@ -0,0 +1,69 @@
+/*
+ * 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.sql;
+
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorScope;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Base class for INSERT OVERWRITE TABLE and INSERT OVERWRITE DIRECTORY 
statements.
+ */
+public abstract class SqlInsertOverwrite extends SqlCall {
+  protected static final SqlOperator INSERT_OVERWRITE_OPERATOR =
+  new SqlSpecialOperator("INSERT_OVERWRITE", SqlKind.INSERT_OVERWRITE);
+
+  private final SqlOperator operator;
+  private final SqlNode target;
+  private final SqlNode source;
+
+  @Override public SqlOperator getOperator() {
+return operator;
+  }
+
+  public SqlNode getTarget() {
+return target;
+  }
+
+  public SqlNode getSource() {
+return source;
+  }
+
+  /** Creates a SqlInsertOverwrite. */
+  protected SqlInsertOverwrite(SqlOperator operator,
+  SqlNode target,
+  SqlNode source,
+  SqlParserPos pos) {
+super(pos);
+this.operator = Objects.requireNonNull(operator, "operator");

Review Comment:
   Ok, I used static import.



##
core/src/main/java/org/apache/calcite/sql/SqlKind.java:
##
@@ -1265,6 +1268,7 @@ public enum SqlKind {
* {@link #DELETE},
* {@link #MERGE},
* {@link #PROCEDURE_CALL}.
+   * {@link #INSERT_OVERWRITE}.

Review Comment:
   They are not in alphabetical order, I have rearranged them.



-- 
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



Re: [PR] [CALCITE-4455] Babel parser support Spark INSERT OVERWRITE TABLE/DIRECTORY statement [calcite]

2023-10-04 Thread via GitHub


JiajunBernoulli commented on code in PR #2949:
URL: https://github.com/apache/calcite/pull/2949#discussion_r1345327464


##
babel/src/main/java/org/apache/calcite/sql/babel/SqlInsertOverwriteDir.java:
##
@@ -0,0 +1,72 @@
+/*
+ * 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.sql.babel;
+
+import org.apache.calcite.sql.SqlInsertOverwrite;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+/**
+ * A SqlInsertOverwriteDirectory is a node of a parse tree which 
represents an
+ * INSERT OVERWRITE DIRECTORY statement.
+ */
+public class SqlInsertOverwriteDir extends SqlInsertOverwrite {
+  public static final SqlSpecialOperator OPERATOR =
+new SqlSpecialOperator("INSERT OVERWRITE DIRECTORY", 
SqlKind.INSERT_OVERWRITE);
+  private boolean isLocal;
+  private SqlNode format;
+  private SqlNodeList optionList;

Review Comment:
   Yes, I should have done that.



-- 
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



Re: [PR] [CALCITE-4455] Babel parser support Spark INSERT OVERWRITE TABLE/DIRECTORY statement [calcite]

2023-10-04 Thread via GitHub


JiajunBernoulli commented on code in PR #2949:
URL: https://github.com/apache/calcite/pull/2949#discussion_r1345328139


##
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##
@@ -3080,6 +3081,26 @@ private void registerQuery(
   }
   break;
 
+case INSERT_OVERWRITE:
+  SqlInsertOverwrite insertOverwrite = (SqlInsertOverwrite) node;
+  if (insertOverwrite.getTarget() instanceof SqlIdentifier) {
+InsertOvertwriteNamespace insertOvertwriteNamespace =
+new InsertOvertwriteNamespace(this, insertOverwrite,
+enclosingNode,

Review Comment:
   Done



##
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##
@@ -6425,6 +6481,23 @@ protected DmlNamespace(SqlValidatorImpl validator, 
SqlNode id,
 }
   }
 
+  /**

Review Comment:
   Fixed typo.
   
   There are `SqlInsert` in InsertNamespace, but I need `SqlInsertOverwrite`. 
   One namespace has one SqlNode, so used `InsertOverwriteNamespace`
   



-- 
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



Re: [PR] [CALCITE-4455] Babel parser support Spark INSERT OVERWRITE TABLE/DIRECTORY statement [calcite]

2023-10-04 Thread via GitHub


JiajunBernoulli commented on code in PR #2949:
URL: https://github.com/apache/calcite/pull/2949#discussion_r1345327189


##
babel/src/main/java/org/apache/calcite/sql/babel/SqlInsertOverwriteDir.java:
##
@@ -0,0 +1,72 @@
+/*
+ * 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.sql.babel;
+
+import org.apache.calcite.sql.SqlInsertOverwrite;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+/**
+ * A SqlInsertOverwriteDirectory is a node of a parse tree which 
represents an
+ * INSERT OVERWRITE DIRECTORY statement.
+ */
+public class SqlInsertOverwriteDir extends SqlInsertOverwrite {

Review Comment:
   Renamed them.



##
babel/src/main/java/org/apache/calcite/sql/babel/SqlInsertOverwriteDir.java:
##
@@ -0,0 +1,72 @@
+/*
+ * 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.sql.babel;
+
+import org.apache.calcite.sql.SqlInsertOverwrite;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+/**
+ * A SqlInsertOverwriteDirectory is a node of a parse tree which 
represents an
+ * INSERT OVERWRITE DIRECTORY statement.
+ */
+public class SqlInsertOverwriteDir extends SqlInsertOverwrite {
+  public static final SqlSpecialOperator OPERATOR =
+new SqlSpecialOperator("INSERT OVERWRITE DIRECTORY", 
SqlKind.INSERT_OVERWRITE);

Review Comment:
   Yes, changed it to private.



-- 
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