[ 
https://issues.apache.org/jira/browse/CALCITE-6792?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17914881#comment-17914881
 ] 

Pavel Pereslegin commented on CALCITE-6792:
-------------------------------------------

With enabled "ALLOW_NON_NUMERIC_NUMBERS" feature it throws:

{noformat}
java.lang.RuntimeException: 
com.fasterxml.jackson.databind.JsonMappingException: Value "Infinity" can not 
be represented as `java.math.BigDecimal`, reason: Character I is neither a 
decimal digit number, decimal point, nor "e" notation exponential mark. 
(through reference chain: java.util.LinkedHashMap["rels"])

        at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:194)
        at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:136)
        at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:154)
        at org.apache.calcite.plan.RelWriterTest.testInf(RelWriterTest.java:517)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at 
org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
        at 
org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
        at 
org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
        at 
org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
        at 
org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
        at 
org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
        at 
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
        at 
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
        at 
org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
        at 
org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
        at 
org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
        at 
org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
        at 
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
        at 
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
        at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
        at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
        at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
        at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
        at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at 
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at 
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
        at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at 
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at 
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
        at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at 
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at 
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
        at 
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at 
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
        at 
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
        at 
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
        at 
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
        at 
org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
        at 
org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
        at 
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
        at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
        at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
        at 
org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
        at 
org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
        at 
com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
        at 
com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
        at 
com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
        at 
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
        at 
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
        at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Value 
"Infinity" can not be represented as `java.math.BigDecimal`, reason: Character 
I is neither a decimal digit number, decimal point, nor "e" notation 
exponential mark. (through reference chain: java.util.LinkedHashMap["rels"])
        at 
com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
        at 
com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
        at 
com.fasterxml.jackson.databind.deser.std.ContainerDeserializerBase.wrapAndThrow(ContainerDeserializerBase.java:190)
        at 
com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:638)
        at 
com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:449)
        at 
com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:32)
        at 
com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at 
com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825)
        at 
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772)
        at 
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3755)
        at 
org.apache.calcite.rel.externalize.RelJsonReader.read(RelJsonReader.java:99)
        at 
org.apache.calcite.plan.RelWriterTest.lambda$testInf$1(RelWriterTest.java:541)
        at 
org.apache.calcite.tools.Frameworks.lambda$withPlanner$0(Frameworks.java:141)
        at 
org.apache.calcite.prepare.CalcitePrepareImpl.perform(CalcitePrepareImpl.java:977)
        at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:192)
        ... 73 more
Caused by: java.lang.NumberFormatException: Value "Infinity" can not be 
represented as `java.math.BigDecimal`, reason: Character I is neither a decimal 
digit number, decimal point, nor "e" notation exponential mark.
        at 
com.fasterxml.jackson.core.io.BigDecimalParser.parse(BigDecimalParser.java:56)
        at 
com.fasterxml.jackson.core.io.BigDecimalParser.parse(BigDecimalParser.java:62)
        at 
com.fasterxml.jackson.core.io.BigDecimalParser.parse(BigDecimalParser.java:31)
        at 
com.fasterxml.jackson.core.io.NumberInput.parseBigDecimal(NumberInput.java:432)
        at 
com.fasterxml.jackson.core.base.ParserBase.convertNumberToBigDecimal(ParserBase.java:1202)
        at 
com.fasterxml.jackson.core.base.ParserBase.getDecimalValue(ParserBase.java:847)
        at 
com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializerNR._deserializeNR(UntypedObjectDeserializerNR.java:253)
        at 
com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializerNR.deserialize(UntypedObjectDeserializerNR.java:79)
        at 
com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:623)
        ... 84 more
{noformat}

>  RelJsonReader failed to read RelJsonWriter output if 'NaN' or 'Infinity' 
> approximate numerics are present
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6792
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6792
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.38.0
>            Reporter: Evgeny Stanilovsky
>            Priority: Major
>
> Simple reproduser is below, place it into RelWriterTest
> {noformat}
>   @Test void testInf() {
>       Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> {
>         final RexBuilder rexBuilder = cluster.getRexBuilder();
>         final FrameworkConfig config = RelBuilderTest.config().build();
>         final RelBuilder builder = RelBuilder.create(config);
>  
>         RelDataType doubleType = 
> cluster.getTypeFactory().builder().add("name",
>             
> cluster.getTypeFactory().createSqlType(SqlTypeName.DOUBLE)).build();
>  
>         final RelDataType doubleTypeLit =
>             cluster.getTypeFactory().createSqlType(SqlTypeName.DOUBLE);
>         RexLiteral lit = 
> rexBuilder.makeApproxLiteral(Double.POSITIVE_INFINITY, // <---
>             doubleTypeLit);
>         RelNode vals = builder.values(Collections.nCopies(1, List.of(lit)), 
> doubleType).build();
>  
>         final RelJsonWriter writer = new RelJsonWriter();
>         vals.explain(writer);
>         String serialized = writer.asString();
>  
>         SchemaPlus schema = rootSchema.add("hr",
>             new ReflectiveSchema(new HrSchema()));
>         final RelJsonReader reader =
>             new RelJsonReader(cluster, relOptSchema, schema);
>         RelNode node;
>         try {
>           node = reader.read(serialized); // <- raised from here
>         } catch (IOException e) {
>           throw TestUtil.rethrow(e);
>         }
>         return RelOptUtil.dumpPlan("", node, SqlExplainFormat.TEXT,
>             SqlExplainLevel.EXPPLAN_ATTRIBUTES);
>       });
>   }
> {noformat}
> will throw: com.fasterxml.jackson.core.JsonParseException: Non-standard token 
> 'Infinity': enable `JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS` to allow



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to