You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "xiangfu0 (via GitHub)" <gi...@apache.org> on 2023/03/16 09:48:40 UTC

[GitHub] [pinot] xiangfu0 opened a new pull request, #10434: [multistage] Support array type for select query

xiangfu0 opened a new pull request, #10434:
URL: https://github.com/apache/pinot/pull/10434

   Fix the schema conversion to support Array types for sql select.


-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] kishoreg commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "kishoreg (via GitHub)" <gi...@apache.org>.
kishoreg commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1144274769


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java:
##########
@@ -108,6 +107,18 @@ public void testQueryOptions()
         h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));
   }
 
+  @Test
+  public void testMultiValueColumnSelectionQuery()
+      throws Exception {
+    String pinotQuery =
+        "SELECT DivAirportIDs, DivAirports FROM mytable WHERE DATE_TIME_CONVERT(DaysSinceEpoch, '1:DAYS:EPOCH', "
+            + "'1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd''T''HH:mm:ss.SSS''Z''', '1:DAYS') = '2014-09-05T00:00:00.000Z'";
+    String h2Query =
+        "SELECT DivAirportIDs__MV0, DivAirports__MV0 FROM mytable WHERE DaysSinceEpoch = 16318 LIMIT 10000";
+    ClusterIntegrationTestUtils.testQueryWithMatchingRowCount(pinotQuery, _brokerBaseApiUrl, getPinotConnection(),
+        h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));

Review Comment:
   lets think about the behavior here.. lets keep implicit unnest on mv columns restricted to a single table and single level mv. with joins and windows lets make unnest explicit



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] siddharthteotia commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "siddharthteotia (via GitHub)" <gi...@apache.org>.
siddharthteotia commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1140976431


##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RelToStageConverter.java:
##########
@@ -151,34 +152,39 @@ private static DataSchema toDataSchema(RelDataType rowType) {
   }
 
   public static DataSchema.ColumnDataType convertToColumnDataType(RelDataType relDataType) {
-    switch (relDataType.getSqlTypeName()) {
+    SqlTypeName sqlTypeName = relDataType.getSqlTypeName();
+    boolean isArray = sqlTypeName == SqlTypeName.ARRAY;

Review Comment:
   Here we are equating our current support of MV with `SqlTypeName.ARRAY`. Is `SqlTypeName.ARRAY` extendible in future to help handle complex LIST (list that may not necessarily have primitives only) ?



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] siddharthteotia commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "siddharthteotia (via GitHub)" <gi...@apache.org>.
siddharthteotia commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1140975636


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java:
##########
@@ -108,6 +107,18 @@ public void testQueryOptions()
         h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));
   }
 
+  @Test
+  public void testMultiValueColumnSelectionQuery()
+      throws Exception {
+    String pinotQuery =
+        "SELECT DivAirportIDs, DivAirports FROM mytable WHERE DATE_TIME_CONVERT(DaysSinceEpoch, '1:DAYS:EPOCH', "
+            + "'1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd''T''HH:mm:ss.SSS''Z''', '1:DAYS') = '2014-09-05T00:00:00.000Z'";
+    String h2Query =
+        "SELECT DivAirportIDs__MV0, DivAirports__MV0 FROM mytable WHERE DaysSinceEpoch = 16318 LIMIT 10000";
+    ClusterIntegrationTestUtils.testQueryWithMatchingRowCount(pinotQuery, _brokerBaseApiUrl, getPinotConnection(),
+        h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));

Review Comment:
   For multi stage, are we not keeping the implicit unnest behavior of MV columns when used in GROUP BY ?
   
   



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] kishoreg commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "kishoreg (via GitHub)" <gi...@apache.org>.
kishoreg commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1144274769


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java:
##########
@@ -108,6 +107,18 @@ public void testQueryOptions()
         h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));
   }
 
