heterodb / pg-strom

PG-Strom - Master development repository
http://heterodb.github.io/pg-strom/
Other
1.27k stars 163 forks source link

arrow_fdw: ERROR attribute 2 of type regtest_arrow has wrong type #762

Closed 0-kaz closed 2 months ago

0-kaz commented 2 months ago

arrow_fdw外部テーブルで以下のエラーメッセージが発生。

発生コミット:6ee93d6dff13036ac5e37ce38542f7586e02320d PG16で確認。

ERROR:  attribute 2 of type regtest_arrow has wrong type
DETAIL:  Table has type integer, but query expects date.

再現クエリ

DROP TABLE IF EXISTS arrow_index_data;
DROP FOREIGN TABLE IF EXISTS regtest_arrow;

CREATE TABLE arrow_index_data (
  id         int,
  date_num        date,
  int_num         int
);

INSERT INTO arrow_index_data (
    SELECT x,
        pgstrom.random_date(0),
        pgstrom.random_int(0, -16777216, 16777216)   -- int_num
    FROM generate_series(1,1000000) x);

\! ~/pg-strom/arrow-tools/pg2arrow -s 4m --set=timezone:Asia/Tokyo -d postgres -c 'SELECT * FROM arrow_index_data ORDER BY date_num' -o /tmp/test_arrow_index.data --stat=date_num --progress

IMPORT FOREIGN SCHEMA regtest_arrow
  FROM SERVER arrow_fdw
  INTO public
OPTIONS (file '/tmp/test_arrow_index.data');

SELECT count(*)
  FROM regtest_arrow
 WHERE date_num between '2019-04-14' and '2023-05-23';
-- 発生
kaigai commented 2 months ago

7a3eb511245c3dbab3ed11e1542e15132c64754f で修正しました。

ArrowのHintを評価する式表現が(INDEX_VAR + custom_scan_tlist のインデックス)になっていたままだったので、 間違った列を参照するというズレが発生していました。

0-kaz commented 2 months ago

解消確認できました。クローズします。