You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Junqing Li (Jira)" <ji...@apache.org> on 2024/06/07 07:16:00 UTC
[jira] [Created] (SPARK-48562) Writing to JDBC Temporary View Failed
Junqing Li created SPARK-48562:
----------------------------------
Summary: 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.3, 3.5.1, 3.5.0, 3.4.1, 3.4.0, 3.4.2, 4.0.0
Reporter: Junqing Li
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.
```
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()
}
}
```
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org