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

Trino does not honor "hive.ignore-absent-partitions=true" #23893

Open
coquebg opened this issue Oct 24, 2024 · 1 comment
Open

Trino does not honor "hive.ignore-absent-partitions=true" #23893

coquebg opened this issue Oct 24, 2024 · 1 comment

Comments

@coquebg
Copy link

coquebg commented Oct 24, 2024

I'm using Trino with Hive connector.
Underlying storage is Google Cloud storage

After migrating some tables with Google transfer service, for some partitions that does not contains data files - their corresponding "directories" where not created
Running query against these tables rise error:

TrinoExternalError(type=EXTERNAL, name=HIVE_FILE_NOT_FOUND, message="Partition location does not exist: gs://<bucket name here>/.../.../.../.../")

Hive connector uses the following configuratioon

hive.properties
connector.name=hive
fs.cache.enabled=true
fs.cache.directories=/cache
fs.cache.max-disk-usage-percentages=95
hive.collect-column-statistics-on-write=false
hive.config.resources=/etc/trino/core-site.xml,/etc/trino/hive-site.xml
hive.hive-views.enabled=true
hive.hive-views.legacy-translation=true
hive.hive-views.run-as-invoker=true
hive.ignore-absent-partitions=true
hive.metastore.thrift.impersonation.enabled=false
hive.metastore.uri=thrift://hive:9083
hive.metastore=thrift
hive.non-managed-table-creates-enabled=true
hive.non-managed-table-writes-enabled=true
hive.security=allow-all
hive.storage-format=PARQUET

core-site.xml contains GS specific part and works as expected

Trino version 451

@coquebg
Copy link
Author

coquebg commented Oct 28, 2024

I think I found the issue.
BackgroundHiveSplitLoader.java

This method does not account for ignoreAbsentPartitions

    private static void checkPartitionLocationExists(TrinoFileSystem fileSystem, Location location)
    {
        try {
            if (!fileSystem.directoryExists(location).orElse(true)) {
                throw new TrinoException(HIVE_FILE_NOT_FOUND, "Partition location does not exist: " + location);
            }
        }
        catch (IOException e) {
            throw new TrinoException(HIVE_FILESYSTEM_ERROR, "Failed checking directory path:" + location, e);
        }
    }

It should be reworked as

    private static void checkPartitionLocationExists(TrinoFileSystem fileSystem, Location location)
    {
        try {
            if (!fileSystem.directoryExists(location).orElse(!ignoreAbsentPartitions)) {
                throw new TrinoException(HIVE_FILE_NOT_FOUND, "Partition location does not exist: " + location);
            }
        }
        catch (IOException e) {
            throw new TrinoException(HIVE_FILESYSTEM_ERROR, "Failed checking directory path:" + location, e);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant