Max Gekk created SPARK-52261:
--------------------------------

             Summary: Misleading error: Invalid usage of '*'
                 Key: SPARK-52261
                 URL: https://issues.apache.org/jira/browse/SPARK-52261
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 4.0.0
            Reporter: Max Gekk


The code below raises the misleading error:

{code:java}
[INVALID_USAGE_OF_STAR_OR_REGEX] Invalid usage of '*' in Project. SQLSTATE: 
42000; line 7 pos 9;
{code}

{code:sql}
    sql(
      """with foo as (
        |  values ("one", 1), ("two", 2), ("three", 3) as a (str, num)
        |  union all
        |  values ("four"), ("five"), ("six") as b (str)
        |),
        |bar as (
        |  select * from foo
        |)
        |select * from foo
        |""".stripMargin).collect()
{code}

The error is not caused by '*' usage, and should be similar to:

{code:sql}
    sql(
      """with foo as (
        |  values ("one", 1), ("two", 2), ("three", 3) as a (str, num)
        |  union all
        |  values ("four"), ("five"), ("six") as b (str)
        |)
        |select * from foo
        |""".stripMargin).collect()
{code}

{code:java}
[NUM_COLUMNS_MISMATCH] UNION can only be performed on inputs with the same 
number of columns, but the first input has 2 columns and the second input has 1 
columns. SQLSTATE: 42826; line 2 pos 2;
{code}







--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to