Skip to content

Invalid JSON value for CAST to DATE/TIME/DATETIME/TIMESTAMP from column json_extract for virtual column #13722

@wjhuang2016

Description

@wjhuang2016

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
create table t1 (a timestamp as (json_extract(k,'$.a')), b datetime as (json_extract(k, '$.a')) stored, k json);
insert into t1 set k='{\"a\":\"2018-09-28 12:59:51\"}';
select * from t1;
  1. What did you expect to see?
    Get the data.

  2. What did you see instead?

mysql> select * from t1;
+---+---------------------+------------------------------+
| a | b                   | k                            |
+---+---------------------+------------------------------+
| NULL | 2018-09-28 12:59:51 | {"a": "2018-09-28 12:59:51"} |
+---+---------------------+------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+---------------------------------------------------+
| Level   | Code | Message                                           |
+---------+------+---------------------------------------------------+
| Warning | 1105 | cannot convert datum from json to type timestamp. |
+---------+------+---------------------------------------------------+
1 row in set (0.00 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

master

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions