Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return TEXT instead of VARCHAR columns #583

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pgduckdb_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ GetPostgresArrayDuckDBType(const duckdb::LogicalType &type) {
case duckdb::LogicalTypeId::UINTEGER:
return INT8ARRAYOID;
case duckdb::LogicalTypeId::VARCHAR:
return type.IsJSONType() ? JSONARRAYOID : VARCHARARRAYOID;
return type.IsJSONType() ? JSONARRAYOID : TEXTARRAYOID;
case duckdb::LogicalTypeId::DATE:
return DATEARRAYOID;
case duckdb::LogicalTypeId::TIMESTAMP:
Expand Down Expand Up @@ -1064,7 +1064,7 @@ GetPostgresDuckDBType(const duckdb::LogicalType &type) {
case duckdb::LogicalTypeId::UINTEGER:
return INT8OID;
case duckdb::LogicalTypeId::VARCHAR:
return type.IsJSONType() ? JSONOID : VARCHAROID;
return type.IsJSONType() ? JSONOID : TEXTOID;
case duckdb::LogicalTypeId::DATE:
return DATEOID;
case duckdb::LogicalTypeId::TIMESTAMP:
Expand Down
2 changes: 1 addition & 1 deletion test/regression/expected/materialized_view.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE t(a INT, b VARCHAR);
CREATE TABLE t(a INT, b TEXT);
INSERT INTO t SELECT g % 100, MD5(g::VARCHAR) FROM generate_series(1,1000) g;
SELECT COUNT(*) FROM t WHERE a % 10 = 0;
count
Expand Down
2 changes: 1 addition & 1 deletion test/regression/sql/materialized_view.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE t(a INT, b VARCHAR);
CREATE TABLE t(a INT, b TEXT);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be some bug when creating materialized views. Without changing this type we'd get an error like this:

+ERROR:  SELECT rule's target entry 2 has different type from column "b"
+DETAIL:  SELECT target entry has type character varying, but column has type text.

That shouldn't happen, the type should be detected as text everywhere.

INSERT INTO t SELECT g % 100, MD5(g::VARCHAR) FROM generate_series(1,1000) g;
SELECT COUNT(*) FROM t WHERE a % 10 = 0;
CREATE MATERIALIZED VIEW tv AS SELECT * FROM t WHERE a % 10 = 0;
Expand Down