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

[GLib] Add GArrowDecimal32DataType #44392

Closed
kou opened this issue Oct 13, 2024 · 3 comments
Closed

[GLib] Add GArrowDecimal32DataType #44392

kou opened this issue Oct 13, 2024 · 3 comments

Comments

@kou
Copy link
Member

kou commented Oct 13, 2024

Describe the enhancement requested

It's for arrow::type::Decimal32Type.

See also the GArrowDecimal128DataType implementation:

#define GARROW_TYPE_DECIMAL128_DATA_TYPE (garrow_decimal128_data_type_get_type())
GARROW_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE(GArrowDecimal128DataType,
garrow_decimal128_data_type,
GARROW,
DECIMAL128_DATA_TYPE,
GArrowDecimalDataType)
struct _GArrowDecimal128DataTypeClass
{
GArrowDecimalDataTypeClass parent_class;
};
GARROW_AVAILABLE_IN_3_0
gint32
garrow_decimal128_data_type_max_precision();
GARROW_AVAILABLE_IN_0_12
GArrowDecimal128DataType *
garrow_decimal128_data_type_new(gint32 precision, gint32 scale, GError **error);

* #GArrowDecimal128DataType is a class for the 128-bit decimal data type.

G_DEFINE_TYPE(GArrowDecimal128DataType,
garrow_decimal128_data_type,
GARROW_TYPE_DECIMAL_DATA_TYPE)
static void
garrow_decimal128_data_type_init(GArrowDecimal128DataType *object)
{
}
static void
garrow_decimal128_data_type_class_init(GArrowDecimal128DataTypeClass *klass)
{
}
/**
* garrow_decimal128_data_type_max_precision:
*
* Returns: The max precision of 128-bit decimal data type.
*
* Since: 3.0.0
*/
gint32
garrow_decimal128_data_type_max_precision()
{
return arrow::Decimal128Type::kMaxPrecision;
}
/**
* garrow_decimal128_data_type_new:
* @precision: The precision of decimal data.
* @scale: The scale of decimal data.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Returns: (nullable):
* The newly created 128-bit decimal data type on success, %NULL on error.
*
* Since: 0.12.0
*/
GArrowDecimal128DataType *
garrow_decimal128_data_type_new(gint32 precision, gint32 scale, GError **error)
{
auto arrow_data_type_result = arrow::Decimal128Type::Make(precision, scale);
if (garrow::check(error, arrow_data_type_result, "[decimal128-data-type][new]")) {
auto arrow_data_type = *arrow_data_type_result;
return GARROW_DECIMAL128_DATA_TYPE(g_object_new(GARROW_TYPE_DECIMAL128_DATA_TYPE,
"data-type",
&arrow_data_type,
NULL));
} else {
return NULL;
}
}

https://github.com/apache/arrow/blob/main/c_glib/test/test-decimal128-data-type.rb

Component(s)

GLib

hiroyuki-sato added a commit to hiroyuki-sato/arrow that referenced this issue Oct 15, 2024
hiroyuki-sato added a commit to hiroyuki-sato/arrow that referenced this issue Oct 15, 2024
hiroyuki-sato added a commit to hiroyuki-sato/arrow that referenced this issue Oct 15, 2024
hiroyuki-sato added a commit to hiroyuki-sato/arrow that referenced this issue Oct 30, 2024
hiroyuki-sato added a commit to hiroyuki-sato/arrow that referenced this issue Oct 30, 2024
kou pushed a commit that referenced this issue Oct 30, 2024
### Rationale for this change

`arrow::Decimal32Type` data type has been introduced. It is also necessary to support the same data type in GLib.

### What changes are included in this PR?

This PR implements `GArrowDecimal32DataType`.

### Are these changes tested?

YES

### Are there any user-facing changes?

Before this change `garrow_decimal_data_type_new()` returns `GArrowDecimal64DataType` if the precision is less than `garrow_decimal64_data_type_max_precision()`.
After this change, it returns `GArrowDecimal32DataType` if the precision is less than garrow_decimal32_data_type_max_precision().

* GitHub Issue: #44392

Authored-by: Hiroyuki Sato <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
@kou kou added this to the 19.0.0 milestone Oct 30, 2024
@kou
Copy link
Member Author

kou commented Oct 30, 2024

Issue resolved by pull request 44580
#44580

@kou kou closed this as completed Oct 30, 2024
@kou
Copy link
Member Author

kou commented Oct 30, 2024

@hiroyuki-sato Could you add "take" only comment here to assign you to this issue?

@hiroyuki-sato
Copy link
Contributor

hiroyuki-sato commented Oct 31, 2024

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants