Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lancelly committed Jan 9, 2025
1 parent 17b305e commit b9dc058
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public void testInPredicateSubqueryLegalityCheck() {
// Legality check: Join key type mismatch.(left key is int and right key is double)
tableAssertTestFail(
"select s1 from table1 where device_id = 'd01' and s1 in (select s1 + 30.0 from table3 where device_id = 'd01')",
"301: Join key type mismatch.",
"701: Join key type mismatch",
DATABASE_NAME);

// Legality check: Row Type is not supported for now.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.schema.column.ColumnHeader;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
import org.apache.iotdb.db.queryengine.execution.aggregation.timerangeiterator.ITableTimeRangeIterator;
import org.apache.iotdb.db.queryengine.execution.aggregation.timerangeiterator.TableDateBinTimeRangeIterator;
Expand Down Expand Up @@ -1415,10 +1416,9 @@ public Operator visitJoin(JoinNode node, LocalExecutionPlanContext context) {

Type leftJoinKeyType =
context.getTypeProvider().getTableModelType(node.getCriteria().get(i).getLeft());
checkArgument(
leftJoinKeyType
== context.getTypeProvider().getTableModelType(node.getCriteria().get(i).getRight()),
"Join key type mismatch.");
checkIfJoinKeyTypeMatches(
leftJoinKeyType,
context.getTypeProvider().getTableModelType(node.getCriteria().get(i).getRight()));
joinKeyTypes.add(leftJoinKeyType);
}

Expand Down Expand Up @@ -1525,11 +1525,9 @@ public Operator visitSemiJoin(SemiJoinNode node, LocalExecutionPlanContext conte

Type sourceJoinKeyType =
context.getTypeProvider().getTableModelType(node.getSourceJoinSymbol());

checkArgument(
sourceJoinKeyType
== context.getTypeProvider().getTableModelType(node.getFilteringSourceJoinSymbol()),
"Join key type mismatch.");
checkIfJoinKeyTypeMatches(
sourceJoinKeyType,
context.getTypeProvider().getTableModelType(node.getFilteringSourceJoinSymbol()));
OperatorContext operatorContext =
context
.getDriverContext()
Expand All @@ -1548,6 +1546,16 @@ public Operator visitSemiJoin(SemiJoinNode node, LocalExecutionPlanContext conte
dataTypes);
}

private void checkIfJoinKeyTypeMatches(Type leftJoinKeyType, Type rightJoinKeyType) {
if (leftJoinKeyType != rightJoinKeyType) {
throw new SemanticException(
"Join key type mismatch. Left join key type: "
+ leftJoinKeyType
+ ", right join key type: "
+ rightJoinKeyType);
}
}

@Override
public Operator visitEnforceSingleRow(
EnforceSingleRowNode node, LocalExecutionPlanContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public R visitJoin(
}

public R visitSemiJoin(SemiJoinNode node, C context) {
return visitPlan(node, context);
return visitTwoChildProcess(node, context);
}

public R visitGroupReference(GroupReference node, C context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Objects;

import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -124,6 +125,33 @@ public List<String> getOutputColumnNames() {
throw new UnsupportedOperationException();
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (obj == null || !this.getClass().equals(obj.getClass())) {
return false;
}

if (!super.equals(obj)) {
return false;
}

SemiJoinNode other = (SemiJoinNode) obj;

return Objects.equals(this.sourceJoinSymbol, other.sourceJoinSymbol)
&& Objects.equals(this.filteringSourceJoinSymbol, other.filteringSourceJoinSymbol)
&& Objects.equals(this.semiJoinOutput, other.semiJoinOutput);
}

@Override
public int hashCode() {
return Objects.hash(
super.hashCode(), sourceJoinSymbol, filteringSourceJoinSymbol, semiJoinOutput);
}

@Override
protected void serializeAttributes(ByteBuffer byteBuffer) {
PlanNodeType.TABLE_SEMI_JOIN_NODE.serialize(byteBuffer);
Expand Down

0 comments on commit b9dc058

Please sign in to comment.