mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-25 06:35:34 +00:00
* feat!: upgrade DataFusion dependencies to 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * refactor: migrate DataFusion 55 APIs Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: preserve table function planning behavior Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: preserve PostgreSQL query compatibility Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: preserve distributed execution plan behavior Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: cover DataFusion 55 behavior regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: update DataFusion 55 SQLness expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: complete DataFusion 55 test API migration Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: address DataFusion 55 CI regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: address remaining DataFusion 55 regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: adapt latest base code to DataFusion 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: normalize environment-specific DataFusion 55 plans Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: align final DataFusion 55 expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: isolate DataFusion 55 regression cases Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: preserve empty result schema in timestamp widening Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: preserve JSON source column order Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * chore: use released DataFusion 55 integrations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: adapt latest execution plan mock to DataFusion 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: pin DataFusion recursive schema and date repairs Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(promql): align dictionary temporality match keys Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: retain Greptime DataFusion fork behaviors on version 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore ordinary function error expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh distributed count compatibility plan Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(query): adapt last-row cast hint to DataFusion 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh instant last-row empty results for Arrow 59 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * style: simplify DataFusion expression visitor imports Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore sorting and PostgreSQL column-order assertions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(function): restore primitive numeric coercion signatures Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * refactor(function): share geo integer signature types Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: cover timestamp widening overflow boundaries Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: fix decimal coercion regression imports Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(function): preserve scalar count_hash NULL state semantics Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: simplify decimal clamp case type inference Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: retain historical count_hash wrapper result Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: restore timestamp widening equality and IN pruning Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: carry upstream aggregate dynamic filter correctness fix Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: carry upstream null and predicate simplification fixes Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore baseline JSON ordering expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore histogram JSON ordering expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh empty PromQL range result schemas Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: align native timestamp plan with DF55 decimal display Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh native timestamp SQLness results for DF55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: regenerate NULL sample empty result headers for DF55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: use DF55 child replacement API in timestamp regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: expose pushed scan dynamic filters to DF55 producers Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: encode string-backed PostgreSQL OID aliases in binary results Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: verify REGPROC binary and text over PostgreSQL protocol Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: register real PostgreSQL catalogs in server fixtures Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: complete DF55 expression inventories for custom query plans Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: correct RangeSelect expression fixture and column identities Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * ci: wait for Kafka WAL helper deployment rollout Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: update custom storage empty result headers Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: require exact row counts in scan statistics Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: suppress deprecated partition_statistics warning in test Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> --------- Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> Co-authored-by: Ning Sun <sunng@protonmail.com>
307 lines
9.9 KiB
SQL
307 lines
9.9 KiB
SQL
-- should not able to create pg_catalog
|
|
create database pg_catalog;
|
|
|
|
-- session_user because session_user is based on the current user so is not null is for test
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT session_user is not null;
|
|
|
|
-- SQLNESS REPLACE PostgreSQL.* VERSION
|
|
-- SQLNESS REPLACE [\s\-]+
|
|
-- current_schema
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select current_schema(), current_schemas(true), current_schemas(false), version(), current_database();
|
|
|
|
-- search_path for pg using schema for now FIXME when support real search_path
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
show search_path;
|
|
|
|
-- set search_path for pg using schema for now FIXME when support real search_path
|
|
create database test;
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
set search_path to 'test';
|
|
drop database test;
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
set search_path to 'public';
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
set search_path = public;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select current_schema();
|
|
|
|
-- make sure all the pg_catalog tables are only visible to postgres
|
|
select * from pg_catalog.pg_class;
|
|
select * from pg_catalog.pg_namespace;
|
|
select * from pg_catalog.pg_type;
|
|
select * from pg_catalog.pg_database;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select * from pg_catalog.pg_type order by oid;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
-- SQLNESS REPLACE (\d+\s*) OID
|
|
select * from pg_catalog.pg_database where datname = 'public';
|
|
|
|
-- \d
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT n.nspname as "Schema",
|
|
c.relname as "Name",
|
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
|
|
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
|
|
FROM pg_catalog.pg_class c
|
|
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
WHERE c.relkind IN ('r','p','v','m','S','f','')
|
|
AND n.nspname <> 'pg_catalog'
|
|
AND n.nspname !~ '^pg_toast'
|
|
AND n.nspname <> 'information_schema'
|
|
AND n.nspname <> 'greptime_private'
|
|
AND pg_catalog.pg_table_is_visible(c.oid)
|
|
ORDER BY 1,2;
|
|
|
|
-- \dt
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT n.nspname as "Schema",
|
|
c.relname as "Name",
|
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
|
|
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
|
|
FROM pg_catalog.pg_class c
|
|
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
WHERE c.relkind IN ('r','p','')
|
|
AND n.nspname <> 'pg_catalog'
|
|
AND n.nspname !~ '^pg_toast'
|
|
AND n.nspname <> 'information_schema'
|
|
AND n.nspname <> 'greptime_private'
|
|
AND pg_catalog.pg_table_is_visible(c.oid)
|
|
ORDER BY 1,2;
|
|
|
|
-- make sure oid of namespace keep stable
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
-- SQLNESS REPLACE (\d+\s*) OID
|
|
SELECT * FROM pg_namespace ORDER BY nspname;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
create database my_db;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use my_db;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
create table foo
|
|
(
|
|
ts TIMESTAMP TIME INDEX
|
|
);
|
|
|
|
-- show tables in `my_db`
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select relname
|
|
from pg_catalog.pg_class
|
|
where relnamespace = (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname = 'my_db'
|
|
);
|
|
|
|
-- \dt
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT n.nspname as "Schema",
|
|
c.relname as "Name",
|
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
|
|
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
|
|
FROM pg_catalog.pg_class c
|
|
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
WHERE c.relkind IN ('r','p','')
|
|
AND n.nspname <> 'pg_catalog'
|
|
AND n.nspname !~ '^pg_toast'
|
|
AND n.nspname <> 'information_schema'
|
|
AND n.nspname <> 'greptime_private'
|
|
AND pg_catalog.pg_table_is_visible(c.oid)
|
|
ORDER BY 1,2;
|
|
|
|
-- show tables in `my_db`, `public`
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select relname
|
|
from pg_catalog.pg_class
|
|
where relnamespace in (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname = 'my_db' or nspname = 'public'
|
|
)
|
|
order by relname;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
select relname
|
|
from pg_catalog.pg_class
|
|
where relnamespace in (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname like 'my%'
|
|
);
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT
|
|
CASE WHEN
|
|
quote_ident(table_schema) IN (
|
|
SELECT
|
|
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
|
|
FROM
|
|
generate_series(
|
|
array_lower(string_to_array(current_setting('search_path'),','),1),
|
|
array_upper(string_to_array(current_setting('search_path'),','),1)
|
|
) as i,
|
|
string_to_array(current_setting('search_path'),',') s
|
|
)
|
|
THEN quote_ident(table_name)
|
|
ELSE quote_ident(table_schema) || '.' || quote_ident(table_name)
|
|
END AS "table"
|
|
FROM information_schema.tables
|
|
WHERE quote_ident(table_schema) NOT IN ('information_schema',
|
|
'pg_catalog',
|
|
'greptime_private',
|
|
'_timescaledb_cache',
|
|
'_timescaledb_catalog',
|
|
'_timescaledb_internal',
|
|
'_timescaledb_config',
|
|
'timescaledb_information',
|
|
'timescaledb_experimental')
|
|
ORDER BY CASE WHEN
|
|
quote_ident(table_schema) IN (
|
|
SELECT
|
|
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
|
|
FROM
|
|
generate_series(
|
|
array_lower(string_to_array(current_setting('search_path'),','),1),
|
|
array_upper(string_to_array(current_setting('search_path'),','),1)
|
|
) as i,
|
|
string_to_array(current_setting('search_path'),',') s
|
|
) THEN 0 ELSE 1 END, 1;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT quote_ident(column_name) AS "column", data_type AS "type"
|
|
FROM information_schema.columns
|
|
WHERE
|
|
CASE WHEN array_length(parse_ident('my_db.foo'),1) = 2
|
|
THEN quote_ident(table_schema) = (parse_ident('my_db.foo'))[1]
|
|
AND quote_ident(table_name) = (parse_ident('my_db.foo'))[2]
|
|
ELSE quote_ident(table_name) = 'my_db.foo'
|
|
AND
|
|
quote_ident(table_schema) IN (
|
|
SELECT
|
|
CASE WHEN trim(s[i]) = '"$user"' THEN user ELSE trim(s[i]) END
|
|
FROM
|
|
generate_series(
|
|
array_lower(string_to_array(current_setting('search_path'),','),1),
|
|
array_upper(string_to_array(current_setting('search_path'),','),1)
|
|
) as i,
|
|
string_to_array(current_setting('search_path'),',') s
|
|
)
|
|
END;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
-- SQLNESS REPLACE (\d+\s*) OID
|
|
select relnamespace, relname, relkind
|
|
from pg_catalog.pg_class
|
|
where relnamespace in (
|
|
select oid
|
|
from pg_catalog.pg_namespace
|
|
where nspname <> 'public'
|
|
and nspname <> 'information_schema'
|
|
and nspname <> 'pg_catalog'
|
|
and nspname <> 'greptime_private'
|
|
)
|
|
order by relnamespace, relname;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use public;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
drop schema my_db;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use pg_catalog;
|
|
|
|
-- pg_class
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
desc table pg_class;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
desc table pg_namespace;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
drop table my_db.foo;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
use public;
|
|
|
|
-- PostgreSQL description functions - placeholder returning NULL for compatibility
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT obj_description((SELECT oid FROM pg_class LIMIT 1), 'pg_class') IS NULL AS is_null;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT obj_description((SELECT oid FROM pg_class LIMIT 1)) IS NULL AS is_null;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT col_description((SELECT oid FROM pg_class LIMIT 1), 1) IS NULL AS is_null;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT shobj_description(1, 'pg_database') IS NULL AS is_null;
|
|
|
|
-- pg_my_temp_schema returns 0 (no temp schema support)
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT pg_my_temp_schema();
|
|
|
|
-- Issue 7313
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
-- SQLNESS REPLACE (\d+\s*) OID
|
|
SELECT
|
|
oid
|
|
,nspname
|
|
,nspname = ANY (current_schemas(true)) AS is_on_search_path
|
|
|
|
,obj_description(oid, 'pg_namespace') AS comment
|
|
|
|
FROM pg_namespace; SELECT
|
|
oid
|
|
,nspname
|
|
FROM pg_namespace
|
|
WHERE oid = pg_my_temp_schema();
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
CREATE table foo
|
|
(
|
|
ts TIMESTAMP TIME INDEX,
|
|
log_data TEXT,
|
|
count_num BIGINT,
|
|
);
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
SELECT attr.attnum, attname, atttypid FROM pg_catalog.pg_class AS cls INNER JOIN
|
|
pg_catalog.pg_attribute AS attr ON cls.oid = attr.attrelid INNER JOIN
|
|
pg_catalog.pg_type AS typ ON attr.atttypid = typ.oid WHERE attr.attnum >= 0 AND
|
|
cls.oid = 'foo'::regclass::oid ORDER BY attr.attnum;
|
|
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
DROP TABLE foo;
|
|
|
|
-- array_upper / array_lower UDFs (DataFusion ships array_length but not these)
|
|
SELECT array_upper(ARRAY[1,2,3], 1), array_lower(ARRAY[5,6,7], 1);
|
|
|
|
-- NULL semantics: out-of-range dim (dim < 1) yields NULL
|
|
SELECT array_upper(ARRAY[1,2], 0), array_lower(ARRAY[1,2], 0);
|
|
|
|
-- generate_series with int4 bounds from array_upper must execute (widened to int8)
|
|
SELECT n FROM generate_series(1, array_upper(ARRAY[10,20,30], 1)) AS t(n);
|
|
|
|
-- ADBC type-info predicate: retain bool, excluding zero receivers and arrays.
|
|
-- SQLNESS PROTOCOL POSTGRES
|
|
WITH type_info AS (
|
|
SELECT oid, typname, typreceive, typbasetype, typrelid, typarray
|
|
FROM pg_catalog.pg_type
|
|
WHERE (typreceive != 0 OR typsend != 0)
|
|
AND typtype != 'r'
|
|
AND typreceive::TEXT != 'array_recv'
|
|
)
|
|
SELECT oid, typname, typreceive
|
|
FROM type_info
|
|
WHERE oid IN (16, 269, 1000)
|
|
ORDER BY oid;
|