Re: [PR] Adding unnest tests for join precedence when using multiple joins tog… (druid)

2024-03-31 Thread via GitHub


github-actions[bot] closed pull request #14969: Adding unnest tests for join 
precedence when using multiple joins tog…
URL: https://github.com/apache/druid/pull/14969


-- 
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: commits-unsubscr...@druid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



Re: [PR] Adding unnest tests for join precedence when using multiple joins tog… (druid)

2024-03-31 Thread via GitHub


github-actions[bot] commented on PR #14969:
URL: https://github.com/apache/druid/pull/14969#issuecomment-2028963110

   This pull request/issue has been closed due to lack of activity. If you 
think that
   is incorrect, or the pull request requires review, you can revive the PR at 
any time.


-- 
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: commits-unsubscr...@druid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



Re: [PR] Adding unnest tests for join precedence when using multiple joins tog… (druid)

2024-03-03 Thread via GitHub


github-actions[bot] commented on PR #14969:
URL: https://github.com/apache/druid/pull/14969#issuecomment-1975419448

   This pull request has been marked as stale due to 60 days of inactivity.
   It will be closed in 4 weeks if no further activity occurs. If you think
   that's incorrect or this pull request should instead be reviewed, please 
simply
   write any comment. Even if closed, you can still revive the PR at any time or
   discuss it on the d...@druid.apache.org list.
   Thank you for your contributions.


-- 
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: commits-unsubscr...@druid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



Re: [PR] Adding unnest tests for join precedence when using multiple joins tog… (druid)

2023-09-12 Thread via GitHub


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


##
sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java:
##
@@ -4807,4 +4808,187 @@ public void 
testUnnestWithGroupByHavingWithWhereOnUnnestCol()
 )
 );
   }
+
+  @Test
+  public void testUnnestWithCommaButHigherPrecedenceJoinLaterAlongWithAlias()
+  {
+// CROSS JOIN has a higher precedence over COMMA JOIN
+// CALCITE would interpret this as
+// (foo t1) COMMA JOIN (UNNEST(t1.dim3) CROSS JOIN foo t2)
+// while validating the right, parser does not understand t1.dim3
+// will throw a table not found validation error
+expectedException.expect(DruidException.class);
+expectedException.expectMessage("Table 't1' not found (line [2], column 
[34])");
+testQuery(
+"select c1 from \n"
++ "druid.foo t1, unnest(mv_to_array(t1.dim3)) as u1(c1) CROSS JOIN 
druid.foo t2 \n",
+QUERY_CONTEXT_UNNEST,
+ImmutableList.of(),
+ImmutableList.of()
+);
+  }
+
+  @Test
+  public void testUnnestWithCrossJoinEarlierToEnforcePrecedence()
+  {
+testQuery(
+"select c1 from \n"
++ "druid.foo CROSS JOIN unnest(mv_to_array(dim3)) as u1(c1) CROSS JOIN 
druid.foo t2 \n",
+QUERY_CONTEXT_UNNEST,
+ImmutableList.of(
+Druids.newScanQueryBuilder()
+  .dataSource(
+  join(
+  new QueryDataSource(
+  Druids.newScanQueryBuilder()
+.dataSource(
+UnnestDataSource.create(
+new 
TableDataSource(CalciteTests.DATASOURCE1),
+
expressionVirtualColumn("j0.unnest", "\"dim3\"", ColumnType.STRING),
+null
+)
+)
+
.intervals(querySegmentSpec(Filtration.eternity()))
+
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
+.legacy(false)
+.columns(
+"__time",
+"cnt",
+"dim1",
+"dim2",
+"dim3",
+"j0.unnest",
+"m1",
+"m2",
+"unique_dim1"
+)
+.context(QUERY_CONTEXT_UNNEST)
+.build()
+  ),
+  new QueryDataSource(
+  Druids.newScanQueryBuilder()
+.dataSource(new 
TableDataSource(CalciteTests.DATASOURCE1))
+
.intervals(querySegmentSpec(Filtration.eternity()))
+
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
+.legacy(false)
+.context(QUERY_CONTEXT_UNNEST)
+.columns("__time", "cnt", "dim1", "dim2", 
"dim3", "m1", "m2", "unique_dim1")
+.build()
+  ),
+  "_j0.",
+  "1",
+  JoinType.INNER,
+  null
+  )
+  )
+  .intervals(querySegmentSpec(Filtration.eternity()))
+  
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
+  .legacy(false)
+  .columns("j0.unnest")
+  .context(QUERY_CONTEXT_UNNEST)
+  .build()
+),
+NullHandling.sqlCompatible() ?
+ImmutableList.of(
+new Object[]{"a"},
+new Object[]{"a"},
+new Object[]{"a"},
+new Object[]{"a"},
+new Object[]{"a"},
+new Object[]{"a"},

Review Comment:
   Refactoring comment - We should use a loop or a method that supports adding 
multiple elements at a single time.
   
   I think one of the concise approach can be something like:
   ```java
   ImmutableList.Builder resultsBuilder = ImmutableList.builder();
   resultsBuilder.addAll(Collections.nCopies(6, new Object[]{"a"}));
   resultsBuilder.addAll(Collections.nCopies(12, new Object[]{"b"}));
   
   resultsBuilder.addAll(Collections.nCopies(12, new 
Object[]{NullHandling.defaultStringValue()}));
   
   
   ```