Skip to content

Commit

Permalink
Merge branch 'main' into universalmind303/native-table-drop
Browse files Browse the repository at this point in the history
  • Loading branch information
universalmind303 authored Jan 22, 2024
2 parents 1d2828b + 0116fc1 commit 3683e88
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
11 changes: 10 additions & 1 deletion crates/datafusion_ext/src/planner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ impl<'a, S: AsyncContextProvider> SqlQueryPlanner<'a, S> {
}
SQLDataType::Bytea => Ok(DataType::Binary),
SQLDataType::Interval => Ok(DataType::Interval(IntervalUnit::MonthDayNano)),
SQLDataType::Custom(obj, _) => {
let obj = obj.to_string();
match obj.as_str() {
// PSQL uses `pg_catalog.text` for `text` type in some cases
"pg_catalog.text" => Ok(DataType::Utf8),
_ => Err(DataFusionError::NotImplemented(format!(
"Unsupported SQL type {sql_type:?}"
))),
}
}
// Explicitly list all other types so that if sqlparser
// adds/changes the `SQLDataType` the compiler will tell us on upgrade
// and avoid bugs like https://github.com/apache/arrow-datafusion/issues/3059
Expand All @@ -280,7 +290,6 @@ impl<'a, S: AsyncContextProvider> SqlQueryPlanner<'a, S> {
| SQLDataType::Blob(_)
| SQLDataType::Datetime(_)
| SQLDataType::Regclass
| SQLDataType::Custom(_, _)
| SQLDataType::Array(_)
| SQLDataType::Enum(_)
| SQLDataType::Set(_)
Expand Down
35 changes: 34 additions & 1 deletion testdata/sqllogictests/pg_catalog.slt
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,37 @@ pg_catalog_test pg_description


statement ok
select * from pg_catalog.pg_type;
select * from pg_catalog.pg_type;


# This is one of the queries postgres uses for tab completion
# see https://github.com/GlareDB/glaredb/issues/2393
statement ok
SELECT
c.relname,
NULL::pg_catalog.text
FROM pg_catalog.pg_class c
WHERE c.relkind IN ('r', 'S', 'v', 'm', 'f', 'p')
AND (c.relname) LIKE '%'
AND pg_catalog.pg_table_is_visible(c.oid)
AND c.relnamespace <> ( SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog') UNION ALL
SELECT NULL::pg_catalog.text, n.nspname
FROM pg_catalog.pg_namespace n
WHERE n.nspname LIKE '%'
AND n.nspname NOT LIKE E'pg\\_%'
LIMIT 1000;

# Another query postgres uses for tab completion
# see https://github.com/GlareDB/glaredb/issues/2393
statement ok
SELECT
c.relname,
n.nspname
FROM
pg_catalog.pg_class c,
pg_catalog.pg_namespace n
WHERE c.relnamespace = n.oid
AND c.relkind IN ('r', 'S', 'v', 'm', 'f', 'p')
AND (c.relname) LIKE '%'
AND n.nspname = 'pg_catalog'
LIMIT 1000;

0 comments on commit 3683e88

Please sign in to comment.