Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group by on a :Coercion/YYYYMMDDHHMMSSBytes->Temporal postgres column fails #16335

Closed
dpsutton opened this issue Jun 3, 2021 · 1 comment · Fixed by #16336
Closed

Group by on a :Coercion/YYYYMMDDHHMMSSBytes->Temporal postgres column fails #16335

dpsutton opened this issue Jun 3, 2021 · 1 comment · Fixed by #16336

Comments

@dpsutton
Copy link
Contributor

dpsutton commented Jun 3, 2021

Setup:

postgres table

create table wut2 (t bytea, ts text);
insert into wut2 (t, ts) values ('20210421164300'::bytea, '20210421164300');

In Admin > data model, mark wut2.t as :Coercion/YYYYMMDDHHMMSSBytes->Temporal and wut2.t2 as :Coercion/YYYYMMDDHHMMSSString->Temporal. A simple question should now work and these appear as date times:

image

Open up the aggregations pane and aggregating by t2 (the string column should work).

Aggregating by t (the byte column) throws an error
image

The problem comes from the query generated:

For my column ids,

(-> (qp/process-query {:database 6
                       :query {:source-table 347
                               :aggregation [["count"]]
                               :breakout [["field" 1782 {:temporal-unit "day"}]]}
                       :type "query"
                       :parameters []})
    (update-in [:data :rows] count))

throws the error and generates this sql:

SELECT CAST(to_timestamp(convert_from(\"public\".\"wut\".\"t\", ?), 'YYYYMMDDHH24MISS') AS date) AS \"t\",
       count(*) AS \"count\" FROM \"public\".\"wut\"
GROUP BY CAST(to_timestamp(convert_from(\"public\".\"wut\".\"t\", ?), 'YYYYMMDDHH24MISS') AS date)
ORDER BY CAST(to_timestamp(convert_from(\"public\".\"wut\".\"t\", ?), 'YYYYMMDDHH24MISS') AS date) ASC
-- params are ("UTF8" "UTF8" "UTF8")
@nemanjaglumac
Copy link
Member

Is there a way to create these custom tables and to store them as docker images that we can use for repros?

@rlotun rlotun added this to the 0.40 milestone Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants