Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 3.0.0
    • None
    • SQL
    • None

    Description

      In PgSQL, we can use SELECT statements in VALUES of INSERT INTO;

      postgres=# create table t (c0 int, c1 int);
      CREATE TABLE
      postgres=# insert into t values (3, (select 1));
      INSERT 0 1
      postgres=# select * from t;
       c0 | c1 
      ----+----
        3 |  1
      (1 row)
      
      scala> sql("""create table t (c0 int, c1 int) using parquet""")
      
      scala> sql("""insert into t values (3, (select 1))""")
      org.apache.spark.sql.AnalysisException: unresolved operator 'Project [unresolvedalias(1, None)];;
      'InsertIntoStatement 'UnresolvedRelation [t], false, false
      +- 'UnresolvedInlineTable [col1, col2], [List(3, scalar-subquery#0 [])]
            +- 'Project [unresolvedalias(1, None)]
               +- OneRowRelation
      
        at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.failAnalysis(CheckAnalysis.scala:47)
        at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.failAnalysis$(CheckAnalysis.scala:46)
        at org.apache.spark.sql.catalyst.analysis.Analyzer.failAnalysis(Analyzer.scala:122)
        at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$36(CheckAnalysis.scala:540)
        at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$36$adapted(CheckAnalysis.scala:538)
        at org.apache.spark.sql.catalyst.trees.TreeNode.foreachUp(TreeNode.scala:154)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            maropu Takeshi Yamamuro
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: