You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "Manya0407 (via GitHub)" <gi...@apache.org> on 2026/07/20 06:53:18 UTC
[PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Manya0407 opened a new pull request, #6616:
URL: https://github.com/apache/hive/pull/6616
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
3. Ensure you have added or run the appropriate tests for your PR:
4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX: Your PR title ...'.
5. Be sure to keep the PR description updated to reflect all changes.
6. Please write your PR title to summarize what this PR proposes.
7. If possible, provide a concise example to reproduce the issue for a faster review.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description, screenshot and/or a reproducable example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Hive versions or within the unreleased branches such as master.
If no, write 'No'.
-->
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "Manya0407 (via GitHub)" <gi...@apache.org>.
Manya0407 commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3637255072
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrimScalarCol.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import java.util.Arrays;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized LTRIM with a scalar string and a trim-characters column.
+ */
+public class StringLTrimScalarCol extends VectorExpression {
Review Comment:
StringUnaryUDFDirect is for unary expressions with a single column input (e.g. StringTrimCol, StringTrimColScalar). The *ScalarCol classes are binary SCALAR + COLUMN expressions: a fixed scalar string plus a per-row trim-characters column. That operand pattern doesn’t match the unary base class API.
For SCALAR + COLUMN, the existing precedent in Hive is StringScalarConcatStringGroupCol, which also extends VectorExpression directly and implements its own evaluate() loop. We followed the same approach for StringTrimScalarCol, StringLTrimScalarCol, and StringRTrimScalarCol.
COL + SCALAR (trim(col, 'xy')) already uses StringTrimColScalarBase → StringUnaryUDFDirect. COL + COLUMN uses NullUtil.propagateNullsColCol in the ColCol classes.
I can extract a shared base for the three *ScalarCol classes if you’d prefer less duplication in evaluate(), but extending StringUnaryUDFDirect wouldn’t be the right fit for this operand pattern.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6616:
URL: https://github.com/apache/hive/pull/6616#issuecomment-5088138427
## [](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6616) **Quality Gate passed**
Issues
 [19 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6616&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6616&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6616&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6616&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6616&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6616)
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "kasakrisz (via GitHub)" <gi...@apache.org>.
kasakrisz commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3645414647
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrimScalarCol.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import java.util.Arrays;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized LTRIM with a scalar string and a trim-characters column.
+ */
+public class StringLTrimScalarCol extends VectorExpression {
Review Comment:
> That operand pattern doesn’t match the unary base class API.
Do you mean that the implementation for processing the new trim function calls with SCALAR + COLUMN expression arguments would be different from the one in `StringUnaryUDFDirect` or `StringUnaryUDF`?
If that is the case, it still makes sense to extract the duplicated code. So please go ahead.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "kasakrisz (via GitHub)" <gi...@apache.org>.
kasakrisz commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3636809363
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringTrimColScalarBase.java:
##########
@@ -43,14 +44,75 @@ public StringTrimColScalarBase() {
}
protected boolean shouldTrim(int character) {
- for (int i = 0; i < trimChars.length; ++i) {
- if (trimChars[i] == character) {
+ return shouldTrimByte((byte) character, trimChars, 0, trimChars.length);
+ }
+
+ static boolean shouldTrimByte(byte character, byte[] trimBytes, int trimStart, int trimLen) {
+ final int trimEnd = trimStart + trimLen;
+ for (int i = trimStart; i < trimEnd; ++i) {
+ if (trimBytes[i] == character) {
return true;
}
}
return false;
}
+ static void trimBoth(BytesColumnVector outV, byte[] bytes, int startIndex, int length,
+ byte[] trimBytes, int trimStart, int trimLen, int batchIndex) {
+ final int end = startIndex + length;
+ int leftIndex = startIndex;
+ while (leftIndex < end && shouldTrimByte(bytes[leftIndex], trimBytes, trimStart, trimLen)) {
+ leftIndex++;
+ }
+ if (leftIndex == end) {
+ outV.setVal(batchIndex, EMPTY_BYTES, 0, 0);
+ return;
+ }
+
+ int rightIndex = end - 1;
+ final int rightLimit = leftIndex + 1;
+ while (rightIndex >= rightLimit && shouldTrimByte(bytes[rightIndex], trimBytes, trimStart, trimLen)) {
+ rightIndex--;
+ }
+ final int resultLength = rightIndex - leftIndex + 1;
+ if (resultLength <= 0) {
+ throw new RuntimeException("Not expected");
+ }
+ outV.setVal(batchIndex, bytes, leftIndex, resultLength);
+ }
Review Comment:
Is this method identical to `StringTrimColScalar.func`?
Could you please remove the duplicate and call the remaining method instead?
The same goes for `trimLeft` and `trimRight`.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "Manya0407 (via GitHub)" <gi...@apache.org>.
Manya0407 commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3637333561
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringTrimColScalarBase.java:
##########
@@ -43,14 +44,75 @@ public StringTrimColScalarBase() {
}
protected boolean shouldTrim(int character) {
- for (int i = 0; i < trimChars.length; ++i) {
- if (trimChars[i] == character) {
+ return shouldTrimByte((byte) character, trimChars, 0, trimChars.length);
+ }
+
+ static boolean shouldTrimByte(byte character, byte[] trimBytes, int trimStart, int trimLen) {
+ final int trimEnd = trimStart + trimLen;
+ for (int i = trimStart; i < trimEnd; ++i) {
+ if (trimBytes[i] == character) {
return true;
}
}
return false;
}
+ static void trimBoth(BytesColumnVector outV, byte[] bytes, int startIndex, int length,
+ byte[] trimBytes, int trimStart, int trimLen, int batchIndex) {
+ final int end = startIndex + length;
+ int leftIndex = startIndex;
+ while (leftIndex < end && shouldTrimByte(bytes[leftIndex], trimBytes, trimStart, trimLen)) {
+ leftIndex++;
+ }
+ if (leftIndex == end) {
+ outV.setVal(batchIndex, EMPTY_BYTES, 0, 0);
+ return;
+ }
+
+ int rightIndex = end - 1;
+ final int rightLimit = leftIndex + 1;
+ while (rightIndex >= rightLimit && shouldTrimByte(bytes[rightIndex], trimBytes, trimStart, trimLen)) {
+ rightIndex--;
+ }
+ final int resultLength = rightIndex - leftIndex + 1;
+ if (resultLength <= 0) {
+ throw new RuntimeException("Not expected");
+ }
+ outV.setVal(batchIndex, bytes, leftIndex, resultLength);
+ }
Review Comment:
Refactored the existing ColScalar func() methods to delegate to trimBoth/trimLeft/trimRight in StringTrimColScalarBase, so trim logic lives in one place for both ColScalar and the new ColCol/ScalarCol classes.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6616:
URL: https://github.com/apache/hive/pull/6616#issuecomment-5020093118
## [](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6616) **Quality Gate passed**
Issues
 [13 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6616&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6616&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6616&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6616&metric=new_coverage&view=list)
 [42.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6616&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6616)
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "Manya0407 (via GitHub)" <gi...@apache.org>.
Manya0407 commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3637331854
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrimColCol.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized RTRIM with a string column and a trim-characters column.
+ */
+public class StringRTrimColCol extends VectorExpression {
Review Comment:
Extracted the shared COL+COLUMN evaluate() loop into StringTrimColColBase. The three subclasses now only implement func() with trimBoth/trimLeft/trimRight. Null, repeating, and selected handling is delegated to NullUtil.propagateNullsColCol, which covers the same COL+COL combinations as the inlined logic in StringGroupConcatColCol.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "kasakrisz (via GitHub)" <gi...@apache.org>.
kasakrisz commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3636826214
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrimColCol.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized RTRIM with a string column and a trim-characters column.
+ */
+public class StringRTrimColCol extends VectorExpression {
+ private static final long serialVersionUID = 1L;
+
+ public StringRTrimColCol(int strCol, int trimCharsCol, int outputColumnNum) {
+ super(strCol, trimCharsCol, outputColumnNum);
+ }
+
+ public StringRTrimColCol() {
+ super();
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) throws HiveException {
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ BytesColumnVector strV = (BytesColumnVector) batch.cols[inputColumnNum[0]];
+ BytesColumnVector trimV = (BytesColumnVector) batch.cols[inputColumnNum[1]];
+ BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ if (n == 0) {
+ return;
+ }
+
+ outV.initBuffer();
+ NullUtil.propagateNullsColCol(strV, trimV, outV, sel, n, batch.selectedInUse);
+
+ if (strV.isRepeating && trimV.isRepeating) {
+ if (!outV.isNull[0]) {
+ applyTrim(outV, strV, 0, trimV, 0, 0);
+ }
+ outV.isRepeating = true;
+ return;
+ }
+
+ if (batch.selectedInUse) {
+ for (int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!outV.isNull[i]) {
+ applyTrim(outV, strV, i, trimV, trimV.isRepeating ? 0 : i, i);
+ }
+ }
+ } else {
+ for (int i = 0; i != n; i++) {
+ if (!outV.isNull[i]) {
+ applyTrim(outV, strV, i, trimV, trimV.isRepeating ? 0 : i, i);
+ }
+ }
+ }
+ }
+
+ private void applyTrim(BytesColumnVector outV, BytesColumnVector strV, int strIndex,
Review Comment:
This method is called `func` in the existing code like `StringTrimColScalar`
I think both names are fine but please use only one of them.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "kasakrisz (via GitHub)" <gi...@apache.org>.
kasakrisz commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3636767789
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrimColCol.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized RTRIM with a string column and a trim-characters column.
+ */
+public class StringRTrimColCol extends VectorExpression {
Review Comment:
We have `StringTrimColCol`, `StringLTrimColCol`, and `StringRTrimColCol`. All of them are binary string functions. Please extract the common logic such as the evaluate method.
There is also `StringGroupConcatColCol`: its evaluate method seems more complex than `StringTrimColCol.evaluate`.
Could you please check the differences and verify that all possibilities—isNull, isRepeating, selected, and their combinations—are covered?
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "Manya0407 (via GitHub)" <gi...@apache.org>.
Manya0407 commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3654624615
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrimScalarCol.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import java.util.Arrays;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized LTRIM with a scalar string and a trim-characters column.
+ */
+public class StringLTrimScalarCol extends VectorExpression {
Review Comment:
Yes — the SCALAR + COLUMN path is a different operand pattern from what StringUnaryUDF / StringUnaryUDFDirect handle.
I've extracted the shared logic into StringTrimScalarColBase. StringTrimScalarCol, StringLTrimScalarCol, and StringRTrimScalarCol now only implement func() (calling trimBoth / trimLeft / trimRight), mirroring the StringTrimColColBase pattern.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599: Add support for vectorized two-parameter trim functions [hive]
Posted by "kasakrisz (via GitHub)" <gi...@apache.org>.
kasakrisz merged PR #6616:
URL: https://github.com/apache/hive/pull/6616
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6616:
URL: https://github.com/apache/hive/pull/6616#issuecomment-5057875765
## [](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6616) **Quality Gate passed**
Issues
 [17 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6616&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6616&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6616&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6616&metric=new_coverage&view=list)
 [29.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6616&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6616)
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "kasakrisz (via GitHub)" <gi...@apache.org>.
kasakrisz commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3636719073
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrimScalarCol.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import java.util.Arrays;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized LTRIM with a scalar string and a trim-characters column.
+ */
+public class StringLTrimScalarCol extends VectorExpression {
Review Comment:
Why is this class extending `VectorExpression`? There is `StringUnaryUDF` and `StringUnaryUDFDirect` to handle string functions that takes one string column argument.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
Re: [PR] HIVE-24599 :Add support vectorized two parameter trim functions [hive]
Posted by "Manya0407 (via GitHub)" <gi...@apache.org>.
Manya0407 commented on code in PR #6616:
URL: https://github.com/apache/hive/pull/6616#discussion_r3637335008
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrimColCol.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.hadoop.hive.ql.exec.vector.expressions;
+
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Vectorized RTRIM with a string column and a trim-characters column.
+ */
+public class StringRTrimColCol extends VectorExpression {
+ private static final long serialVersionUID = 1L;
+
+ public StringRTrimColCol(int strCol, int trimCharsCol, int outputColumnNum) {
+ super(strCol, trimCharsCol, outputColumnNum);
+ }
+
+ public StringRTrimColCol() {
+ super();
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) throws HiveException {
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ BytesColumnVector strV = (BytesColumnVector) batch.cols[inputColumnNum[0]];
+ BytesColumnVector trimV = (BytesColumnVector) batch.cols[inputColumnNum[1]];
+ BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ if (n == 0) {
+ return;
+ }
+
+ outV.initBuffer();
+ NullUtil.propagateNullsColCol(strV, trimV, outV, sel, n, batch.selectedInUse);
+
+ if (strV.isRepeating && trimV.isRepeating) {
+ if (!outV.isNull[0]) {
+ applyTrim(outV, strV, 0, trimV, 0, 0);
+ }
+ outV.isRepeating = true;
+ return;
+ }
+
+ if (batch.selectedInUse) {
+ for (int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!outV.isNull[i]) {
+ applyTrim(outV, strV, i, trimV, trimV.isRepeating ? 0 : i, i);
+ }
+ }
+ } else {
+ for (int i = 0; i != n; i++) {
+ if (!outV.isNull[i]) {
+ applyTrim(outV, strV, i, trimV, trimV.isRepeating ? 0 : i, i);
+ }
+ }
+ }
+ }
+
+ private void applyTrim(BytesColumnVector outV, BytesColumnVector strV, int strIndex,
Review Comment:
Renamed applyTrim to func for consistency with StringTrimColScalar and the new StringTrimColColBase.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org