Skip to content

Commit

Permalink
remove isdirectory check because this breaks reading from HTTPFileSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
samansmink committed Jan 22, 2025
1 parent 0e8dfaf commit 3b0b680
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/common/iceberg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,30 @@ string IcebergSnapshot::GetMetaDataPath(ClientContext &context, const string &pa
if (StringUtil::EndsWith(path, ".json")) {
// We've been given a real metadata path. Nothing else to do.
return path;
} else if (!fs.DirectoryExists(meta_path)) {
// Make sure we have a metadata directory to look in
throw IOException("Cannot open \"%s\": Metadata directory does not exist", path);
} else if(StringUtil::EndsWith(table_version, ".text")||StringUtil::EndsWith(table_version, ".txt")) {
}

if(StringUtil::EndsWith(table_version, ".text")||StringUtil::EndsWith(table_version, ".txt")) {
// We were given a hint filename
version_hint = GetTableVersionFromHint(meta_path, fs, table_version);
return GenerateMetaDataUrl(fs, meta_path, version_hint, metadata_compression_codec, version_format);
} else if (table_version != UNKNOWN_TABLE_VERSION) {
}
if (table_version != UNKNOWN_TABLE_VERSION) {
// We were given an explicit version number
version_hint = table_version;
return GenerateMetaDataUrl(fs, meta_path, version_hint, metadata_compression_codec, version_format);
} else if (fs.FileExists(fs.JoinPath(meta_path, DEFAULT_VERSION_HINT_FILE))) {
}
if (fs.FileExists(fs.JoinPath(meta_path, DEFAULT_VERSION_HINT_FILE))) {
// We're guessing, but a version-hint.text exists so we'll use that
version_hint = GetTableVersionFromHint(meta_path, fs, DEFAULT_VERSION_HINT_FILE);
return GenerateMetaDataUrl(fs, meta_path, version_hint, metadata_compression_codec, version_format);
} else if (!UnsafeVersionGuessingEnabled(context)) {
}
if (!UnsafeVersionGuessingEnabled(context)) {
// Make sure we're allowed to guess versions
throw InvalidInputException("No version was provided and no version-hint could be found, globbing the filesystem to locate the latest version is disabled by default as this is considered unsafe and could result in reading uncommitted data. To enable this use 'SET %s = true;'", VERSION_GUESSING_CONFIG_VARIABLE);
} else {
// We are allowed to guess to guess from file paths
return GuessTableVersion(meta_path, fs, table_version, metadata_compression_codec, version_format);
}

// We are allowed to guess to guess from file paths
return GuessTableVersion(meta_path, fs, table_version, metadata_compression_codec, version_format);
}


Expand Down
2 changes: 1 addition & 1 deletion test/sql/iceberg_snapshots.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ SELECT * FROM ICEBERG_SNAPSHOTS('data/iceberg/lineitem_iceberg', version='1');
statement error
SELECT * FROM ICEBERG_SNAPSHOTS('data/iceberg/lineitem_iceberg_nonexistent');
----
IO Error: Cannot open "data/iceberg/lineitem_iceberg_nonexistent": Metadata directory does not exist
Invalid Input Error: No version was provided and no version-hint could be found

statement error
SELECT * FROM ICEBERG_SNAPSHOTS('data/iceberg/lineitem_iceberg_gz');
Expand Down

0 comments on commit 3b0b680

Please sign in to comment.