You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "somu-imply (via GitHub)" <gi...@apache.org> on 2024/02/14 18:28:59 UTC
[PR] Handling recursive NVLs with convertlet (druid)
somu-imply opened a new pull request, #15906:
URL: https://github.com/apache/druid/pull/15906
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
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@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Handling recursive NVLs with convertlet (druid)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15906:
URL: https://github.com/apache/druid/pull/15906#issuecomment-2054453285
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 dev@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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Handling recursive NVLs with convertlet (druid)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15906:
URL: https://github.com/apache/druid/pull/15906#issuecomment-2109040447
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Handling recursive NVLs with convertlet (druid)
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #15906:
URL: https://github.com/apache/druid/pull/15906#discussion_r1489929708
##########
sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/DruidNVLOperatorConversion.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.sql.calcite.expression.builtin;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlTypeTransforms;
+import org.apache.calcite.sql2rel.SqlRexContext;
+import org.apache.calcite.sql2rel.SqlRexConvertlet;
+import org.apache.druid.query.filter.DimFilter;
+import org.apache.druid.segment.column.RowSignature;
+import org.apache.druid.sql.calcite.planner.PlannerContext;
+import org.apache.druid.sql.calcite.planner.convertlet.DruidConvertletFactory;
+import org.apache.druid.sql.calcite.rel.VirtualColumnRegistry;
+
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DruidNVLOperatorConversion extends CoalesceOperatorConversion
+ implements DruidConvertletFactory, SqlRexConvertlet
+{
+ private static final SqlFunction OPERATOR = new SqlNVLFunction();
+
+ public static class SqlNVLFunction extends SqlFunction
+ {
+
+ public SqlNVLFunction()
+ {
+ super(
+ "NVL",
+ SqlKind.OTHER_FUNCTION,
+ ReturnTypes.LEAST_RESTRICTIVE
+ .andThen(SqlTypeTransforms.TO_NULLABLE_ALL),
+ null,
+ OperandTypes.SAME_SAME,
+ SqlFunctionCategory.SYSTEM
+ );
+ }
+ }
+
+ public static final DruidNVLOperatorConversion INSTANCE = new DruidNVLOperatorConversion();
+
+ public DruidNVLOperatorConversion()
+ {
+ super(OPERATOR);
+ }
+
+ @Override
+ public SqlRexConvertlet createConvertlet(PlannerContext plannerContext)
+ {
+ return this;
+ }
+
+ @Override
+ public RexNode convertCall(final SqlRexContext cx, final SqlCall call)
+ {
+
+ final RexBuilder rexBuilder = cx.getRexBuilder();
+ final List<RexNode> newArgs = new ArrayList<RexNode>();
+ for (SqlNode node : call.getOperandList()) {
+ newArgs.add(cx.convertExpression(node));
+ }
+ return rexBuilder.makeCall(OPERATOR, newArgs);
+ }
+
+ @Override
+ public List<SqlOperator> operators()
+ {
+ return ImmutableList.of(calciteOperator());
+ }
+
+ @Nullable
+ @Override
+ public DimFilter toDruidFilter(
+ PlannerContext plannerContext,
+ RowSignature rowSignature,
+ @Nullable VirtualColumnRegistry virtualColumnRegistry,
+ RexNode rexNode)
+ {
+ final List<RexNode> operands = ((RexCall) rexNode).getOperands();
Review Comment:
## Unread local variable
Variable 'List<RexNode> operands' is never read.
[Show more details](https://github.com/apache/druid/security/code-scanning/6571)
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java:
##########
@@ -15292,4 +15292,88 @@
)
.run();
}
+
+ @Test
+ public void testNVLColumns()
Review Comment:
## Confusing method names because of capitalization
The method 'testNVLColumns' may be confused with [testNvlColumns](1).
[Show more details](https://github.com/apache/druid/security/code-scanning/6572)
--
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@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Handling recursive NVLs with convertlet (druid)
Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #15906:
URL: https://github.com/apache/druid/pull/15906#discussion_r1490212218
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteMultiValueStringQueryTest.java:
##########
@@ -2115,8 +2115,10 @@ public void testMultiValueStringOverlapFilterCoalesceNvl()
queryFramework().macroTable()
)
)
- .filters(expressionFilter(
- "array_overlap(nvl(mv_to_array(\"dim3\"),array('other')),array('a','b','other'))"))
+ .filters(or(
+ expressionFilter("array_overlap(nvl(mv_to_array(\"dim3\"),array('other')),array('a','b','other'))"),
+ expressionFilter("array_overlap(nvl(mv_to_array(\"dim3\"),array('other')),array('a','b','other'))")
Review Comment:
this is weird as 2 same things are ORed, will revisit
--
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@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Handling recursive NVLs with convertlet (druid)
Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #15906:
URL: https://github.com/apache/druid/pull/15906#discussion_r1490212218
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteMultiValueStringQueryTest.java:
##########
@@ -2115,8 +2115,10 @@ public void testMultiValueStringOverlapFilterCoalesceNvl()
queryFramework().macroTable()
)
)
- .filters(expressionFilter(
- "array_overlap(nvl(mv_to_array(\"dim3\"),array('other')),array('a','b','other'))"))
+ .filters(or(
+ expressionFilter("array_overlap(nvl(mv_to_array(\"dim3\"),array('other')),array('a','b','other'))"),
+ expressionFilter("array_overlap(nvl(mv_to_array(\"dim3\"),array('other')),array('a','b','other'))")
Review Comment:
this is weird as 2 same things are ORed
--
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@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Handling recursive NVLs with convertlet (druid)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #15906: Handling recursive NVLs with convertlet
URL: https://github.com/apache/druid/pull/15906
--
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@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org