+  @Test
+  public void testMultiValueColumnSelectionQuery()
+      throws Exception {
+    String pinotQuery =
+        "SELECT DivAirportIDs, DivAirports FROM mytable WHERE DATE_TIME_CONVERT(DaysSinceEpoch, '1:DAYS:EPOCH', "
+            + "'1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd''T''HH:mm:ss.SSS''Z''', '1:DAYS') = '2014-09-05T00:00:00.000Z'";
+    String h2Query =
+        "SELECT DivAirportIDs__MV0, DivAirports__MV0 FROM mytable WHERE DaysSinceEpoch = 16318 LIMIT 10000";
+    ClusterIntegrationTestUtils.testQueryWithMatchingRowCount(pinotQuery, _brokerBaseApiUrl, getPinotConnection(),
+        h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));

Review Comment:
   lets think about the behavior here.. one option I can think of is to keep implicit unnest on mv columns restricted to a single table and single level mv. with joins and windows we make unnest/cross join a requirement to flatten the array column



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "walterddr (via GitHub)" <gi...@apache.org>.
walterddr commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1140627280


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java:
##########
@@ -108,6 +107,18 @@ public void testQueryOptions()
         h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));
   }
 
+  @Test
+  public void testMultiValueColumnSelectionQuery()
+      throws Exception {
+    String pinotQuery =
+        "SELECT DivAirportIDs, DivAirports FROM mytable WHERE DATE_TIME_CONVERT(DaysSinceEpoch, '1:DAYS:EPOCH', "
+            + "'1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd''T''HH:mm:ss.SSS''Z''', '1:DAYS') = '2014-09-05T00:00:00.000Z'";
+    String h2Query =
+        "SELECT DivAirportIDs__MV0, DivAirports__MV0 FROM mytable WHERE DaysSinceEpoch = 16318 LIMIT 10000";
+    ClusterIntegrationTestUtils.testQueryWithMatchingRowCount(pinotQuery, _brokerBaseApiUrl, getPinotConnection(),
+        h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));

Review Comment:
   i don't think we need integration test for this. we can simply add a test case in `pinot-query-runtime/src/test/resources/` 
   but good to have this.



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "walterddr (via GitHub)" <gi...@apache.org>.
walterddr commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1140628979


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java:
##########
@@ -108,6 +107,18 @@ public void testQueryOptions()
         h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));
   }
 
+  @Test
+  public void testMultiValueColumnSelectionQuery()
+      throws Exception {
+    String pinotQuery =
+        "SELECT DivAirportIDs, DivAirports FROM mytable WHERE DATE_TIME_CONVERT(DaysSinceEpoch, '1:DAYS:EPOCH', "
+            + "'1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd''T''HH:mm:ss.SSS''Z''', '1:DAYS') = '2014-09-05T00:00:00.000Z'";
+    String h2Query =
+        "SELECT DivAirportIDs__MV0, DivAirports__MV0 FROM mytable WHERE DaysSinceEpoch = 16318 LIMIT 10000";
+    ClusterIntegrationTestUtils.testQueryWithMatchingRowCount(pinotQuery, _brokerBaseApiUrl, getPinotConnection(),
+        h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));

Review Comment:
   i am not sure this counts are full support and will cause issue. for example if we do a group-by query. the behavior will be drastically different between
   ```
   SELECT mvCol, count(*) FROM tbl GROUP BY mvCol  -- this will still behave as unnest
   SELECT mvCol, count(*) FROM tblA JOIN tblB USING(key) GROUP BY mvCol  -- this will use the entire array as group
   ```
   also the ordering of a group is not guaranteed --> maybe we are better off creating a ARRAY type in V1 that MV column can extend from. 



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] xiangfu0 commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1142744672


##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RelToStageConverter.java:
##########
@@ -151,34 +152,39 @@ private static DataSchema toDataSchema(RelDataType rowType) {
   }
 
   public static DataSchema.ColumnDataType convertToColumnDataType(RelDataType relDataType) {
-    switch (relDataType.getSqlTypeName()) {
+    SqlTypeName sqlTypeName = relDataType.getSqlTypeName();
+    boolean isArray = sqlTypeName == SqlTypeName.ARRAY;

Review Comment:
   From what I've read from here: https://calcite.apache.org/javadocAggregate/org/apache/calcite/sql/type/SqlTypeName.html
   Seems Array is the type.
   
   For future extensibility, we can make this call recursive to construct the recursive DataType for Complex/nest data structure.
   



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] xiangfu0 merged pull request #10434: [multistage] Support array type for select query

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 merged PR #10434:
URL: https://github.com/apache/pinot/pull/10434


-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] xiangfu0 commented on a diff in pull request #10434: [multistage] Support array type for select query

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on code in PR #10434:
URL: https://github.com/apache/pinot/pull/10434#discussion_r1141048046


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java:
##########
@@ -108,6 +107,18 @@ public void testQueryOptions()
         h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));
   }
 
