Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](source) fix projection and function pushdown not functioning correctly #383

Merged
merged 11 commits into from
May 11, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ public ChangelogMode getChangelogMode() {

@Override
public ScanRuntimeProvider getScanRuntimeProvider(ScanContext runtimeProviderContext) {
if (StringUtils.isNullOrWhitespaceOnly(readOptions.getFilterQuery())) {
String filterQuery = resolvedFilterQuery.stream().collect(Collectors.joining(" AND "));
readOptions.setFilterQuery(filterQuery);
}
if (StringUtils.isNullOrWhitespaceOnly(readOptions.getReadFields())) {
String[] selectFields =
DataType.getFieldNames(physicalRowDataType).toArray(new String[0]);
readOptions.setReadFields(
Arrays.stream(selectFields)
.map(item -> String.format("`%s`", item.trim().replace("`", "")))
.collect(Collectors.joining(", ")));
}

if (readOptions.getUseOldApi()) {
List<PartitionDefinition> dorisPartitions;
Expand Down Expand Up @@ -212,5 +200,17 @@ public boolean supportsNestedProjection() {
@Override
public void applyProjection(int[][] projectedFields, DataType producedDataType) {
this.physicalRowDataType = Projection.of(projectedFields).project(physicalRowDataType);
if (StringUtils.isNullOrWhitespaceOnly(readOptions.getFilterQuery())) {
String filterQuery = resolvedFilterQuery.stream().collect(Collectors.joining(" AND "));
this.readOptions.setFilterQuery(filterQuery);
}
if (StringUtils.isNullOrWhitespaceOnly(readOptions.getReadFields())) {
String[] selectFields =
DataType.getFieldNames(physicalRowDataType).toArray(new String[0]);
this.readOptions.setReadFields(
Arrays.stream(selectFields)
.map(item -> String.format("`%s`", item.trim().replace("`", "")))
.collect(Collectors.joining(", ")));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the benefits of putting it below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method getScanRuntimeProvider is executed before applyProjection. Therefore, initializing readFields in getScanRuntimeProvider will result in querying all fields in Doris, leading to type conversion errors.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ public String visit(CallExpression call) {
if (BuiltInFunctionDefinitions.IS_NOT_NULL.equals(call.getFunctionDefinition())) {
return combineLeftExpression("IS NOT NULL", call.getResolvedChildren().get(0));
}

if (BuiltInFunctionDefinitions.PLUS.equals(call.getFunctionDefinition())) {
return combineExpression("+", call.getResolvedChildren());
}

if (BuiltInFunctionDefinitions.DIVIDE.equals(call.getFunctionDefinition())) {
return combineExpression("/", call.getResolvedChildren());
}

if (BuiltInFunctionDefinitions.BETWEEN.equals(call.getFunctionDefinition())) {
return combineExpression("between", call.getResolvedChildren());
}

if (BuiltInFunctionDefinitions.CAST.equals(call.getFunctionDefinition())) {
return call.getChildren().get(0).accept(this);
}
return null;
}

Expand Down