I have a mysql table spam
, and create a model on spam , then when create a Question based on this model.
One bigint column named create_timestamp
of spam
be translated twice from bigint to datetime by origin table and question layers .
Spam metadata config :
create_timestamp
stored millisecond timestamp value of bigint type , configured to auto change timestamp to datetime in metabse table metadata.
in model A
query : do nothing
in question based on model A
: use create_timestamp in 'group by ' conditions , the raw sql is error , and create_timestamp by day is empty string
SELECT
DATE(FROM_UNIXTIME(`source`.`create_timestamp` / 1000)) AS `create_timestamp`, //second transform in question layer
COUNT(*) AS `count`
FROM
(
SELECT
`source`.`user_id` AS `user_id`,
`source`.`type` AS `type`,
`source`.`origin_content` AS `origin_content`,
`source`.`origin_type` AS `origin_type`,
`source`.`status` AS `status`,
`source`.`create_timestamp` AS `create_timestamp`
FROM
(
SELECT
`spam`.`user_id` AS `user_id`,
`spam`.`type` AS `type`,
`spam`.`origin_content` AS `origin_content`,
`spam`.`origin_type` AS `origin_type`,
`spam`.`status` AS `status`,
FROM_UNIXTIME(`spam`.`create_timestamp` / 1000) AS `create_timestamp` //first transform
FROM
`spam`
WHERE
(
FROM_UNIXTIME(`spam`.`create_timestamp` / 1000) >= DATE(NOW(6))
)
AND (
FROM_UNIXTIME(`spam`.`create_timestamp` / 1000) < DATE(DATE_ADD(NOW(6), INTERVAL 1 day))
)
) AS `source`
) AS `source`
GROUP BY
DATE(FROM_UNIXTIME(`source`.`create_timestamp` / 1000))
ORDER BY
DATE(FROM_UNIXTIME(`source`.`create_timestamp` / 1000)) ASC