[ 
https://issues.apache.org/jira/browse/FLINK-32564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hanyu Zheng updated FLINK-32564:
--------------------------------
    Description: 
We are dealing with a task that requires casting from the BYTES type to BIGINT. 
Specifically, we have a string '00T1p'. Our approach is to convert this string 
to BYTES and then cast the result to BIGINT with the following SQL query:
{code:java}
SELECT CAST((CAST('00T1p' as BYTES)) as BIGINT);{code}
However, an issue arises when executing this query, likely due to an error in 
the conversion between BYTES and BIGINT. We aim to identify and rectify this 
issue so our query can run correctly. The tasks involved are:
 # Investigate and identify the specific reason for the failure of conversion 
from BYTES to BIGINT.
 # Design and implement a solution to ensure our query can function correctly.
 # Test this solution across all required scenarios to guarantee its 
functionality.

 

see also

1. PostgreSQL: PostgreSQL supports casting from BYTES type (BYTEA) to NUMBER 
types (INTEGER, BIGINT, DECIMAL, etc.). In PostgreSQL, you can use CAST or type 
conversion operator (::) for performing the conversion. URL: 
[https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS]

2. MySQL: MySQL supports casting from BYTES type (BLOB or BINARY) to NUMBER 
types (INTEGER, BIGINT, DECIMAL, etc.). In MySQL, you can use CAST or CONVERT 
functions for performing the conversion. URL: 
[https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html]

3. Microsoft SQL Server: SQL Server supports casting from BYTES type 
(VARBINARY, IMAGE) to NUMBER types (INT, BIGINT, NUMERIC, etc.). You can use 
CAST or CONVERT functions for performing the conversion. URL: 
[https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql]

4. Oracle Database: Oracle supports casting from RAW type (equivalent to BYTES) 
to NUMBER types (NUMBER, INTEGER, FLOAT, etc.). You can use the TO_NUMBER 
function for performing the conversion. URL: 
[https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/TO_NUMBER.html]

5. Apache Spark: Spark DataFrame supports casting binary types (BinaryType or 
ByteType) to numeric types (IntegerType, LongType, DecimalType, etc.) by using 
the {{cast}} function. URL: [https://spark.apache.org/docs/latest/api/sql/#cast]

  was:
We are dealing with a task that requires casting from the BYTES type to BIGINT. 
Specifically, we have a string '00T1p'. Our approach is to convert this string 
to BYTES and then cast the result to BIGINT with the following SQL query:
{code:java}
SELECT CAST((CAST('00T1p' as BYTES)) as BIGINT);{code}
However, an issue arises when executing this query, likely due to an error in 
the conversion between BYTES and BIGINT. We aim to identify and rectify this 
issue so our query can run correctly. The tasks involved are:
 # Investigate and identify the specific reason for the failure of conversion 
from BYTES to BIGINT.
 # Design and implement a solution to ensure our query can function correctly.
 # Test this solution across all required scenarios to guarantee its 
functionality.

 

see also

1. PostgreSQL: PostgreSQL supports casting from BYTES type (BYTEA) to NUMBER 
types (INTEGER, BIGINT, DECIMAL, etc.). In PostgreSQL, you can use CAST or type 
conversion operator (::) for performing the conversion. URL: 
[https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS]

2. MySQL: MySQL supports casting from BYTES type (BLOB or BINARY) to NUMBER 
types (INTEGER, BIGINT, DECIMAL, etc.). In MySQL, you can use CAST or CONVERT 
functions for performing the conversion. URL: 
[https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html]

3. Microsoft SQL Server: SQL Server supports casting from BYTES type 
(VARBINARY, IMAGE) to NUMBER types (INT, BIGINT, NUMERIC, etc.). You can use 
CAST or CONVERT functions for performing the conversion. URL: 
[https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql]

4. Oracle Database: Oracle supports casting from RAW type (equivalent to BYTES) 
to NUMBER types (NUMBER, INTEGER, FLOAT, etc.). You can use the TO_NUMBER 
function for performing the conversion. URL: 
[https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/TO_NUMBER.html]

5. Apache Spark: Spark DataFrame supports casting binary types (BinaryType or 
ByteType) to numeric types (IntegerType, LongType, DecimalType, etc.) by using 
the {{cast}} function. URL: [https://spark.apache.org/docs/latest/api/sql/#cast]


> Support cast from BYTES to NUMBER
> ---------------------------------
>
>                 Key: FLINK-32564
>                 URL: https://issues.apache.org/jira/browse/FLINK-32564
>             Project: Flink
>          Issue Type: Sub-task
>            Reporter: Hanyu Zheng
>            Assignee: Hanyu Zheng
>            Priority: Major
>              Labels: pull-request-available
>
> We are dealing with a task that requires casting from the BYTES type to 
> BIGINT. Specifically, we have a string '00T1p'. Our approach is to convert 
> this string to BYTES and then cast the result to BIGINT with the following 
> SQL query:
> {code:java}
> SELECT CAST((CAST('00T1p' as BYTES)) as BIGINT);{code}
> However, an issue arises when executing this query, likely due to an error in 
> the conversion between BYTES and BIGINT. We aim to identify and rectify this 
> issue so our query can run correctly. The tasks involved are:
>  # Investigate and identify the specific reason for the failure of conversion 
> from BYTES to BIGINT.
>  # Design and implement a solution to ensure our query can function correctly.
>  # Test this solution across all required scenarios to guarantee its 
> functionality.
>  
> see also
> 1. PostgreSQL: PostgreSQL supports casting from BYTES type (BYTEA) to NUMBER 
> types (INTEGER, BIGINT, DECIMAL, etc.). In PostgreSQL, you can use CAST or 
> type conversion operator (::) for performing the conversion. URL: 
> [https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS]
> 2. MySQL: MySQL supports casting from BYTES type (BLOB or BINARY) to NUMBER 
> types (INTEGER, BIGINT, DECIMAL, etc.). In MySQL, you can use CAST or CONVERT 
> functions for performing the conversion. URL: 
> [https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html]
> 3. Microsoft SQL Server: SQL Server supports casting from BYTES type 
> (VARBINARY, IMAGE) to NUMBER types (INT, BIGINT, NUMERIC, etc.). You can use 
> CAST or CONVERT functions for performing the conversion. URL: 
> [https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql]
> 4. Oracle Database: Oracle supports casting from RAW type (equivalent to 
> BYTES) to NUMBER types (NUMBER, INTEGER, FLOAT, etc.). You can use the 
> TO_NUMBER function for performing the conversion. URL: 
> [https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/TO_NUMBER.html]
> 5. Apache Spark: Spark DataFrame supports casting binary types (BinaryType or 
> ByteType) to numeric types (IntegerType, LongType, DecimalType, etc.) by 
> using the {{cast}} function. URL: 
> [https://spark.apache.org/docs/latest/api/sql/#cast]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to