-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
api:sqlIssues related to SQL APIIssues related to SQL API
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
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'
Metadata
Metadata
Assignees
Labels
api:sqlIssues related to SQL APIIssues related to SQL API