citusdata / pg_shard

ATTENTION: pg_shard is superseded by Citus, its more powerful replacement
https://github.com/citusdata/citus
GNU Lesser General Public License v3.0
1.06k stars 63 forks source link

CURRENT_DATE incorrectly deparsed in SELECT queries #85

Open bonesmoses opened 9 years ago

bonesmoses commented 9 years ago

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';
jasonmp85 commented 9 years ago

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?

bonesmoses commented 9 years ago

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

jasonmp85 commented 9 years ago

This will be closed by #60.