This is an automated email from the ASF dual-hosted git repository.
lgbo-ustc pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git
The following commit(s) were added to refs/heads/main by this push:
new e7b1b3bac6 fix(planner): extract VARCHAR literal value without charset
prefix (#12250)
e7b1b3bac6 is described below
commit e7b1b3bac60eaa9d4100479bbbc060ad7318b8cd
Author: GGboom <[email protected]>
AuthorDate: Thu Jun 25 15:24:55 2026 +0800
fix(planner): extract VARCHAR literal value without charset prefix (#12250)
Use getValueAs(String.class) instead of getValue().toString() which
produces "_UTF-16LE'value'" from NlsString.
---
.../apache/gluten/rexnode/RexNodeConverter.java | 2 +-
.../gluten/rexnode/RexNodeConverterTest.java | 66 ++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git
a/gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/RexNodeConverter.java
b/gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/RexNodeConverter.java
index 519f36d6e1..3cc61a2593 100644
---
a/gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/RexNodeConverter.java
+++
b/gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/RexNodeConverter.java
@@ -111,7 +111,7 @@ public class RexNodeConverter {
case DOUBLE:
return new DoubleValue(Double.valueOf(literal.getValue().toString()));
case VARCHAR:
- return new VarCharValue(literal.getValue().toString());
+ return new VarCharValue(literal.getValueAs(String.class));
case CHAR:
// For CHAR, we convert it to VARCHAR
return new VarCharValue(literal.getValueAs(String.class));
diff --git
a/gluten-flink/ut/src/test/java/org/apache/gluten/rexnode/RexNodeConverterTest.java
b/gluten-flink/ut/src/test/java/org/apache/gluten/rexnode/RexNodeConverterTest.java
new file mode 100644
index 0000000000..0cae77d7b6
--- /dev/null
+++
b/gluten-flink/ut/src/test/java/org/apache/gluten/rexnode/RexNodeConverterTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.gluten.rexnode;
+
+import io.github.zhztheplayer.velox4j.variant.VarCharValue;
+import io.github.zhztheplayer.velox4j.variant.Variant;
+
+import org.apache.flink.table.planner.calcite.FlinkRexBuilder;
+import org.apache.flink.table.planner.calcite.FlinkTypeFactory;
+import org.apache.flink.table.planner.calcite.FlinkTypeSystem;
+
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class RexNodeConverterTest {
+
+ private static FlinkTypeFactory typeFactory;
+ private static RexBuilder rexBuilder;
+
+ @BeforeAll
+ public static void setUp() {
+ typeFactory =
+ new FlinkTypeFactory(
+ Thread.currentThread().getContextClassLoader(),
FlinkTypeSystem.INSTANCE);
+ rexBuilder = new FlinkRexBuilder(typeFactory);
+ }
+
+ @Test
+ public void testVarcharLiteralExtractsRawValue() {
+ RexLiteral literal =
+ (RexLiteral)
+ rexBuilder.makeLiteral("apple",
typeFactory.createSqlType(SqlTypeName.VARCHAR), false);
+ Variant variant = RexNodeConverter.toVariant(literal);
+ assertThat(variant).isInstanceOf(VarCharValue.class);
+ assertThat(((VarCharValue) variant).getValue()).isEqualTo("apple");
+ }
+
+ @Test
+ public void testCharLiteralExtractsRawValue() {
+ RexLiteral literal =
+ (RexLiteral)
+ rexBuilder.makeLiteral("banana",
typeFactory.createSqlType(SqlTypeName.CHAR), false);
+ Variant variant = RexNodeConverter.toVariant(literal);
+ assertThat(variant).isInstanceOf(VarCharValue.class);
+ assertThat(((VarCharValue) variant).getValue()).isEqualTo("banana");
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]