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

SQL query bug for basic column operations - BUG 'rename' method. #1286

Open
oualib opened this issue Sep 26, 2024 Discussed in #1140 · 0 comments
Open

SQL query bug for basic column operations - BUG 'rename' method. #1286

oualib opened this issue Sep 26, 2024 Discussed in #1140 · 0 comments
Assignees
Labels
Bug Something isn't working.

Comments

@oualib
Copy link
Member

oualib commented Sep 26, 2024

Discussed in #1140

Originally posted by mail4umar January 31, 2024
The following lines of code produces an error:

vdf = vp.vDataFrame({"a":[1,2,3]})
vdf["a"].rename("b")
vdf["c"] = "1"
vdf

The Error is:

MissingColumn: Severity: ERROR, Message: Column "a" does not exist, Sqlstate: 42703, Routine: transformSQLColumnRef, File: /data/jenkins/workspace/RE-ReleaseBuilds/RE-Laserbeam_2/server/vertica/Optimizer/OptUtil/ExprUtil.cpp, Line: 7389, Error Code: 2624, SQL: 'SELECT                      "b" AS "b", "c" AS "c"                  FROM (SELECT "a" AS "b", "c" FROM (                 SELECT                      1 AS "c"                  FROM ((SELECT 1 AS "a") UNION ALL (SELECT 2 AS "a") UNION ALL (SELECT 3 AS "a")) VERTICAPY_SUBTABLE) VERTICAPY_SUBTABLE) VERTICAPY_SUBTABLE                                   LIMIT 100 OFFSET 0'

Upon investigation and looking at the SQL I can see that there is one line incorrect:

SELECT
  "b" AS "b",
  "c" AS "c"
FROM
  (
    SELECT
      "a" AS "b",
      "c"
    FROM
      (
        SELECT
          1 AS "c",
        FROM
          (
            (
              SELECT
                1 AS "a") UNION ALL (
              SELECT
                2 AS "a") UNION ALL (
              SELECT
                3 AS "a"
            )
          ) AS VERTICAPY_SUBTABLE_1
      ) AS VERTICAPY_SUBTABLE_2
  ) AS VERTICAPY_SUBTABLE_3
LIMIT 100
OFFSET 0;

In the third nested SELECT, there is no mention of column "a".

The correct query should be:

SELECT
  "b" AS "b",
  "c" AS "c"
FROM
  (
    SELECT
      "a" AS "b",
      "c"
    FROM
      (
        SELECT
          1 AS "c",
          "a" AS "a"
        FROM
          (
            (
              SELECT
                1 AS "a") UNION ALL (
              SELECT
                2 AS "a") UNION ALL (
              SELECT
                3 AS "a"
            )
          ) AS VERTICAPY_SUBTABLE_1
      ) AS VERTICAPY_SUBTABLE_2
  ) AS VERTICAPY_SUBTABLE_3
LIMIT 100
OFFSET 0;

Note the above only happens when a new column is created using SQL string.

@oualib oualib added the Bug Something isn't working. label Sep 26, 2024
@oualib oualib added this to the VerticaPy 1.1.0 milestone Sep 26, 2024
@oualib oualib self-assigned this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

1 participant