Composable query builder for Delta Sharing tables.
Example
"books"
|> Query.new()
|> Query.where("library_id = 100")
|> Query.select(["book_id", "title"])
|> Query.execute!()
|> Results.to_rows()For post-query operations (joins, filtering, conversion to rows), see DeltaQuery.Results.
Summary
Functions
Execute the query and return results.
Execute the query and return results, raising on error.
Set a limit hint for the query.
Create a new query for the given table.
Select specific columns to return.
Add a filter predicate to the query.
Types
@type t() :: %DeltaQuery.Query{ columns: [String.t()] | nil, filters: [String.t()], limit: pos_integer() | nil, table: String.t() }
Functions
@spec execute( t(), keyword() ) :: {:ok, DeltaQuery.Results.t()} | {:error, term()}
Execute the query and return results.
Options
:config- ADeltaQuery.Configstruct or keyword options for configuration. If not provided, configuration is read from application environment.
Returns {:ok, %Results{}} on success or {:error, reason} on failure.
Examples
{:ok, result} =
"books"
|> Query.new()
|> Query.select(["book_id", "title"])
|> Query.execute()
result.dataframe #=> %Explorer.DataFrame{...}
result.files_processed #=> 5
result.total_files #=> 5
# With explicit config
config = DeltaQuery.Config.new!(endpoint: "...", bearer_token: "...", share: "my_share")
{:ok, result} = Query.execute(query, config: config)
@spec execute!( t(), keyword() ) :: DeltaQuery.Results.t()
Execute the query and return results, raising on error.
Returns %Results{} on success, raises on failure.
Examples
"books"
|> Query.new()
|> Query.where("library_id = 100")
|> Query.execute!()
|> Results.to_rows()
@spec limit(t(), pos_integer()) :: t()
Set a limit hint for the query.
Note: This is a hint to the Delta Sharing server and may not be strictly enforced. Calling multiple times overwrites the previous limit.
Examples
"books"
|> Query.new()
|> Query.limit(100)
Create a new query for the given table.
Examples
iex> DeltaQuery.Query.new("books")
%DeltaQuery.Query{table: "books"}
Select specific columns to return.
If not called, all columns are returned. Calling multiple times overwrites previous selections.
Examples
"books"
|> Query.new()
|> Query.select(["book_id", "title", "author"])
Add a filter predicate to the query.
Predicates use SQL-like syntax: column operator value
Supported operators: =, !=, >, <, >=, <=
Examples
"books"
|> Query.new()
|> Query.where("library_id = 100")
|> Query.where("genre = 'Fiction'")