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

Cannot change case using output name (as) of an upper case column #564

Open
CaselIT opened this issue Jan 28, 2025 · 9 comments · May be fixed by #565
Open

Cannot change case using output name (as) of an upper case column #564

CaselIT opened this issue Jan 28, 2025 · 9 comments · May be fixed by #565

Comments

@CaselIT
Copy link

CaselIT commented Jan 28, 2025

Not sure if it's related, but it seems you can't change the casing of the names with as if the name is upper when reading from parquet.

create a parquet, like

duckdb -c "COPY (select generate_series as \"UPPER\", generate_series as \"lower\" FROM generate_series(100)) TO '/tmp/tmp.parquet' (FORMAT 'parquet')"

then from the postgresql

select * from read_parquet('/tmp/tmp.parquet') as t(upper int8, lower int8) limit 2;

select upper as "upper", lower as "LOWER" from read_parquet('/tmp/tmp.parquet') as t(upper int8, lower int8) limit 2;

select upper as "upper_", lower as "LOWER_" from read_parquet('/tmp/tmp.parquet') as t(upper int8, lower int8) limit 2;

output of the above queries is

 UPPER | lower
-------+-------
     0 |     0
     1 |     1
(2 rows)

 UPPER | LOWER
-------+-------
     0 |     0
     1 |     1
(2 rows)

 upper_ | LOWER_
--------+--------
      0 |      0
      1 |      1
(2 rows)

can't rename UPPER to lowercase. If you change the name it works fine.

interestingly it only happens UPPERCASE to lowercase, not the opposite as shown in the lower column

let me know if I should open a new issue

Originally posted by @CaselIT in #116

@JelteF
Copy link
Collaborator

JelteF commented Jan 28, 2025

Can you update the example to include ones with the new syntax? That makes copy pasting easier when debugging.

@CaselIT
Copy link
Author

CaselIT commented Jan 28, 2025

not sure I understand what you are asking, but I've split the sql from the output

JelteF added a commit that referenced this issue Jan 29, 2025
With the `read_parquet` syntax from before #531 we had a bug where it
was impossible to change casing of an alias from upper to lower:

```
select upper as "upper", lower as "LOWER" from read_parquet('/tmp/tmp.parquet') as t(upper int8, lower int8) limit 2;

 UPPER | LOWER
-------+-------
     0 |     0
     1 |     1
(2 rows)
```

See #564 for more details.

Luckily #531 has completely fixed this problem, so all this PR does is add
some regression tests.

Finally it also corrects the output file of the `case_insensitivity.sql`
test, which was introduced by #563. It also adds that test to the
`schedule` file, which was the reason that CI didn't notice that the
output was wrong.

Fixes #564
Related #563
@JelteF JelteF linked a pull request Jan 29, 2025 that will close this issue
@JelteF
Copy link
Collaborator

JelteF commented Jan 29, 2025

See #565 with what I meant with the "new syntax", i.e no AS t(upper int8, lower int8) is necessary anymore.

@CaselIT
Copy link
Author

CaselIT commented Jan 29, 2025

oh nice change. I didn't know about it, since I did not find it yet mentioned in the readme

@JelteF
Copy link
Collaborator

JelteF commented Jan 29, 2025

Yeah docs+readme updates are planned soon

@JelteF
Copy link
Collaborator

JelteF commented Jan 29, 2025

I'm curious how your old syntax worked with the new docker images though. Because those should fail now.

@CaselIT
Copy link
Author

CaselIT commented Jan 30, 2025

I'm just using whatever is in docker.io/pgduckdb/pgduckdb:17-main

psql (17.2 (Debian 17.2-1.pgdg120+1))
Type "help" for help.

scott=# \dx
                  List of installed extensions
   Name    | Version |   Schema   |         Description
-----------+---------+------------+------------------------------
 pg_duckdb | 0.3.0   | public     | DuckDB Embedded in Postgres
 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
(2 rows)
scott=# \! ls /tmp
foo.parquet  tmp.parquet
scott=# select * from read_parquet('/tmp/tmp.parquet') as t(upper int8, lower int8) limit 2;
 UPPER | lower
-------+-------
     0 |     0
     1 |     1
(2 rows)

@JelteF
Copy link
Collaborator

JelteF commented Jan 30, 2025

Hmm, maybe try force pulling the image? Maybe you have an old one cached.

@CaselIT
Copy link
Author

CaselIT commented Jan 30, 2025

I'm sure I pulled it yesterday. images returns:

docker.io/pgduckdb/pgduckdb  17-main     85c6dc3039c4  7 days ago     555 MB

running podman image inspect 85c6dc3039c4 --format '{{.Digest}}'
returns sha256:595a4916b725b7cce49a0d695461a872c7f5f65742d2304774a9dde79b29b32c

that seems to match the latests one on docker hub: https://hub.docker.com/layers/pgduckdb/pgduckdb/17-main/images/sha256-5c9219f89312824a2a63bd3c12694db9c99332f69786d0aa35716981a1677084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants