You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2022/06/28 10:57:55 UTC
[GitHub] [drill] luocooong opened a new pull request, #2580: DRILL-8253: Support the limit results in kafka scan
luocooong opened a new pull request, #2580:
URL: https://github.com/apache/drill/pull/2580
# [DRILL-8253](https://issues.apache.org/jira/browse/DRILL-8253): Support the limit results in kafka scan
## Description
In the current implementation of the kafka storage, although we use the limit detection method in the result loader, but the actual `maxRecords` is always -1.
The mechanism for this revision is to get limit (SQL parsing from the execution plan stage) from the group scan, then pass it to the sub-scan, and finally process it in the result loader.
## Documentation
N/A
## Testing
Added the unit test. KafkaQueriesTest#testResultLimit()
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] cgivre merged pull request #2580: DRILL-8253: Support Limit Results in Kafka Scan
Posted by GitBox <gi...@apache.org>.
cgivre merged PR #2580:
URL: https://github.com/apache/drill/pull/2580
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] cgivre commented on a diff in pull request #2580: DRILL-8253: Support the limit results in kafka scan
Posted by GitBox <gi...@apache.org>.
cgivre commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908416571
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -262,6 +269,17 @@ public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) {
assignments = AssignmentCreator.getMappings(incomingEndpoints, Lists.newArrayList(partitionWorkMap.values()));
}
+ @Override
+ public GroupScan applyLimit(int maxRecords) {
+ records = maxRecords; // Just apply the limit value into sub-scan
+ return super.applyLimit(maxRecords);
+ }
+
Review Comment:
I'm fairly certain this isn't actually working. The super method always returns `null`.
https://github.com/apache/drill/blob/53e6f2697b31cb76a38e75fe95283512715d28c3/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/AbstractGroupScan.java#L174-L178
What I think you need to do here is:
1. Create a clone constructor in the `KafkaGroupScan`
2. Call that and return a new `KafkaGroupScan` with the limit applied.
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -77,6 +77,7 @@ public class KafkaGroupScan extends AbstractGroupScan {
private final KafkaScanSpec kafkaScanSpec;
private List<SchemaPath> columns;
+ private int records;
Review Comment:
These variables should all be `final`.
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -359,7 +382,7 @@ public KafkaStoragePlugin getStoragePlugin() {
@Override
public String toString() {
- return String.format("KafkaGroupScan [KafkaScanSpec=%s, columns=%s]", kafkaScanSpec, columns);
+ return String.format("KafkaGroupScan [KafkaScanSpec=%s, columns=%s, records=%d]", kafkaScanSpec, columns, records);
Review Comment:
Could we use the `PlanStringBuilder` here?
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] luocooong commented on a diff in pull request #2580: DRILL-8253: Support the limit results in kafka scan
Posted by GitBox <gi...@apache.org>.
luocooong commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908624939
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -262,6 +269,17 @@ public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) {
assignments = AssignmentCreator.getMappings(incomingEndpoints, Lists.newArrayList(partitionWorkMap.values()));
}
+ @Override
+ public GroupScan applyLimit(int maxRecords) {
+ records = maxRecords; // Just apply the limit value into sub-scan
+ return super.applyLimit(maxRecords);
+ }
+
Review Comment:
Follow your suggestion, create the immutable groupscan always.
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] luocooong commented on a diff in pull request #2580: DRILL-8253: Support the limit results in kafka scan
Posted by GitBox <gi...@apache.org>.
luocooong commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908438483
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -77,6 +77,7 @@ public class KafkaGroupScan extends AbstractGroupScan {
private final KafkaScanSpec kafkaScanSpec;
private List<SchemaPath> columns;
+ private int records;
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] cgivre commented on a diff in pull request #2580: DRILL-8253: Support the limit results in kafka scan
Posted by GitBox <gi...@apache.org>.
cgivre commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908624673
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -271,8 +292,11 @@ public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) {
@Override
public GroupScan applyLimit(int maxRecords) {
- records = maxRecords; // Just apply the limit value into sub-scan
- return super.applyLimit(maxRecords);
+ if (maxRecords > records) { // pass the limit value into sub-scan
+ return new KafkaGroupScan(this, maxRecords);
+ } else { // stop the transform
+ return super.applyLimit(maxRecords);
Review Comment:
Do we still need to call the `super` method here? Could we just return `null`?
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] luocooong commented on a diff in pull request #2580: DRILL-8253: Support the limit results in kafka scan
Posted by GitBox <gi...@apache.org>.
luocooong commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908438074
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -262,6 +269,17 @@ public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) {
assignments = AssignmentCreator.getMappings(incomingEndpoints, Lists.newArrayList(partitionWorkMap.values()));
}
+ @Override
+ public GroupScan applyLimit(int maxRecords) {
+ records = maxRecords; // Just apply the limit value into sub-scan
+ return super.applyLimit(maxRecords);
+ }
+
Review Comment:
Yes, I'm just call this parent interface that returns null (As long as the default behavior is not broken), because I just need to get the limit value from the execution plan.
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] luocooong commented on a diff in pull request #2580: DRILL-8253: Support the limit results in kafka scan
Posted by GitBox <gi...@apache.org>.
luocooong commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908439009
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -359,7 +382,7 @@ public KafkaStoragePlugin getStoragePlugin() {
@Override
public String toString() {
- return String.format("KafkaGroupScan [KafkaScanSpec=%s, columns=%s]", kafkaScanSpec, columns);
+ return String.format("KafkaGroupScan [KafkaScanSpec=%s, columns=%s, records=%d]", kafkaScanSpec, columns, records);
Review Comment:
Good idea, thanks!
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] cgivre commented on a diff in pull request #2580: DRILL-8253: Support the limit results in kafka scan
Posted by GitBox <gi...@apache.org>.
cgivre commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908569894
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -262,6 +269,17 @@ public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) {
assignments = AssignmentCreator.getMappings(incomingEndpoints, Lists.newArrayList(partitionWorkMap.values()));
}
+ @Override
+ public GroupScan applyLimit(int maxRecords) {
+ records = maxRecords; // Just apply the limit value into sub-scan
+ return super.applyLimit(maxRecords);
+ }
+
Review Comment:
I wouldn't recommend that. My understanding of how all this works is that Calcite/Drill create multiple copies of the GroupScan to try to find the optimal query plan. The GroupScans have to be immutable otherwise strange things will happen when you execute more complex queries, and in all likelihood, the limit won't be pushed down.
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [drill] luocooong commented on a diff in pull request #2580: DRILL-8253: Support Limit Results in Kafka Scan
Posted by GitBox <gi...@apache.org>.
luocooong commented on code in PR #2580:
URL: https://github.com/apache/drill/pull/2580#discussion_r908637682
##########
contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaGroupScan.java:
##########
@@ -271,8 +292,11 @@ public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) {
@Override
public GroupScan applyLimit(int maxRecords) {
- records = maxRecords; // Just apply the limit value into sub-scan
- return super.applyLimit(maxRecords);
+ if (maxRecords > records) { // pass the limit value into sub-scan
+ return new KafkaGroupScan(this, maxRecords);
+ } else { // stop the transform
+ return super.applyLimit(maxRecords);
Review Comment:
Can be returned null directly.
--
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: dev-unsubscribe@drill.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org