Skip to content

binary_to_numeric macro will fail to parse token id when it is a vast number #1

@onesuper

Description

@onesuper

The datatype of token_id of erc721 is uint256. On the other side, Spark uses a 8-byte integer number to calculate conv internally.

The following macro will fail to return the token id correctly when it exceed 18446744073709551615(2^64-1)

{% macro default__binary_to_numeric(expression) %}
    cast(conv(hex({{ expression }}), 16, 10) as {{ dbt_utils.type_numeric() }})
{% endmacro %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions