Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/18079
  
    Currently, we have the same behaviour;
    ```
    -- PostgreSQL
    postgres=# create table t1(col1 int, col2 int);
    CREATE TABLE
    
    postgres=# select col1 as a, col2 as b from t1 as t(c, d);
    ERROR:  column "col1" does not exist at character 8
    STATEMENT:  select col1 as a, col2 as b from t1 as t(c, d);
    ERROR:  column "col1" does not exist
    LINE 1: select col1 as a, col2 as b from t1 as t(c, d);
                   ^
    -- MySQL
    mysql> create table t1(col1 int, col2 int);
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> select col1 as a, col2 as b from t1 as t(c, d);
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to use near 
'(c, d)' at line 1
    mysql> 
    
    
    -- Spark with this pr
    scala> Seq((1, 2), (2, 3)).toDF("col1", "col2").createOrReplaceTempView("t")
    
    scala> sql("select col1 as a, col2 as b from t as t(c, d)").show
    org.apache.spark.sql.AnalysisException: cannot resolve '`col1`' given input 
columns: [c, d]; line 1 pos 7;
    'Project ['col1 AS a#18, 'col2 AS b#19]
    +- SubqueryAlias t
       +- Project [col1#5 AS c#20, col2#6 AS d#21]
          +- SubqueryAlias t
             +- Project [_1#2 AS col1#5, _2#3 AS col2#6]
                +- LocalRelation [_1#2, _2#3]
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to