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

tupleToNameValuePairs changed behavior between 22.2 and 22.3 #36773

Closed
jnd77 opened this issue Apr 29, 2022 · 1 comment
Closed

tupleToNameValuePairs changed behavior between 22.2 and 22.3 #36773

jnd77 opened this issue Apr 29, 2022 · 1 comment
Labels
backward compatibility st-wontfix Known issue, no plans to fix it currenlty

Comments

@jnd77
Copy link

jnd77 commented Apr 29, 2022

Describe the issue
tupleToNameValuePairs output is changing when using the columns from a table.
The name used to be the column name. It now is the index

How to reproduce
When using the docker clickhouse-server:22.2-alpine and clickhouse-server:22.2-alpine and the docker client.

Here is the setup:

CREATE TABLE test (`p100` Float64, `p200` Float64) ENGINE = Memory;
INSERT INTO test VALUES (4.2, 5.3);
SELECT tupleToNameValuePairs((p100, p200)) FROM test

The output with 22.2 was:

┌─tupleToNameValuePairs(tuple(p100, p200))─┐
│ [('p100',4.2),('p200',5.3)]              │
└──────────────────────────────────────────┘

while the output with 22.3 is:

┌─tupleToNameValuePairs(tuple(p100, p200))─┐
│ [('1',4.2),('2',5.3)]                    │
└──────────────────────────────────────────┘
@UnamedRus
Copy link
Contributor

This is really pity.

We need to go back to ugly

SELECT
    suppkey,
    brand,
    category,
    quantity
FROM sales_w
ARRAY JOIN
    [AA, AB, AC, AD] AS quantity,
    splitByString(', ', 'AA, AB, AC, AD') AS category
ORDER BY suppkey ASC

┌─suppkey─┬─brand───┬─category─┬─quantity─┐
│       1 │ BRAND_A │ AA       │     1500 │
│       1 │ BRAND_A │ AB       │     4200 │
│       1 │ BRAND_A │ AC       │     1600 │
│       1 │ BRAND_A │ AD       │     9800 │
│       2 │ BRAND_B │ AA       │     6200 │
│       2 │ BRAND_B │ AB       │     1300 │
│       2 │ BRAND_B │ AC       │     5800 │
│       2 │ BRAND_B │ AD       │     3100 │
│       3 │ BRAND_C │ AA       │     5000 │
│       3 │ BRAND_C │ AB       │     8900 │
│       3 │ BRAND_C │ AC       │     6900 │
│       3 │ BRAND_C │ AD       │     3400 │
└─────────┴─────────┴──────────┴──────────┘

Instead of clean and cool

SELECT
    suppkey,
    brand,
    tpl.1 AS category,
    tpl.2 AS quantity
FROM sales_w
ARRAY JOIN tupleToNameValuePairs((AA, AB, AC, AD)) AS tpl
ORDER BY suppkey ASC

┌─suppkey─┬─brand───┬─category─┬─quantity─┐
│       1 │ BRAND_A │ AA       │     1500 │
│       1 │ BRAND_A │ AB       │     4200 │
│       1 │ BRAND_A │ AC       │     1600 │
│       1 │ BRAND_A │ AD       │     9800 │
│       2 │ BRAND_B │ AA       │     6200 │
│       2 │ BRAND_B │ AB       │     1300 │
│       2 │ BRAND_B │ AC       │     5800 │
│       2 │ BRAND_B │ AD       │     3100 │
│       3 │ BRAND_C │ AA       │     5000 │
│       3 │ BRAND_C │ AB       │     8900 │
│       3 │ BRAND_C │ AC       │     6900 │
│       3 │ BRAND_C │ AD       │     3400 │
└─────────┴─────────┴──────────┴──────────┘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backward compatibility st-wontfix Known issue, no plans to fix it currenlty
Projects
None yet
Development

No branches or pull requests

4 participants