adjust / parquet_fdw

Parquet foreign data wrapper for PostgreSQL
PostgreSQL License
333 stars 37 forks source link

Crash when create pathkey for sorted option in UNION query #86

Open MinhLA1410 opened 3 weeks ago

MinhLA1410 commented 3 weeks ago
CREATE FOREIGN TABLE example1 (
    one     INT8,
    two     INT8[],
    three   TEXT,
    four    TIMESTAMP,
    five    DATE,
    six     BOOL,
    seven   FLOAT8)
SERVER parquet_srv
OPTIONS (filename '/tmp/data_local/data/simple/example1.parquet', sorted 'one');

CREATE FOREIGN TABLE example2 (
    one     INT8,
    two     INT8[],
    three   TEXT,
    four    TIMESTAMP,
    five    DATE,
    six     BOOL,
    seven   FLOAT8)
SERVER parquet_srv
OPTIONS (filename '/tmp/data_local/data/simple/example2.parquet', sorted 'one');

postgres=# SELECT 1 AS type,one FROM example1 UNION ALL SELECT 2 AS type,one FROM example2 ORDER BY type,one;
 type | one 
------+-----
    1 |   1
    1 |   2
    1 |   3
    1 |   4
    1 |   5
    1 |   6
    2 |   1
    2 |   3
    2 |   5
    2 |   7
    2 |   9
(11 rows)

postgres=# SELECT 1 AS type,one FROM example1 UNION ALL SELECT 2 AS type,one FROM example2 ORDER BY type;
TRAP: FailedAssertion("rel->reloptkind == RELOPT_BASEREL || rel->reloptkind == RELOPT_DEADREL", File: "equivclass.c", Line: 760, PID: 2418941)
postgres: vagrant postgres [local] SELECT(ExceptionalCondition+0xb9)[0xb1fb37]
postgres: vagrant postgres [local] SELECT(get_eclass_for_sort_expr+0x51b)[0x82d880]
postgres: vagrant postgres [local] SELECT[0x83f42b]
postgres: vagrant postgres [local] SELECT(build_expression_pathkey+0xdf)[0x840202]
/home/vagrant/workplace/version_postgres/postgresql-15.0/PGS/lib/parquet_fdw.so(parquetGetForeignPaths+0x4d9)[0x7fe78939d8e9]
za-arthur commented 2 weeks ago

Thank you for the report.

The issue should be solved by the PR https://github.com/adjust/parquet_fdw/pull/66. I didn't merge it yet because there is another case when it crashes, although it shouldn't be related with the PR itself, I think there is a bug related to that query.