Skip to content

Commit

Permalink
another test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxxen committed Nov 18, 2024
1 parent e0ddd5a commit e879857
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/excel/xlsx/read_xlsx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ static void ParseXLSXFileMeta(const unique_ptr<XLSXReadData> &result, ZipFileRea
for (auto &sheet : candidate_sheets) {
all_sheets.push_back(sheet.first);
}
StringUtil::CandidatesErrorMessage(all_sheets, options.sheet, "Did you mean: ");
throw BinderException("Sheet \"%s\" not found in xlsx file \"%s\"\n%s", result->file_path, options.sheet);
auto suggestions = StringUtil::CandidatesErrorMessage(all_sheets, options.sheet, "Did you mean");
throw BinderException("Sheet \"%s\" not found in xlsx file \"%s\"%s", result->file_path, options.sheet, suggestions);
}
result->sheet_path = found->second;
}
Expand Down
Binary file added test/data/xlsx/two_sheets.xlsx
Binary file not shown.
51 changes: 51 additions & 0 deletions test/sql/excel/xlsx/two_sheets.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require excel

# By default we use the first sheet
query II
SELECT * FROM read_xlsx('test/data/xlsx/two_sheets.xlsx')
----
42 1337

query II
SELECT * FROM read_xlsx('test/data/xlsx/two_sheets.xlsx', header = false)
----
A B
42.0 1337.0


query II
SELECT X, Y FROM read_xlsx('test/data/xlsx/two_sheets.xlsx', sheet = 'My Sheet', header = true)
----
foo bar

query II
SELECT * FROM read_xlsx('test/data/xlsx/two_sheets.xlsx', sheet = 'My Sheet', header = false)
----
X Y
foo bar

query III
SELECT * FROM read_xlsx('test/data/xlsx/two_sheets.xlsx', sheet = 'My Sheet', range := 'A1:C4')
----
NULL NULL NULL
NULL NULL NULL
NULL X Y
NULL foo bar

query III
SELECT * FROM read_xlsx('test/data/xlsx/two_sheets.xlsx', sheet = 'My Sheet', range := 'A2:C4')
----
NULL NULL NULL
NULL X Y
NULL foo bar

query II
SELECT X, Y FROM read_xlsx('test/data/xlsx/two_sheets.xlsx', sheet = 'My Sheet', range := 'B3:C4', header = true)
----
foo bar

# Sheet not found? Provide suggestions
statement error
SELECT * FROM read_xlsx('test/data/xlsx/two_sheets.xlsx', sheet = 'Sh')
----
Did you mean: "Sheet1", "My Sheet"

0 comments on commit e879857

Please sign in to comment.