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

Convert a StringLiteral into a DecimalLiteral #538

Closed
Fokko opened this issue Mar 21, 2024 · 3 comments
Closed

Convert a StringLiteral into a DecimalLiteral #538

Fokko opened this issue Mar 21, 2024 · 3 comments

Comments

@Fokko
Copy link
Contributor

Fokko commented Mar 21, 2024

Feature Request / Improvement

This is not possible today, but would be nice to have in there.

@Dysprosium0626
Copy link

Hi @Fokko I'd like to have I try but I do not know where to put these code. It seems that we already have https://github.com/apache/iceberg-python/blob/bbc7e7c8d095b4afea5c27e6de324d008aa2d803/pyiceberg/expressions/literals.py#L578C1-L585C125

@sungwy
Copy link
Collaborator

sungwy commented Mar 21, 2024

I'm making a similar observation as @Dysprosium0626 as well

from pyiceberg.expressions.literals import StringLiteral
from pyiceberg.types import DecimalType

StringLiteral("3.33").to(DecimalType(1, 2)).value

yields:

Decimal('3.33')

Is there a specific edge case we've overlooked?

@Fokko
Copy link
Contributor Author

Fokko commented Mar 21, 2024

This indeed works:

>>> from pyiceberg.types import DecimalType
>>> literal("100.00").to(DecimalType(10,2))
DecimalLiteral(Decimal('100.00'))

I maybe overlooked something when working on #539. Thanks for checking @Dysprosium0626 and @syun64 🙌

@Fokko Fokko closed this as completed Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants