danny0405 commented on a change in pull request #2696:
URL: https://github.com/apache/calcite/pull/2696#discussion_r790205396
##########
File path:
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
##########
@@ -2441,9 +2447,8 @@ private SqlNode registerFrom(
null,
forceRightNullable,
lateral);
- if (newRight != right) {
- join.setRight(newRight);
- }
+ // for check style.
+ swapJoinRightNode(join, right, newRight);
Review comment:
Don't think this is a right change, you should make the `newRight`
correct first.
##########
File path: core/src/main/java/org/apache/calcite/sql/SqlCorrelateTableRef.java
##########
@@ -0,0 +1,73 @@
+/*
+ * 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 com.google.common.collect.ImmutableList;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.List;
+
+import static java.util.Objects.requireNonNull;
Review comment:
Can we just reuse `SqlTableRef` code ? We can switch the `tableName` to
`tableRef` which is a `SqlNode`.
##########
File path:
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
##########
@@ -1225,7 +1226,7 @@ private SqlValidatorScope getScopeOrThrow(SqlNode node) {
return getNamespace(id);
}
- @Override public @Nullable SqlValidatorNamespace getNamespace(SqlNode node) {
+ @Override public @Nullable SqlValidatorNamespace getNamespace(SqlNode node)
{
switch (node.getKind()) {
Review comment:
unnecessary change.
##########
File path: core/src/main/codegen/templates/Parser.jj
##########
@@ -2173,10 +2176,23 @@ SqlNode TableRef2(boolean lateral) :
<TABLE> { s = span(); } <LPAREN>
tableRef = TableFunctionCall(s.pos())
<RPAREN>
+ [
+ <HINT_BEG>
+ CommaSeparatedSqlHints(hints)
+ <COMMENT_END>
+ ]
{
if (lateral) {
- tableRef = SqlStdOperatorTable.LATERAL.createCall(
- s.end(this), tableRef);
+ if (hints.size() > 0) {
+ hintList = new SqlNodeList(hints,
s.addAll(hints).end(this));
+ SqlNode tmpTableRef =
SqlStdOperatorTable.LATERAL.createCall(
+ s.end(this), tableRef);
Review comment:
`tmpTableRef ` => `lateralCall`
##########
File path: core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
##########
@@ -3001,12 +3009,20 @@ private void convertJoin(Blackboard bb, SqlJoin join) {
throw Util.unexpected(conditionType);
}
}
+
+ final List<RelHint> hints;
+ if (right instanceof SqlCorrelateTableRef) {
+ hints = SqlUtil.getRelHint(hintStrategies, ((SqlCorrelateTableRef)
right).operand(1));
+ } else {
Review comment:
A way to avoid these `instanceOf` is add a new `SqlKind`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]