Sh-Zh-7 commented on code in PR #15151:
URL: https://github.com/apache/iotdb/pull/15151#discussion_r2086380319
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LagFunction.java:
##########
@@ -63,13 +74,44 @@ public void transform(
} else {
builder.appendNull();
}
- } else if (defaultVal != null) {
- builder.writeObject(defaultVal);
+ } else if (defaultValChannel >= 0) {
+ writeDefaultValue(partition, defaultValChannel, index, builder);
} else {
builder.appendNull();
}
}
+ private void writeDefaultValue(
+ Partition partition, int defaultValChannel, int index, ColumnBuilder
builder) {
+ TSDataType dataType = builder.getDataType();
+ switch (dataType) {
+ case INT32:
+ case DATE:
+ builder.writeInt(partition.getInt(defaultValChannel, index));
+ return;
+ case INT64:
+ case TIMESTAMP:
+ builder.writeLong(partition.getLong(defaultValChannel, index));
+ return;
+ case FLOAT:
+ builder.writeFloat(partition.getFloat(defaultValChannel, index));
+ return;
+ case DOUBLE:
+ builder.writeDouble(partition.getDouble(defaultValChannel, index));
+ return;
+ case BOOLEAN:
+ builder.writeBoolean(partition.getBoolean(defaultValChannel, index));
+ return;
+ case TEXT:
+ case STRING:
Review Comment:
Done.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/window/function/value/LeadFunction.java:
##########
@@ -65,13 +75,44 @@ public void transform(
} else {
builder.appendNull();
}
- } else if (defaultVal != null) {
- builder.writeObject(defaultVal);
+ } else if (defaultValChannel >= 0) {
+ writeDefaultValue(partition, defaultValChannel, index, builder);
} else {
builder.appendNull();
}
}
+ private void writeDefaultValue(
+ Partition partition, int defaultValChannel, int index, ColumnBuilder
builder) {
+ TSDataType dataType = builder.getDataType();
+ switch (dataType) {
+ case INT32:
+ case DATE:
+ builder.writeInt(partition.getInt(defaultValChannel, index));
+ return;
+ case INT64:
+ case TIMESTAMP:
+ builder.writeLong(partition.getLong(defaultValChannel, index));
+ return;
+ case FLOAT:
+ builder.writeFloat(partition.getFloat(defaultValChannel, index));
+ return;
+ case DOUBLE:
+ builder.writeDouble(partition.getDouble(defaultValChannel, index));
+ return;
+ case BOOLEAN:
+ builder.writeBoolean(partition.getBoolean(defaultValChannel, index));
+ return;
+ case TEXT:
+ case STRING:
Review Comment:
Done.
--
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]