You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by cg...@apache.org on 2021/11/12 12:58:51 UTC

[drill] branch master updated: DRILL-8042: Select star from MongoDB with aggregated pipeline fails with empty $project error (#2369)

This is an automated email from the ASF dual-hosted git repository.

cgivre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new 433fab2  DRILL-8042: Select star from MongoDB with aggregated pipeline fails with empty $project error (#2369)
433fab2 is described below

commit 433fab26aca7c87ce5e2de0e84b91800544f6af6
Author: Volodymyr Vysotskyi <vv...@gmail.com>
AuthorDate: Fri Nov 12 14:58:40 2021 +0200

    DRILL-8042: Select star from MongoDB with aggregated pipeline fails with empty $project error (#2369)
---
 .../org/apache/drill/exec/store/mongo/MongoRecordReader.java     | 4 +++-
 .../apache/drill/exec/store/mongo/plan/RexToMongoTranslator.java | 2 +-
 .../apache/drill/exec/store/mongo/TestMongoLimitPushDown.java    | 9 +++++++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java
index a26a98a..5ca1358 100644
--- a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java
+++ b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java
@@ -188,7 +188,9 @@ public class MongoRecordReader extends AbstractRecordReader {
       MongoIterable<BsonDocument> projection;
       if (CollectionUtils.isNotEmpty(operations)) {
         List<Bson> operations = new ArrayList<>(this.operations);
-        operations.add(Aggregates.project(fields));
+        if (!fields.isEmpty()) {
+          operations.add(Aggregates.project(fields));
+        }
         projection = collection.aggregate(operations);
       } else {
         projection = collection.find(filters).projection(fields);
diff --git a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/plan/RexToMongoTranslator.java b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/plan/RexToMongoTranslator.java
index cc97c82..a1e9f64 100644
--- a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/plan/RexToMongoTranslator.java
+++ b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/plan/RexToMongoTranslator.java
@@ -219,7 +219,7 @@ class RexToMongoTranslator extends RexVisitorImpl<BsonValue> {
 
     @Override
     public Boolean visitInputRef(RexInputRef inputRef) {
-      return true;
+      return inputRef.getType().getSqlTypeName() != SqlTypeName.DYNAMIC_STAR;
     }
 
     @Override
diff --git a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoLimitPushDown.java b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoLimitPushDown.java
index 2344df7..e75c3f9 100644
--- a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoLimitPushDown.java
+++ b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoLimitPushDown.java
@@ -69,4 +69,13 @@ public class TestMongoLimitPushDown extends MongoTestBase {
       .include("\"\\$limit\": 4", "\"\\$eq\": 52\\.17")
       .match();
   }
+
+  @Test
+  public void testSelectStarWithLimit() throws Exception {
+    testBuilder()
+      .sqlQuery("SELECT * FROM mongo.employee.`empinfo` LIMIT 4")
+      .unOrdered()
+      .expectsNumRecords(4)
+      .go();
+  }
 }