Fragments in Ecto are a way to inject raw SQL expressions directly into Elixir code to construct complex database queries.