[ 
https://issues.apache.org/jira/browse/SPARK-48562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17854223#comment-17854223
 ] 

Junqing Li commented on SPARK-48562:
------------------------------------

Thanks for your reply. Since we do not restrict writes to views, users have the 
flexibility to utilize them in their scenarios. Additionally, temporary tables 
serve various purposes, such as mitigating data conflicts and minimizing 
metadata impact. Therefore, I believe it is essential to maintain support for 
this behavior unless a specific rule is implemented to explicitly prohibit such 
operations.

> Writing to JDBC Temporary View Failed
> -------------------------------------
>
>                 Key: SPARK-48562
>                 URL: https://issues.apache.org/jira/browse/SPARK-48562
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.4.2, 3.4.0, 3.4.1, 3.5.0, 4.0.0, 3.5.1, 3.4.3
>            Reporter: Junqing Li
>            Priority: Major
>
> When creating a JDBC temporary view, *ApplyCharTypePadding* would add a 
> Project before LogicalRelation if CHAR/VARCHAR column exists and Spark would 
> save it as a view plan. Then if we try to write this view, Spark would put 
> this view plan to *InsertintoStatement* in *ResolveRelations* which would 
> fall {*}PrewriteCheck{*}.
> Adding the following code to *JDBCTableCatalogSuite* would meet this problem.
> {code:java}
> test("test writing temporary jdbc view") {
>     withConnection { conn =>
>       conn.prepareStatement("""CREATE TABLE "test"."to_drop" (id 
> CHAR)""").executeUpdate()
>     }
>     sql(
>       s"""
>         CREATE TEMPORARY TABLE jdbcTable
>         USING jdbc
>         OPTIONS (
>           url='$url',
>           dbtable='"test"."to_drop"');""")
>     sql("INSERT INTO jdbcTable values(1),(2)")
>     sql("select * from test.to_drop").show()
>     withConnection { conn =>
>       conn.prepareStatement("""DROP TABLE "test"."to_drop"""").executeUpdate()
>     }
>   } {code}
>  
> Then we would get the following error.
> {code:java}
> [UNSUPPORTED_INSERT.RDD_BASED] Can't insert into the target. An RDD-based 
> table is not allowed. SQLSTATE: 42809;
> 'InsertIntoStatement Project [staticinvoke(class 
> org.apache.spark.sql.catalyst.util.CharVarcharCodegenUtils, StringType, 
> readSidePadding, ID#0, 1, true, false, true) AS ID#1], false, false, false
> +- LocalRelation [col1#3] {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