imback82 commented on a change in pull request #26684: [SPARK-30001][SQL]
ResolveRelations should handle both V1 and V2 tables.
URL: https://github.com/apache/spark/pull/26684#discussion_r354644645
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -777,36 +772,84 @@ class Analyzer(
}
def apply(plan: LogicalPlan): LogicalPlan =
ResolveTables(plan).resolveOperatorsUp {
- case i @ InsertIntoStatement(u @
UnresolvedRelation(AsTableIdentifier(ident)), _, child, _, _)
- if child.resolved =>
- EliminateSubqueryAliases(lookupTableFromCatalog(ident, u)) match {
+ case i @ InsertIntoStatement(
+ u @ UnresolvedRelation(CatalogObjectIdentifier(catalog, ident)), _,
_, _, _)
+ if i.query.resolved && CatalogV2Util.isSessionCatalog(catalog) =>
+ val relation = ResolveTempViews(u) match {
Review comment:
> It would be good to know what other databases do in this case because my
suggestion to not resolve the identifier as a temp table would allow matching a
table here if there is one that conflicts.
In Postgres, it is resolved to temp view:
```
postgres=# create schema s1;
CREATE SCHEMA
postgres=# SET search_path TO s1;
SET
postgres=# create table s1.t (i int);
CREATE TABLE
postgres=# insert into s1.t values (1);
INSERT 0 1
# resolves to table 't'
postgres=# select * from t;
i
---
1
(1 row)
postgres=# create temp view t as select 2 as i;
CREATE VIEW
# resolves to temp view 't'
postgres=# select * from t;
i
---
2
(1 row)
# resolves to temp view 't'
postgres=# insert into t values (1);
2019-12-05 21:40:47.229 EST [5451] ERROR: cannot insert into view "t"
2019-12-05 21:40:47.229 EST [5451] DETAIL: Views that do not select from a
single table or view are not automatically updatable.
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]