korlov42 commented on code in PR #7471:
URL: https://github.com/apache/ignite-3/pull/7471#discussion_r2754293930
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/CorrelatedNestedLoopJoinNode.java:
##########
@@ -485,7 +491,16 @@ private Node<RowT> rightSource() {
private void prepareCorrelations() {
for (int i = 0; i < correlationIds.size(); i++) {
RowT row = i < leftInBuf.size() ? leftInBuf.get(i) :
first(leftInBuf);
- context().correlatedVariable(row, correlationIds.get(i).getId());
+ int corrId = correlationIds.get(i).getId();
+
+ for (int fieldIndex = correlationColumns.nextSetBit(0); fieldIndex
!= -1;
+ fieldIndex = correlationColumns.nextSetBit(fieldIndex +
1)) {
+ Object value = context().rowAccessor().get(fieldIndex, row);
+
+ long id = ((long) corrId << 32) | (fieldIndex & 0xFFFF_FFFFL);
Review Comment:
I would derive this computation to some utility method (and reuse it inside
`CorrValGetter`)
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlEvaluationContext.java:
##########
@@ -38,6 +39,6 @@ public interface SqlEvaluationContext<RowT> extends
DataContext {
/** Returns a factory capable of producing {@link RowFactory} instances
for the {@code RowT} row representation. */
RowFactoryFactory<RowT> rowFactoryFactory();
- /** Returns row representing correlation source by given correlation id. */
- RowT correlatedVariable(int id);
+ /** Returns the value of a correlated variable identified by the given
correlation id and field index. */
Review Comment:
```suggestion
/** Returns the value of a correlated variable identified by the given
correlation id. */
```
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/SharedStateTest.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.ignite.internal.sql.engine.exec;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for class {@link SharedState}.
+ */
+public class SharedStateTest {
+ private final SharedState state = new SharedState();
+
+ @Test
+ void canSetNullAsValue() {
+ state.correlatedVariable(1, null);
+
+ assertThat(state.correlatedVariable(1), is(Matchers.nullValue()));
Review Comment:
let's also add a few tests like this for a few non null values (not
necessary to cover all possible types)
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlKillParserTest.java:
##########
@@ -50,6 +51,13 @@ public void killStatement(String stmt,
IgniteSqlKillObjectType objectType) {
expectUnparsed(kill, stmt);
}
+ @Test
+ void testX() {
+ SqlNode sqlNode = parse("SELECT * FROM tab1, tab2 WHERE tab1.id =
tab2.id");
Review Comment:
is it some kind of debug test?
--
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]