You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2021/12/20 06:37:44 UTC

[ignite] branch sql-calcite updated: IGNITE-15909 Fallback to the UTF-8 when JVM default charset is not supported by Calcite - Fixes #9635.

This is an automated email from the ASF dual-hosted git repository.

alexpl pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/sql-calcite by this push:
     new 2ad9068  IGNITE-15909 Fallback to the UTF-8 when JVM default charset is not supported by Calcite - Fixes #9635.
2ad9068 is described below

commit 2ad9068df89ca35ba79f8a201bdc20344908d823
Author: Aleksey Plekhanov <pl...@gmail.com>
AuthorDate: Mon Dec 20 09:34:57 2021 +0300

    IGNITE-15909 Fallback to the UTF-8 when JVM default charset is not supported by Calcite - Fixes #9635.
    
    Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
 .../query/calcite/type/IgniteTypeFactory.java         | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java
index f523978..e2ac65f 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.query.calcite.type;
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.sql.Timestamp;
 import java.time.Duration;
 import java.time.LocalDateTime;
@@ -35,6 +36,7 @@ import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeSystem;
 import org.apache.calcite.runtime.Geometries;
 import org.apache.calcite.sql.SqlIntervalQualifier;
+import org.apache.calcite.sql.SqlUtil;
 import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.calcite.sql.type.BasicSqlType;
 import org.apache.calcite.sql.type.IntervalSqlType;
@@ -53,8 +55,11 @@ public class IgniteTypeFactory extends JavaTypeFactoryImpl {
         TimeUnit.SECOND, SqlParserPos.ZERO);
 
     /** */
+    private final Charset charset;
+
+    /** */
     public IgniteTypeFactory() {
-        super(IgniteTypeSystem.INSTANCE);
+        this(IgniteTypeSystem.INSTANCE);
     }
 
     /**
@@ -62,6 +67,15 @@ public class IgniteTypeFactory extends JavaTypeFactoryImpl {
      */
     public IgniteTypeFactory(RelDataTypeSystem typeSystem) {
         super(typeSystem);
+
+        if (SqlUtil.translateCharacterSetName(Charset.defaultCharset().name()) != null) {
+            // Use JVM default charset rather then Calcite default charset (ISO-8859-1).
+            charset = Charset.defaultCharset();
+        }
+        else {
+            // If JVM default charset is not supported by Calcite - use UTF-8.
+            charset = StandardCharsets.UTF_8;
+        }
     }
 
     /** {@inheritDoc} */
@@ -233,8 +247,7 @@ public class IgniteTypeFactory extends JavaTypeFactoryImpl {
 
     /** {@inheritDoc} */
     @Override public Charset getDefaultCharset() {
-        // Use JVM default charset rather then Calcite default charset (ISO-8859-1).
-        return Charset.defaultCharset();
+        return charset;
     }
 
     /** {@inheritDoc} */