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

Implement arrow_json encoder for Decimal128 & Decimal256 DataTypes #6605

Closed
phillipleblanc opened this issue Oct 21, 2024 · 1 comment · Fixed by #6606
Closed

Implement arrow_json encoder for Decimal128 & Decimal256 DataTypes #6605

phillipleblanc opened this issue Oct 21, 2024 · 1 comment · Fixed by #6606
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@phillipleblanc
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

I would like to be able to use the arrow_json::ArrayWriter to write Arrow batches that contain Decimal128 & Decimal256 data.

Describe the solution you'd like

Running this code does not produce an error:

    #[test]
    fn test_decimal128_encoder() {
        let array = Decimal128Array::from_iter_values([1234, 5678, 9012])
            .with_precision_and_scale(10, 2)
            .unwrap();
        let field = Arc::new(Field::new("decimal", array.data_type().clone(), true));
        let schema = Schema::new(vec![field]);
        let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(array)]).unwrap();

        let mut buf = Vec::new();
        {
            let mut writer = LineDelimitedWriter::new(&mut buf);
            writer.write_batches(&[&batch]).unwrap();
        }

        assert_json_eq(
            &buf,
            r#"{"decimal":12.34}
{"decimal":56.78}
{"decimal":90.12}
"#,
        );
    }

Describe alternatives you've considered

N/A

Additional context

N/A

@phillipleblanc phillipleblanc added the enhancement Any new improvement worthy of a entry in the changelog label Oct 21, 2024
@alamb alamb added the arrow Changes to the arrow crate label Oct 21, 2024
@alamb
Copy link
Contributor

alamb commented Oct 21, 2024

label_issue.py automatically added labels {'arrow'} from #6606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants