[jira] [Created] (FLINK-15309) Execute sql appear "NumberFormatException: Zero length BigInteger"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-15309) Execute sql appear "NumberFormatException: Zero length BigInteger"

Shang Yuanchun (Jira)
xiaojin.wy created FLINK-15309:
----------------------------------

             Summary: Execute sql appear "NumberFormatException: Zero length BigInteger"
                 Key: FLINK-15309
                 URL: https://issues.apache.org/jira/browse/FLINK-15309
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Client
    Affects Versions: 1.10.0
            Reporter: xiaojin.wy
         Attachments: image-2019-12-18-15-53-24-501.png

*The sql is:*
CREATE TABLE `src` (
        key bigint,
        v varchar
) WITH (
        'format.field-delimiter'='|',
        'connector.type'='filesystem',
        'format.derive-schema'='true',
        'connector.path'='/defender_test_data/daily_regression_batch_hive_1.10/test_cast/sources/src.csv',
        'format.type'='csv'
);

            select
                cast(key as decimal(10,2)) as c1,
                cast(key as char(10)) as c2,
                cast(key as varchar(10)) as c3
            from src
                order by c1, c2, c3
                limit 1;

*The result schema get in the code is:*
sinkSchema:root
 |-- c1: DECIMAL(10, 2)
 |-- c2: CHAR(10)
 |-- c3: VARCHAR(10)

*The detail:*
If you user the sql above to execute in a sqlclinet environment, you can get the result like this:
 !image-2019-12-18-15-53-24-501.png!

But if you change the result directly to a cvs sink in the code, there will be a exception:

Caused by: java.lang.NumberFormatException: Zero length BigInteger
        at java.math.BigInteger.<init>(BigInteger.java:302)
        at org.apache.flink.table.dataformat.Decimal.fromUnscaledBytes(Decimal.java:214)
        at org.apache.flink.table.dataformat.Decimal.readDecimalFieldFromSegments(Decimal.java:487)
        at org.apache.flink.table.dataformat.BinaryRow.getDecimal(BinaryRow.java:334)
        at org.apache.flink.table.dataformat.DataFormatConverters$BigDecimalConverter.toExternalImpl(DataFormatConverters.java:642)
        at org.apache.flink.table.dataformat.DataFormatConverters$BigDecimalConverter.toExternalImpl(DataFormatConverters.java:618)
        at org.apache.flink.table.dataformat.DataFormatConverters$DataFormatConverter.toExternal(DataFormatConverters.java:358)
        at org.apache.flink.table.dataformat.DataFormatConverters$RowConverter.toExternalImpl(DataFormatConverters.java:1370)
        at org.apache.flink.table.dataformat.DataFormatConverters$RowConverter.toExternalImpl(DataFormatConverters.java:1349)
        at org.apache.flink.table.dataformat.DataFormatConverters$DataFormatConverter.toExternal(DataFormatConverters.java:340)
        at SinkConversion$43.processElement(Unknown Source)
        at org.apache.flink.streaming.runtime.tasks.OperatorChain$ChainingOutput.pushToOperator(OperatorChain.java:550)
        at org.apache.flink.streaming.runtime.tasks.OperatorChain$ChainingOutput.collect(OperatorChain.java:527)
        at org.apache.flink.streaming.runtime.tasks.OperatorChain$ChainingOutput.collect(OperatorChain.java:487)
        at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:730)
        at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:708)
        at org.apache.flink.table.runtime.util.StreamRecordCollector.collect(StreamRecordCollector.java:44)
        at org.apache.flink.table.runtime.operators.sort.SortLimitOperator.endInput(SortLimitOperator.java:98)
        at org.apache.flink.streaming.runtime.tasks.OperatorChain.endOperatorInput(OperatorChain.java:265)
        at org.apache.flink.streaming.runtime.tasks.OperatorChain.endHeadOperatorInput(OperatorChain.java:249)
        at org.apache.flink.streaming.runtime.io.StreamOneInputProcessor.processInput(StreamOneInputProcessor.java:73)
        at org.apache.flink.streaming.runtime.tasks.StreamTask.processInput(StreamTask.java:311)
        at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:187)
        at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:488)
        at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:470)
        at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:702)
        at org.apache.flink.runtime.taskmanager.Task.run(Task.java:527)
        at java.lang.Thread.run(Thread.java:834)


*The input data is:*
193|val_193
338|val_338
446|val_446
459|val_459
394|val_394
237|val_237
482|val_482
174|val_174
413|val_413
494|val_494
207|val_207
199|val_199
466|val_466
208|val_208
174|val_174
399|val_399
396|val_396
247|val_247
417|val_417
489|val_489
162|val_162
377|val_377
397|val_397
309|val_309
365|val_365
266|val_266
439|val_439
342|val_342
367|val_367
325|val_325
167|val_167
195|val_195
475|val_475
17|val_17
113|val_113
155|val_155
203|val_203
339|val_339
0|val_0
455|val_455
128|val_128
311|val_311
316|val_316
57|val_57
302|val_302



--
This message was sent by Atlassian Jira
(v8.3.4#803005)