+  @Test
+  public void testMultiValueColumnSelectionQuery()
+      throws Exception {
+    String pinotQuery =
+        "SELECT DivAirportIDs, DivAirports FROM mytable WHERE DATE_TIME_CONVERT(DaysSinceEpoch, '1:DAYS:EPOCH', "
+            + "'1:DAYS:SIMPLE_DATE_FORMAT:yyyy-MM-dd''T''HH:mm:ss.SSS''Z''', '1:DAYS') = '2014-09-05T00:00:00.000Z'";
+    String h2Query =
+        "SELECT DivAirportIDs__MV0, DivAirports__MV0 FROM mytable WHERE DaysSinceEpoch = 16318 LIMIT 10000";
+    ClusterIntegrationTestUtils.testQueryWithMatchingRowCount(pinotQuery, _brokerBaseApiUrl, getPinotConnection(),
+        h2Query, getH2Connection(), null, ImmutableMap.of("queryOptions", "useMultistageEngine=true"));

Review Comment:
   For simple group by, it's pushed down to v1 engine, so the behavior is same as v1. 
   
   I think we need to support group by array in v1 then rewrite the query from v2.



-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] codecov-commenter commented on pull request #10434: [multistage] Support array type for select query

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #10434:
URL: https://github.com/apache/pinot/pull/10434#issuecomment-1471719530

   ## [Codecov](https://codecov.io/gh/apache/pinot/pull/10434?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#10434](https://codecov.io/gh/apache/pinot/pull/10434?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (60ba5aa) into [master](https://codecov.io/gh/apache/pinot/commit/0362ad369db15b696b733038d16f3a129585b660?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0362ad3) will **increase** coverage by `33.17%`.
   > The diff coverage is `6.45%`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             master   #10434       +/-   ##
   =============================================
   + Coverage     35.14%   68.32%   +33.17%     
   - Complexity      282     6096     +5814     
   =============================================
     Files          2053     2053               
     Lines        111402   111418       +16     
     Branches      16940    16960       +20     
   =============================================
   + Hits          39157    76124    +36967     
   + Misses        68835    29841    -38994     
   - Partials       3410     5453     +2043     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration1 | `24.35% <0.00%> (-0.12%)` | :arrow_down: |
   | integration2 | `?` | |
   | unittests1 | `67.96% <6.45%> (?)` | |
   | unittests2 | `13.84% <0.00%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/pinot/pull/10434?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../java/org/apache/pinot/query/type/TypeFactory.java](https://codecov.io/gh/apache/pinot/pull/10434?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcXVlcnktcGxhbm5lci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvdHlwZS9UeXBlRmFjdG9yeS5qYXZh) | `25.92% <0.00%> (+25.92%)` | :arrow_up: |
   | [...not/query/planner/logical/RelToStageConverter.java](https://codecov.io/gh/apache/pinot/pull/10434?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtcXVlcnktcGxhbm5lci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcGxhbm5lci9sb2dpY2FsL1JlbFRvU3RhZ2VDb252ZXJ0ZXIuamF2YQ==) | `75.00% <15.38%> (+75.00%)` | :arrow_up: |
   
   ... and [1260 files with indirect coverage changes](https://codecov.io/gh/apache/pinot/pull/10434/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] xiangfu0 commented on pull request #10434: [multistage] Support array type for select query

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on PR #10434:
URL: https://github.com/apache/pinot/pull/10434#issuecomment-1472814200

   > the change looks good.
   > 
   > can we add some tests on both planner and runtime?
   
   Added tests


-- 
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-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org