cube-js / cube-js/cube

Error when Felt tries to query

Open
#10,320 1 comment 0 reactions 0 assignees View on GitHub
api:sql
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Failed SQL**
```
Query 1 ERROR at Line 1: : ERROR: Initial planning error: Error during planning: No field named 'all_tables.relation_schema'. Valid fields are 'relation_name', 'relation_schema', 'relation_type', 'n.oid', 'n.nspname', 'n.nspowner', 'n.nspacl', 'n.xmin'.
QUERY: WITH tables AS (SELECT table_name AS relation_name, table_schema AS relation_schema, 'table' AS relation_type FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = 'public' AND table_schema NOT IN ('information_schema', 'ogr_system_tables', '_timescaledb_catalog', '_timescaledb_functions', '_timescaledb_internal', '_timescaledb_cache', '_timescaledb_config', 'timescaledb_experimental', 'timescaledb_information', '_timescaledb_debug', 'auth', 'extensions', 'graphql', 'graphql_public', 'realtime', 'storage', 'vault', 'cron') AND table_schema NOT ILIKE 'pg%%' AND table_name NOT IN ('spatial_ref_sys') AND table_name NOT ILIKE 'pg%%'), views AS (SELECT table_name AS relation_name, table_schema AS relation_schema, 'view' AS relation_type FROM information_schema.views WHERE table_schema NOT IN ('information_schema', 'ogr_system_tables', '_timescaledb_catalog', '_timescaledb_functions', '_timescaledb_internal', '_timescaledb_cache', '_timescaledb_config', 'timescaledb_experimental', 'timescaledb_information', '_timescaledb_debug', 'auth', 'extensions', 'graphql', 'graphql_public', 'realtime', 'storage', 'vault', 'cron') AND table_schema = 'public' AND table_schema NOT ILIKE 'pg%%' AND table_name NOT IN ('geometry_columns', 'geography_columns', 'raster_columns', 'raster_overviews') AND table_name NOT ILIKE 'pg%%'), materialized_views AS (SELECT matviewname AS relation_name, schemaname AS relation_schema, 'materialized_view' AS relation_type FROM pg_matviews WHERE schemaname NOT IN ('information_schema', 'ogr_system_tables', '_timescaledb_catalog', '_timescaledb_functions', '_timescaledb_internal', '_timescaledb_cache', '_timescaledb_config', 'timescaledb_experimental', 'timescaledb_information', '_timescaledb_debug', 'auth', 'extensions', 'graphql', 'graphql_public', 'realtime', 'storage', 'vault', 'cron') AND schemaname = 'public' AND schemaname NOT ILIKE 'pg%%' AND matviewname NOT ILIKE 'pg%%'), all_tables AS (SELECT * FROM tables UNION ALL SELECT * FROM views UNION ALL SELECT * FROM materialized_views) SELECT all_tables.* FROM all_tables JOIN pg_namespace AS n ON n.nspname = all_tables.relation_schema JOIN pg_class AS c ON c.relname = all_tables.relation_name AND c.relnamespace = n.oid AND c.relkind IN ('r', 'v', 'm')
```

**Logical Plan**
Can't see it anywhere

**Tool**
It was generated by [Felt](https://felt.com/)

**Version:**
Latest version

**Additional context**
If we add the alias on the end, on the `from` clause, it works (tested through TablePlus):
```
...,
all_tables AS (
SELECT
*
FROM
tables
UNION ALL
SELECT
*
FROM
views
UNION ALL
SELECT
*
FROM
materialized_views
)
SELECT
all_tables.*
FROM
all_tables as all_tables
JOIN pg_namespace AS n ON n.nspname = all_tables.relation_schema
JOIN pg_class AS c ON c.relname = all_tables.relation_name
AND c.relnamespace = n.oid
AND c.relkind IN ('r', 'v', 'm')
AND c.relpersistence = 'p'

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.