YiwenWu commented on code in PR #3883:
URL: https://github.com/apache/calcite/pull/3883#discussion_r1709343783
##########
core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java:
##########
@@ -786,6 +788,9 @@ public TrimResult trimFields(
+ join.getLeft().getRowType().getFieldCount()
+ join.getRight().getRowType().getFieldCount();
final RexNode conditionExpr = join.getCondition();
+ final RexNode matchConditionExpr = (join instanceof LogicalAsofJoin)
+ ? ((LogicalAsofJoin) join).getMatchCondition()
Review Comment:
Directly limit `((LogicalAsofJoin) join).getMatchCondition()` always not
null?
##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -2092,13 +2096,32 @@ SqlNode JoinTable(SqlNode e) :
//
// We allow CROSS JOIN (joinType = CROSS_JOIN) to have a join condition,
// even though that is not valid SQL; the validator will catch it.
- LOOKAHEAD(3)
+ LOOKAHEAD(4)
natural = Natural()
joinType = JoinType()
e2 = TableRef1(ExprContext.ACCEPT_QUERY_OR_JOIN)
(
+ [ <MATCH_CONDITION> matchCondition =
Expression(ExprContext.ACCEPT_SUB_QUERY) ]
Review Comment:
(1). Is it consistent with snowflake, also uses parentheses?
(2). Whether MATCH_CONDITION support multiple conditions?
<img width="771" alt="image"
src="https://github.com/user-attachments/assets/4b67946f-b249-4b0a-a3bb-8a16e9956b77">
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableAsofJoin.java:
##########
@@ -0,0 +1,253 @@
+/*
+ * 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.adapter.enumerable;
+
+import org.apache.calcite.linq4j.tree.BlockBuilder;
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.linq4j.tree.Expressions;
+import org.apache.calcite.plan.DeriveMode;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelOptCost;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelCollationTraitDef;
+import org.apache.calcite.rel.RelCollations;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.CorrelationId;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.logical.LogicalAsofJoin;
+import org.apache.calcite.rel.metadata.RelMdCollation;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.util.BuiltInMethod;
+import org.apache.calcite.util.Pair;
+
+import com.google.common.collect.ImmutableList;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/** Implementation of {@link LogicalAsofJoin} in
Review Comment:
Should consider introducing a new `AsofJoin` class? Both `LogicalAsofJoin`
and `EnumerableAsofJoin` can extends this 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]