matrixone icon indicating copy to clipboard operation
matrixone copied to clipboard

[Bug]: can't cast XXXX from YYYY type to ZZZZ type.

Open daviszhen opened this issue 2 years ago • 1 comments

Is there an existing issue for the same bug?

  • [X] I have checked the existing issues.

Environment

- Version or commit-id (e.g. v0.1.0 or 8b23a93):9589f9ac950564ca34bccc79393775f09e59ed11
- Hardware parameters:
- OS type:
- Others:

Actual Behavior

can't cast 'ABC' from VARCHAR type to TINYINT UNSIGNED type. can't cast '你好' from VARCHAR type to TINYINT UNSIGNED type.

[ERROR] [SCRIPT FILE]: /Users/pengzhen/Documents/GitHub/matrixone/test/cases/function/func_string_oct.test [ROW NUMBER]: 59 [SQL STATEMENT]: SELECT distinct oct(a), oct(b) FROM t1 ORDER BY oct(a); [EXPECT RESULT]: oct(a) oct(b) 106 540 220 540 [ACTUAL RESULT]: can't cast column from VARCHAR type to TINYINT UNSIGNED type because of one or more values in that column.

can't cast '' from VARCHAR type to BIGINT type.

[ERROR] [SCRIPT FILE]: /Users/pengzhen/Documents/GitHub/matrixone/test/cases/function/func_string_lpad_rpad.test [ROW NUMBER]: 99 [SQL STATEMENT]: SELECT ((+0) IN ((0b111111111111111111111111111111111111111111111111111),(rpad(1.0,2048,1)), (32767.1))); [EXPECT RESULT]: ((+0) IN ((0b111111111111111111111111111111111111111111111111111),(rpad(1.0,2048,1)), (32767.1))) 0 [ACTUAL RESULT]: can't cast '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' from VARCHAR type to BIGINT type.

CREATE TABLE t1 (f1 double); INSERT INTO t1 SET f1 = -1.0e+30 ; INSERT INTO t1 SET f1 = +1.0e+30 ; SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;

can't cast column from DOUBLE type to BIGINT type because of one or more values in that column. Reason: overflow

Expected Behavior

Steps to Reproduce

No response

Additional information

No response

daviszhen avatar Jun 29 '22 08:06 daviszhen

-- Not a problem. My clients' problem. -- Ignore Please. my:[email protected]:6001/foo=> select substring('', 1, ''); (0 rows)

fengttt avatar Jun 30 '22 04:06 fengttt

截屏2022-10-29 22 56 07

tianyahui-python avatar Oct 29 '22 14:10 tianyahui-python

CREATE TABLE t1 (f1 double); INSERT INTO t1 SET f1 = -1.0e+30 ; INSERT INTO t1 SET f1 = +1.0e+30 ; SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; can't cast column from DOUBLE type to BIGINT type because of one or more values in that column. Reason: overflow


@daviszhen What does this expectation look like?

tianyahui-python avatar Oct 29 '22 14:10 tianyahui-python

@daviszhen The owner of an issue can close issue.

tianyahui-python avatar Oct 29 '22 15:10 tianyahui-python

simplest cases to reproduce:

MySQL [mo]> SELECT cast('1.1' as signed int); ERROR 20203 (HY000): invalid argument cast to int, bad value 1.1 MySQL [mo]> MySQL [mo]> SELECT cast(1e30 as signed int); ERROR 20201 (HY000): data out of range: data type int64, value '1e+30'

badboynt1 avatar Oct 31 '22 07:10 badboynt1

for this error, keep this unchanged. confirmed with @domingozhang MySQL [mo]> SELECT cast(1e30 as signed int); ERROR 20201 (HY000): data out of range: data type int64, value '1e+30'

badboynt1 avatar Oct 31 '22 07:10 badboynt1

the range can be stayed

domingozhang avatar Oct 31 '22 07:10 domingozhang

these errors still keep unchanged. confirmed with @domingozhang MySQL [mo]> SELECT cast('1.1' as int); ERROR 20203 (HY000): invalid argument cast to int, bad value 1.1 MySQL [mo]> MySQL [mo]> SELECT cast('.1' as int); ERROR 20203 (HY000): invalid argument cast to int, bad value .1 MySQL [mo]> SELECT cast('' as int); ERROR 20203 (HY000): invalid argument cast to int, bad value MySQL [mo]> MySQL [mo]> SELECT cast(' ' as int); ERROR 20203 (HY000): invalid argument cast to int, bad value
MySQL [mo]> MySQL [mo]> SELECT cast('jj' as int); ERROR 20203 (HY000): invalid argument cast to int, bad value jj

badboynt1 avatar Oct 31 '22 08:10 badboynt1