RESULT_SCAN Table Function: Changes to Duplicate Column Names

Attention

This behavior change is in the 2023_03 bundle.

For the current status of the bundle, refer to Bundle History.

Currently, if there are duplicate column names in the results processed by the RESULT_SCAN function, the function appends a suffix to each duplicate column name to make the column names unique. For example, if two columns are named id, the function returns a table with the column names id and id_1.

The way that the RESULT_SCAN function handles duplicate column names behaves as follows:

Previously:

If the results contain duplicate column names, the RESULT_SCAN function appends _<n> to each duplicate column name to make the column names unique.

The function appends this suffix even when there are other columns with the same suffix. This can result in duplicate column names.

For example:

SELECT 1 AS a, 2 AS a_1, 3 AS a;
+---+-----+---+
| A | A_1 | A |
|---+-----+---|
| 1 |   2 | 3 |
+---+-----+---+
SELECT * FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));
+---+-----+-----+
| A | A_1 | A_1 |
|---+-----+-----|
| 1 |   2 |   3 |
+---+-----+-----+
Copy
Currently:

The RESULT_SCAN function appends a suffix with the next available number to make the column names unique:

SELECT * FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));
+---+-----+-----+
| A | A_1 | A_2 |
|---+-----+-----|
| 1 |   2 |   3 |
+---+-----+-----+
Copy

Ref: 1039