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

remove isdirectory check #96

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/common/iceberg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,29 @@ 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);
throw IOException("Failed to read iceberg table. 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);
}

// 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_metadata.test
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ lineitem_iceberg_gz/metadata/23f9dbea-1e7f-4694-a82c-dc3c9a94953e-m0.avro 0 DATA
statement error
SELECT * FROM ICEBERG_METADATA('data/iceberg/lineitem_iceberg_nonexistent');
----
IO Error: Cannot open "data/iceberg/lineitem_iceberg_nonexistent": Metadata directory does not exist
IO Error: Failed to read iceberg table. No version was provided and no version-hint could be found,

statement error
SELECT * FROM ICEBERG_METADATA('data/iceberg/lineitem_iceberg_no_hint', ALLOW_MOVED_PATHS=TRUE);
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
IO Error: Failed to read iceberg table. No version was provided and no version-hint could be found,

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