pg_shard icon indicating copy to clipboard operation
pg_shard copied to clipboard

CURRENT_DATE incorrectly deparsed in SELECT queries

Open bonesmoses opened this issue 9 years ago • 3 comments

When submitting a query to a worker node that contains CURRENT_DATE, the term is translated to ('now'::cstring)::date which produces the following error on the worker nodes:

ERROR:  cannot cast type cstring to date at character 84
STATEMENT:  SELECT NULL::unknown FROM ONLY sys_order_10130 WHERE (order_dt >= (('now'::cstring)::date - '7 days'::interval))

Steps to reproduce

After installing from a current git clone:

CREATE TABLE sys_order
(
    order_id     INT        PRIMARY KEY,
    product_id   INT        NOT NULL,
    item_count   INT        NOT NULL,
    order_dt     DATE       NOT NULL
);

SELECT master_create_distributed_table('sys_order', 'order_id');
SELECT master_create_worker_shards('sys_order', 16, 2);

INSERT INTO sys_order VALUES (1, 2, 3, '2015-03-12');

SELECT COUNT(1) FROM sys_order
WHERE order_dt >= CURRENT_DATE - INTERVAL '7 days';

bonesmoses avatar Mar 12 '15 18:03 bonesmoses

Thanks for the clear bug report and copy-paste repro case! One more thing for posterity's sake: what version of PostgreSQL were you testing this against?

jasonmp85 avatar Mar 13 '15 22:03 jasonmp85

This was a 9.4.1 release from the PGDG PostgreSQL Apt repo.

bonesmoses avatar Mar 14 '15 18:03 bonesmoses

This will be closed by #60.

jasonmp85 avatar Sep 03 '15 05:09 jasonmp85