Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting table_type = 'EXTERNAL_TABLE' builds a 'MANAGED_TABLE' #41

Closed
rotten opened this issue Jan 28, 2021 · 5 comments
Closed

Setting table_type = 'EXTERNAL_TABLE' builds a 'MANAGED_TABLE' #41

rotten opened this issue Jan 28, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@rotten
Copy link

rotten commented Jan 28, 2021

Sorry to open one more...

When I create an external table it ends up being created as a managed table.

            my_table = TableBuilder(
                            table_name='my_table',
                            db_name=table['DatabaseName'],
                            storage_descriptor=storage_descriptor,
                            partition_keys=partition_keys,
                            parameters=parameters,
                            table_type='EXTERNAL_TABLE',
                            owner='root'
                            ).build()

However when I look in the metastore postgresql database for that table:

# select "TBL_TYPE" from "TBLS"  where "TBL_NAME" = 'my_table';
   TBL_TYPE
---------------
 MANAGED_TABLE
(1 row)

fwiw, create table WITH (external_location = xxx) works fine from the presto client and creates the EXTERNAL_TABLE type in the database.

I'm still looking for a root cause or work-around, but thought I'd log what I've run into while I'm looking. Your examples and tests don't include creating an external table.

@rotten
Copy link
Author

rotten commented Jan 28, 2021

Adding an explicit Table Parameter of {'EXTERNAL': 'TRUE'} to the table builder object seems to trick Hive (3.0.0) into creating the table as an EXTERNAL_TABLE instead of a MANAGED_TABLE. I think it completely ignores the table_type setting.

@rotten
Copy link
Author

rotten commented Jan 28, 2021

Unfortunately, although I can query a created in presto manually, I get 0 rows back from an identical table created (with a different name) using this client. So even though the "SHOW CREATE TABLE" command outputs are now identical, and the TBL_TYPE is now correct, there is something else not quite right - still investigating.

@LucasMMota LucasMMota self-assigned this Jan 29, 2021
@LucasMMota LucasMMota added the bug Something isn't working label Jan 29, 2021
@rotten
Copy link
Author

rotten commented Jan 29, 2021

To follow up on the investigation into the 0 rows issue after the table was re-created. That one example I was testing appears to have had an underlying storage issue. Once that was resolved, the queries worked. I've gone back and recreated 75 of my tables now with the extra Table Parameter set, and that switched them all to EXTERNAL_TABLE when I did so and they started working.

@LucasMMota
Copy link
Contributor

Hi @rotten thank you for opening this issue!
Actually, we had not realized that this problem was occurring in Hive Metastore Server. We have also faced some strange behaviors in the tables due to the EXTERNAL/MANAGED option thought.

As far as I know, after digging in the code and testing the possibilities this is a bug from Hive Metastore Server.
We will create a new method that encapsulates the behavior of adding the option {'EXTERNAL': 'TRUE'} so we can work around this issue for now.

@felipemiquelim
Copy link
Collaborator

We addressed the issue in the linked PRs and released version 1.0.4 with all due improvements 😄
Thank you again @rotten for bringing it up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants