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

Add function clause for %FSS.HTTP.Entry{} #992

Merged
merged 4 commits into from
Sep 24, 2024
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
1 change: 1 addition & 0 deletions lib/explorer/data_frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ defmodule Explorer.DataFrame do
end

defp normalise_entry(%Local.Entry{} = entry, nil), do: {:ok, entry}
defp normalise_entry(%HTTP.Entry{} = entry, nil), do: {:ok, entry}
defp normalise_entry(%S3.Entry{config: %S3.Config{}} = entry, nil), do: {:ok, entry}

defp normalise_entry("s3://" <> _rest = entry, config) do
Expand Down
22 changes: 22 additions & 0 deletions test/explorer/data_frame/parquet_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,28 @@ defmodule Explorer.DataFrame.ParquetTest do
assert DF.to_columns(df1) == DF.to_columns(df)
end

test "reads a parquet file from an FSS entry", %{bypass: bypass, df: df_expected} do
# Setup a `GET` expectation for `path` that returns the expected
# DataFrame as a `parquet` binary.
path = "/path/to/file.parquet"
authorization = "Bearer my-token"

Bypass.expect(bypass, "GET", path, fn conn ->
assert [^authorization] = Plug.Conn.get_req_header(conn, "authorization")
bytes = Explorer.DataFrame.dump_parquet!(df_expected)
Plug.Conn.resp(conn, 200, bytes)
end)

# Build an `%FSS.HTTP.Entry{}` for `path` manually.
url = bypass |> http_endpoint() |> Path.join(path)
config = [headers: [{"authorization", authorization}]]
{:ok, %FSS.HTTP.Entry{} = entry} = FSS.HTTP.parse(url, config: config)

# Assert that we can read the parquet binary from that entry.
{:ok, df_actual} = DF.from_parquet(entry)
assert DF.to_columns(df_expected) == DF.to_columns(df_actual)
end

test "cannot find a parquet file", %{bypass: bypass} do
Bypass.expect(bypass, "GET", "/path/to/file.parquet", fn conn ->
Plug.Conn.resp(conn, 404, "not found")
Expand Down
Loading