LakshSingla commented on code in PR #14981:
URL: https://github.com/apache/druid/pull/14981#discussion_r1326471200


##########
extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/MSQFaultsTest.java:
##########
@@ -356,4 +359,44 @@ public void testTooManyInputFiles() throws IOException
         .setExpectedMSQFault(new TooManyInputFilesFault(numFiles, 
Limits.MAX_INPUT_FILES_PER_WORKER, 2))
         .verifyResults();
   }
+
+  @Test
+  public void testUnionAllIsDisallowed()
+  {
+    final RowSignature rowSignature =
+        RowSignature.builder().add("__time", ColumnType.LONG).build();
+    testIngestQuery()
+        .setSql("SELECT * FROM foo\n"
+                + "UNION ALL\n"
+                + "SELECT * FROM foo\n")
+        .setExpectedRowSignature(rowSignature)
+        .setExpectedDataSource("foo1")
+        .setExpectedMSQFault(QueryNotSupportedFault.instance())
+        .verifyResults();
+  }
+
+  @Test
+  public void testUnionAllIsDisallowedWhilePlanning()
+  {
+    // This results in a planning error however the planning error isn't an 
accurate representation of the actual error
+    // because Calcite rewrites it using CoreRules.UNION_TO_DISTINCT, which 
plans it using Union Datasource.
+    // However, this fails since the column names mismatch. Once MSQ is able 
to support Union datasources, the planning
+    // error would become an accurate representation of the error.
+    testIngestQuery()
+        .setSql(
+            "INSERT INTO druid.dst "
+            + "SELECT dim2, dim1, m1 FROM foo2 "
+            + "UNION ALL "
+            + "SELECT dim1, dim2, m1 FROM foo "
+            + "PARTITIONED BY ALL TIME")
+        .setExpectedValidationErrorMatcher(
+            new DruidExceptionMatcher(
+                DruidException.Persona.ADMIN,
+                DruidException.Category.INVALID_INPUT,
+                "general"
+            ).expectMessageIs("Query planning failed for unknown reason, our 
best guess is this "

Review Comment:
   It tries to plan the query using the 
[UnionDataSourceRule](https://github.com/apache/druid/blob/master/sql/src/main/java/org/apache/druid/sql/calcite/rule/DruidUnionDataSourceRule.java),
 goes into the `isCompatible` then, and then rewrites the already set planning 
error. 
   This gets executed using `UnionDataSourceRule` since the column names match, 
`isCompatible` returns and not the top-level union all. 



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to