trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
9.83k stars 2.85k forks source link

CREATE VIEW return incorrect information When a table with the same name exists In hive #10037

Open kyo-tom opened 2 years ago

kyo-tom commented 2 years ago

With Hive connector

trino:default> CREATE TABLE one (a varchar);
CREATE TABLE

CREATE VIEW is rejected when a table with the same name exists,but fail information indicates that the view already exists instead of the table already exists

trino:default> CREATE VIEW one AS SELECT * FROM one;
Query 20211123_061613_00037_jrn8n failed: View already exists: 'default.one'
kyo-tom commented 2 years ago

cc @sopel39

sopel39 commented 2 years ago

Message is wrong, but we shouldn't be able to create view anyway

kyo-tom commented 2 years ago

Message is wrong, but we shouldn't be able to create view anyway

I had fix this message in hive,but where should I write a test,is it in trino-product-tests module?

sopel39 commented 2 years ago

@kyo-tom you can base your test on io.trino.execution.TestCreateMaterializedViewTask

kyo-tom commented 2 years ago

io.trino.execution.TestCreateMaterializedViewTask

@sopel39 But it is the behavior of individual plugin, not all of plugin

sopel39 commented 2 years ago

@sopel39 But it is the behavior of individual plugin, not all of plugin

It should be generic across catalogs

kyo-tom commented 2 years ago

@sopel39 But it is the behavior of individual plugin, not all of plugin

It should be generic across catalogs

but some plugin is not support create views. Do you mean creating a MockMetadata

sopel39 commented 2 years ago

Yes, see how io.trino.execution.TestCreateMaterializedViewTask works

sopel39 commented 2 years ago

Fixed by https://github.com/trinodb/trino/pull/10186

findepi commented 2 years ago

https://github.com/trinodb/trino/pull/10186 fixed this on CreateViewTask level, but this also should be fixed in individual connectors' metadata classes, to take care of view/table conflict resulting from concurrent creation.