Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][sql] Fix the decimal type error convert in json schema #15687

Merged
merged 1 commit into from
May 26, 2022

Conversation

shibd
Copy link
Member

@shibd shibd commented May 20, 2022

Motivation

In the current sql implementation, If using JSON schema and querying for decimal type, there will be the following two errors:

  1. The data type is displayed as varchar.
  2. Loss of precision because scientific notation is used to display.
presto> select bigdecimal, typeof(bigdecimal) as devimal_type from pulsar."public/default".test_avro2;
      bigdecimal       | devimal_type
-----------------------+--------------
 1.2345678912345678E36 | varchar
 1.2345678912345678E36 | varchar
(2 rows)

The original data is: 1234567891234567891234567891234567.89

Modifications

  • When getting jsonNode, use BIG_DECIMAL instead of float and double.
  • PulsarJsonFieldDecoder increases the processing of Decimal types

Documentation

  • no-need-doc
    (Please explain why)

@shibd shibd marked this pull request as ready for review May 20, 2022 08:56
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label May 20, 2022
@codelipenghui codelipenghui added this to the 2.11.0 milestone May 20, 2022
@codelipenghui codelipenghui added release/2.9.3 release/2.10.1 type/bug The PR fixed a bug or issue reported a bug area/sql Pulsar SQL related features labels May 20, 2022
Copy link
Contributor

@Technoboy- Technoboy- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is fixed in master and need to rebase

@shibd shibd force-pushed the fix_json_of_presto branch from e0647e6 to 9fcd914 Compare May 21, 2022 13:31
@shibd
Copy link
Member Author

shibd commented May 23, 2022

/pulsarbot run-failure-checks

@codelipenghui codelipenghui merged commit 0c6e2ca into apache:master May 26, 2022
codelipenghui pushed a commit that referenced this pull request May 26, 2022
### Motivation

In the current sql implementation, If using `JSON` schema and querying for decimal type, there will be the following two errors:

1. The data type is displayed as varchar.
2. Loss of precision because scientific notation is used to display.

```
presto> select bigdecimal, typeof(bigdecimal) as devimal_type from pulsar."public/default".test_avro2;
      bigdecimal       | devimal_type
-----------------------+--------------
 1.2345678912345678E36 | varchar
 1.2345678912345678E36 | varchar
(2 rows)
```
The original data is: `1234567891234567891234567891234567.89`

### Modifications
-  When getting jsonNode,  use `BIG_DECIMAL` instead of float and double.
- `PulsarJsonFieldDecoder` increases the processing of Decimal types

(cherry picked from commit 0c6e2ca)
codelipenghui pushed a commit that referenced this pull request May 26, 2022
In the current sql implementation, If using `JSON` schema and querying for decimal type, there will be the following two errors:

1. The data type is displayed as varchar.
2. Loss of precision because scientific notation is used to display.

```
presto> select bigdecimal, typeof(bigdecimal) as devimal_type from pulsar."public/default".test_avro2;
      bigdecimal       | devimal_type
-----------------------+--------------
 1.2345678912345678E36 | varchar
 1.2345678912345678E36 | varchar
(2 rows)
```
The original data is: `1234567891234567891234567891234567.89`

-  When getting jsonNode,  use `BIG_DECIMAL` instead of float and double.
- `PulsarJsonFieldDecoder` increases the processing of Decimal types

(cherry picked from commit 0c6e2ca)
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label May 26, 2022
nicoloboschi added a commit to nicoloboschi/pulsar that referenced this pull request May 26, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jun 7, 2022
…15687)

### Motivation

In the current sql implementation, If using `JSON` schema and querying for decimal type, there will be the following two errors:

1. The data type is displayed as varchar.
2. Loss of precision because scientific notation is used to display.

```
presto> select bigdecimal, typeof(bigdecimal) as devimal_type from pulsar."public/default".test_avro2;
      bigdecimal       | devimal_type
-----------------------+--------------
 1.2345678912345678E36 | varchar
 1.2345678912345678E36 | varchar
(2 rows)
```
The original data is: `1234567891234567891234567891234567.89`

### Modifications
-  When getting jsonNode,  use `BIG_DECIMAL` instead of float and double.
- `PulsarJsonFieldDecoder` increases the processing of Decimal types

(cherry picked from commit 0c6e2ca)
(cherry picked from commit 618d4e2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sql Pulsar SQL related features cherry-picked/branch-2.9 Archived: 2.9 is end of life cherry-picked/branch-2.10 doc-not-needed Your PR changes do not impact docs release/2.9.3 release/2.10.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants